Skip to content

Entities

entity

Entities: the things that flow through a simulated system.

Entity

Entity(entity_type: str = 'entity', attributes: dict[str, Any] | None = None, *, id: str | None = None, created_at: float = 0.0, state: str = 'created')

A customer, job, patient, aircraft, packet ... anything with identity and state.

Create entities with :meth:Simulation.entity so that ids are assigned per simulation ("customer-1", "customer-2", ...) and therefore reproducible. Entities built directly get a process-wide id unless one is given, and are attached when passed to :meth:Simulation.add_entity.

set_state

set_state(new_state: str, *, time: float | None = None, **metadata: Any) -> None

Transition to new_state, recording history and the event log.

time_in_states

time_in_states(until: float | None = None) -> dict[str, float]

Total time spent in each state according to the recorded history.