Validation and introspection¶
validate ¶
Model validation: catch configuration and modelling mistakes early.
:func:validate_model combines static checks with a short smoke run:
======================== =========================================================== code meaning ======================== =========================================================== parameter missing/unknown/out-of-range/invalid-type parameter values build-error the build function raised run-error the simulation raised (invalid event time, model bug, ...) zero-capacity a resource has capacity 0 at start no-events nothing was scheduled: the model does nothing resource-not-released a process finished while still holding a resource unit possible-deadlock processes blocked with no pending events at the end unreached-state a declared entity state never occurred in the smoke run undeclared-state an entity entered a state not in the declared list no-duration the model has no duration, so runs may never terminate ======================== ===========================================================
The smoke run is evidence, not proof: a state not reached in a short run might be reachable in a longer one, and deadlocks that need rare event orderings may not show up.
validate_model ¶
validate_model(model: Model, params: Mapping[str, Any] | None = None, *, seed: int = 0, smoke_duration: float | None = None, expected_states: Mapping[str, Iterable[str]] | None = None) -> ValidationReport
Check model with params. smoke_duration defaults to 10% of the model duration.
graph ¶
Model introspection as a graph.
Two complementary views, both observed from a run (SimulSI models are ordinary Python, so the flow cannot be read off the source reliably):
- flow graph - where entities go:
arrival:<type> -> queue/resource -> ... -> exit:<type>, with transition counts. Built from the event log, so run withtrace=Trueand associate entities with requests (passentity=tosim.processorsim.request). - state graph - the state machine of each entity type, from entity
histories (
old_state -> new_statecounts).
Plus the static inventory: resources, queues, entity types, process names.
inventory ¶
inventory(sim: Simulation) -> dict[str, Any]
Static view of the components a simulation has registered.
flow_graph ¶
flow_graph(records: Iterable[LogRecord]) -> ModelGraph
Entity flow between arrival, queues, resources and exit, from an event log.
state_graph ¶
state_graph(sim: Simulation, entity_type: str | None = None) -> ModelGraph
State-transition counts from the histories of (still registered or disposed) entities.
Only entities still reachable are included; for complete coverage run with
trace=True and use :func:state_graph_from_log.
model_graph ¶
model_graph(model: Model, params: dict[str, Any] | None = None, *, seed: int = 0, duration: float | None = None, max_log_records: int = 200000) -> dict[str, Any]
Run model briefly with tracing and return inventory, flow and state graphs.