Skip to content

Releases

v0.1.20

Choose a tag to compare

@github-actions github-actions released this 26 Sep 12:06
4fdd7b3

Added

  • Batch resource (#9): new Batch<T>(sim, batchSize, { maxWait?, unbounded?, name? }) accumulates items and releases them as full batches, or partial batches maxWait after the first item arrived. yield batch.put(item) blocks while a formed batch is still waiting to be taken (back-pressure) unless unbounded; yield batch.take() resumes with items and isPartial. Statistics: batches formed, partial batches, average batch size, item wait, put wait, take wait. Works inside anyOf/allOf and is cleaned up on interrupt.
  • Example examples/batch-oven/.

v0.1.19

Choose a tag to compare

@github-actions github-actions released this 26 Sep 11:59
ecb2c03

Added

  • Schedule (#10): piecewise-constant, optionally periodic values over simulation time for rush hours, shifts and seasons. new Schedule(sim, { period, segments, defaultValue }), current, at(time), nextChange, hasMoreChanges, yield* waitForChange() and onChange(handler, { immediate }). Non-periodic schedules hold their last value; gaps use defaultValue or throw.
  • Resource.setCapacity(n) and a capacity getter: change staffing while the simulation runs. Growing capacity grants waiting requests immediately; shrinking never interrupts anyone, surplus units are shed as they are released. available is clamped at 0 and utilization at 1 while usage exceeds a reduced capacity.
  • The bank-tellers example staffs the counter from a schedule (opening, rush, lunch, afternoon).

v0.1.18

Choose a tag to compare

@github-actions github-actions released this 26 Sep 11:50
e84ef12

Added

  • Non-blocking and real-time execution (#11):
    • await sim.runAsync({ until?, batchSize?, signal? }) processes events in batches and yields to the event loop between them, so browser pages and servers stay responsive. Same result as run().
    • sim.runRealtime({ factor?, until? }) paces events to wall-clock time (factor = seconds per simulation unit) and returns a handle with pause(), resume(), stop(), setFactor(), isPaused, isActive and a done promise.
    • New 'progress' lifecycle event with { now, eventsProcessed, eventsInQueue }, emitted after every batch (async) or every event (real time).
    • Calling run(), runAsync() or runRealtime() while another run is in flight throws.
    • New exported types RunAsyncOptions, RealtimeOptions, RealtimeHandle, ProgressInfo.
  • The React integration guide shows a play/pause/speed control built on runRealtime.

v0.1.17

Choose a tag to compare

@github-actions github-actions released this 26 Sep 11:49
acb254a

Added

  • Process composition (#7):
    • process.done(): wait for another process to finish; result.state is 'completed' or 'interrupted' (with the error).
    • yield* anyOf([...]): wait for the first of several branches (resource/buffer/store requests, event.wait(), process.done(), timeout(n)). Pending branches are cancelled automatically; result.winner, result.index and result.completed describe the outcome. Enables reneging and balking patterns.
    • yield* allOf([...]): wait until every branch has completed (barrier / join).
    • New exports ProcessDoneRequest, AnyOfRequest, AllOfRequest, Waitable and the helpers anyOf, allOf; Process.interruptReason getter.
  • Example examples/bank-renege/: customers leave when their patience runs out.

Fixed

  • Interrupting a waiting process now cleans up its request. Previously a process interrupted while queued for a Resource, Buffer or Store stayed in the queue and was later granted the unit, which leaked capacity. All pending waits (queued requests, timeouts, event waiters, done() subscriptions) are cancelled on interrupt(). A grant that arrives in the same instant a process stops waiting is given back.
  • A waitFor() poll no longer keeps running after the process handled an interruption and moved on.

Internal

  • Resource._cancelAcquire, Buffer._cancelPut/_cancelGet, Store._cancelPut/_cancelGet remove a queued request by callback identity.
  • The two copies of the yield dispatch in Process were merged into one.

v0.1.16

Choose a tag to compare

@github-actions github-actions released this 26 Sep 11:48
3e36f15

Added

  • Experiment runner (#6): new Experiment(model) wraps a model factory (params, seed, replication) => metrics and runs it many times.
    • replicate(params, { replications, seed?, onProgress? }) returns a ReplicationResult with mean, stdDev, min, max, confidenceInterval, summary, table and toCSV.
    • sweep(space, options) runs the full factorial of a parameter space and returns a SweepResult with compare(metric), best(metric, 'min' | 'max') and toCSV().
    • Seeds are derived from the base seed with a hash (deriveSeed), so experiments are reproducible and adjacent replications are not correlated. Replication i uses the same seed in every scenario (common random numbers).
  • Example examples/experiment-mm1/: 30 replications of M/M/1 with a confidence interval next to the theoretical wait, and a server-count sweep.
  • README section "Running Experiments"; GUIDE section "One run is not an answer".

v0.1.15

Choose a tag to compare

@github-actions github-actions released this 26 Sep 11:47
537e0ff

Added

  • Confidence intervals and summaries in Statistics (#5):
    • getConfidenceInterval(name, confidence = 0.95): Student-t interval for the mean of a sample-tracked metric ({ mean, lower, upper, halfWidth, stdError, confidence, n }). Unbounded with fewer than two samples.
    • getBatchMeansCI(name, { batches = 20, confidence = 0.95 }): interval via the method of batch means, for autocorrelated within-run series such as queue waits.
    • getPercentiles(name, [50, 95, 99]): several percentiles from one sort.
    • getSummary(name, confidence?): count, mean, standard deviation, variance, min, max, p50/p95/p99 and the interval in one object.
    • Dependency-free Student-t quantiles (regularized incomplete beta with bisection, accurate to about 1e-9) in src/statistics/distributions.ts.
    • New exported types ConfidenceInterval, BatchMeansResult, BatchMeansOptions, SummaryStatistics.
  • The M/M/1 example prints a 95% confidence interval next to the theoretical mean wait.

v0.1.14

Choose a tag to compare

@github-actions github-actions released this 26 Sep 11:46
deda55f

Added

  • More distributions in Random (#8): lognormal(mu, sigma) with Random.lognormalParams(mean, stdDev), gamma(shape, scale) (Marsaglia-Tsang), erlang(k, mean), weibull(shape, scale), beta(alpha, beta), bernoulli(p), geometric(p), weightedChoice(items, weights), discrete([{ value, weight }]) and empirical(samples, { interpolate }). All are seeded from the same generator, validate their parameters with ValidationError, and document mean/variance in JSDoc. New exported types WeightedValue<T> and EmpiricalOptions.

Fixed

  • exponential(), normal() and the new log-based transforms draw from the open interval (0, 1), so they can no longer return Infinity or NaN on the one generator state per period that yields exactly 0.

v0.1.13

Choose a tag to compare

@github-actions github-actions released this 26 Sep 11:45
ea0a1f7

Added

  • Queue disciplines for Store (#4): putQueueDiscipline and getQueueDiscipline options ('fifo' | 'lifo' | 'priority', or { type, tieBreaker }) order the processes waiting to put into a full store or waiting for a matching item. store.put(item, priority?) and store.get(filter?, priority?) accept an optional priority (lower = served first, default 0). Existing calls are unchanged; the default stays FIFO on both queues. Completes queue discipline support across Resource, Buffer and Store.

Internal

  • Queue insertion logic is shared between Buffer and Store via insertByDiscipline() in src/types/queue-discipline.ts.

v0.1.12

Choose a tag to compare

@github-actions github-actions released this 26 Sep 11:44
c17e2a4

Deprecated

  • React Fast Refresh checker (#12): analyzeExportsForReact, warnReactCompatibilityIssues, withReactCompatCheck and the ExportAnalysis type are deprecated and will be removed from the package in v0.3.0. They have nothing to do with discrete-event simulation. Calling them outside test/production logs a one-time notice. A standalone copy now lives in examples/react-integration/react-compat-checker.ts; copy it into your own project if you use it.

v0.1.11

Choose a tag to compare

@github-actions github-actions released this 26 Sep 11:43
a00f600

Changed

  • Node.js 20 or newer is required (engines.node was >=16). Node 16 and 18 are end-of-life and the test tooling no longer runs on them. The library code itself is unchanged and still targets ES2020.
  • package.json declares "sideEffects": false so bundlers can tree-shake unused exports.

Internal

  • Toolchain upgrade (#3): ESLint 10 with flat config (eslint.config.mjs) and typescript-eslint 8 replace ESLint 8 and the legacy .eslintrc.json; eslint-config-prettier 10; vitest 4.1; TypeScript 5.9; typedoc 0.28; @types/node 22. Lint now also covers tests/. TypeScript 7 was evaluated and deferred because typescript-eslint does not support it yet.
  • Performance and benchmark suites moved to npm run test:perf (wall-clock assertions were flaky on shared CI runners); npm test runs the functional suites.
  • Dependabot removed; dependency upgrades are done deliberately.