Calibration

TokLang.Fit — Module
TokLang.Fit

Calibration of simulation parameters on event logs (the fit layer, see docs/calibration.md): processing times of activities, times between arrivals and branch probabilities, estimated from the XES or CSV event logs of tok sim or of a real process. fit gives maximum-likelihood estimates with confidence intervals; fit_bayes gives posterior estimates with credible intervals when Turing.jl is loaded (using Turing). apply writes the estimates into the document.

log = TokLang.Fit.read_xes("log.xes")
f = TokLang.Fit.fit(text, log)
TokLang.Fit.table(f)
fitted = TokLang.Fit.apply(text, f)
source

Event logs

TokLang.Fit.read_xes — Function
read_xes(source) -> EventLog

Read an XES event log (IEEE 1849-2016): a file path or the XML text. Activity instances are formed from the lifecycle transitions of the events: schedule gives the enqueue time, start the start, complete the end of a completed instance, ati_abort and withdraw the end of an interrupted one. Events are grouped into instances by concept:instance (as tok sim --xes writes it) or, without it, by activity in order. The activity is the activity attribute when present, else concept:name; the trace attributes start and end_event give the arrival and the end event of a case.

source
TokLang.Fit.read_csv_log — Function
read_csv_log(log; cases=nothing) -> EventLog

Read the event log of tok sim --log (columns case, activity, label, resource, enqueue, start, end, status), and optionally the table of cases of --cases-csv (columns case, start, end, end_event, …), which gives the arrival and the end event of every case. Each argument is a file path or the CSV text. Without the table of cases the arrival of a case is the first enqueue time of its instances.

source

Estimates

TokLang.Fit.fit — Function
fit(model, log; level=0.95, families=Dict(), bootstrap=200, seed=1) -> FitResult

Maximum-likelihood calibration of a simulation model on an event log (see docs/calibration.md). model is a Sim.SimModel or the text of a document, log an EventLog. The estimates are the processing time of every activity with observed instances (in the family the model declares, or the one in families), the time between arrivals, and the probabilities p= of the branches of xor and or gateways whose branches can be told apart in the log. Instances interrupted by a boundary event are right-censored observations. Intervals are Wald intervals at level (on the log scale for positive parameters, Wilson intervals for probabilities) and, for the uniform and triangular families, percentile intervals of a parametric bootstrap with bootstrap replications drawn from the stream seed.

source
TokLang.Fit.fit_bayes — Function
fit_bayes(model, log; samples=1000, warmup=500, seed=1, level=0.95, families=Dict())
    -> FitResult

Bayesian calibration with Turing.jl: the same parameters as fit, with weakly informative priors, sampled with NUTS; the estimates are posterior means and the intervals equal-tailed credible intervals. Available after using Turing (the package extension TokLangTuringExt).

source
TokLang.Fit.FitResult — Type
FitResult

The estimates of fit (or of fit_bayes), the level of their intervals and notes on parameters that could not be estimated.

source
TokLang.Fit.Estimate — Type
Estimate

One fitted distribution or probability: element (an activity identifier, "arrival", or a flow "GATEWAY -> TARGET"), parameter (:duration, :arrival or :p), family (:exp, :norm, :lnorm, :unif, :tri, :fixed, or :p for a probability), the parameter names of the language (mean, sd, a, mode, b, x, p) with their values, lower and upper bounds of the interval (seconds for durations), the number of observations n (for a probability, the visits of the gateway), censored (interrupted instances used as censored observations) and method (:mle or :bayes).

source
TokLang.Fit.table — Function
table(f::FitResult) -> Vector{NamedTuple}

The estimates in long form, one row per parameter: (element, parameter, family, name, estimate, lower, upper, n, censored, method).

source
TokLang.Fit.apply — Function
apply(text, f::FitResult; digits=4) -> String

The document text with the estimates of f written into it: duration= of the activities, arrival= of simulate (added when the document has none) and p= of the flows, rounded to digits significant digits. The document is read and printed in canonical form by the core of TokLang.jl; comments are kept.

source