| tok_sim | R Documentation |
Runs the discrete-event simulation of tok sim: cases arrive, wait for the resources
of by=, take the durations of duration= and choose flows by their conditions and
probabilities, as the simulate, resource and variable statements of the model
say. The same model and seed always give the same result, number by number the result
of tok sim and of the Python package.
tok_sim(x, cases = NULL, seed = NULL, lang = getOption("tok.lang", "en"))
x |
A model: a |
cases |
Number of cases; |
seed |
Seed of the random number generator; |
lang |
Language of the messages, |
Times of the simulation are calendar times counted from start= of simulate. In the
event log and the table of cases they are POSIXct values in UTC; a start= without a
UTC offset is taken as UTC, so the clock times are those of tok sim --log.
The event log has one row per activity instance, as tok sim --log writes it: the
columns case, activity (identifier), label, resource ("" when the activity has
no by=), enqueue (when the case reached the activity), start (when a performer
started the work; NA when the activity was interrupted while waiting), end (when it
completed or was interrupted) and status ("completed" or "interrupted"). The
columns case_id, activity_id (the label, or the identifier when the activity has no
label), activity_instance_id (the row number), resource_id (NA when none),
schedule (= enqueue) and complete (= end of completed instances, NA for
interrupted ones) repeat them under the names process-mining packages expect. For
example, with bupaR:
bupaR::activitylog(s$log, case_id = "case_id", activity_id = "activity_id",
resource_id = "resource_id",
timestamps = c("schedule", "start", "complete"))
An object of class tok_sim, a list with the elements:
kpi: the indicators of tok sim --json, a list with seed; cases (a list of
started, finished and by_end_event, a named integer vector of finished cases
per end event); cycle_time (a list of mean_s, median_s and p90_s in seconds,
NA without finished cases, and the same as short texts mean, median, p90);
activities, a data frame with one row per activity (activity, label, count
of completed instances, mean_wait_s, mean_processing_s, mean_wait,
mean_processing); resources, a data frame with one row per resource
(resource, label, count, utilization as a fraction); horizon_s, the
simulated period in seconds; and warnings.
log: the event log, a data frame described above.
cases: a data frame with one row per case: case, start, end (NA for an
unfinished case), end_event (NA for an unfinished case), cycle_time_s, and
one column per case variable. A variable that holds a single value in every case
is a vector (logical, numeric or character, NA where the case has no value;
durations in seconds), any other a list; a variable named like one of the first
five columns gets the prefix variable_.
warnings: conditions or expressions the simulator could not evaluate.
seed: the seed used, as a number.
horizon: the simulated period in seconds, from the first arrival to the last
event.
report: the text report of tok sim in the language lang, which print()
shows.
The object also keeps the model, the number of cases and the seed of the run, so
tok_xes() can write its event log as XES.
as.data.frame() returns the event log. The function stops with the errors of the
model (see tok_check()) and with the errors of the simulator as tok sim reports
them, for example tok.sim.SimError: the process 'process' has no start event.
f <- system.file("examples", "kwerenda-symulacja.tok", package = "tokr")
s <- tok_sim(f)
s
s$kpi$resources
head(s$log)
table(tok_sim(f, cases = 50, seed = 3)$cases$end_event)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.