State Machine¶
A state machine implementation for use in vivarium
simulations.
- class vivarium.framework.state_machine.Trigger(value)[source]¶
An enumeration.
- NOT_TRIGGERED = 0¶
- START_INACTIVE = 1¶
- START_ACTIVE = 2¶
- class vivarium.framework.state_machine.Transition(input_state, output_state, probability_func=<function Transition.<lambda>>, triggered=Trigger.NOT_TRIGGERED)[source]¶
A process by which an entity might change into a particular state.
- Parameters:
- class vivarium.framework.state_machine.State(state_id)[source]¶
An abstract representation of a particular position in a state space.
- Parameters:
state_id (str) –
- state_id¶
The name of this state. This should be unique
- transition_set¶
A container for potential transitions out of this state.
- next_state(index, event_time, population_view)[source]¶
Moves a population between different states.
- Parameters:
index (Index) – An iterable of integer labels for the simulants.
event_time (Time) – When this transition is occurring.
population_view (PopulationView) – A view of the internal state of the simulation.
- Return type:
None
- transition_effect(index, event_time, population_view)[source]¶
Updates the simulation state and triggers any side-effects associated with entering this state.
- Parameters:
index (Index) – An iterable of integer labels for the simulants.
event_time (Time) – The time at which this transition occurs.
population_view (PopulationView) – A view of the internal state of the simulation.
- Return type:
None
- cleanup_effect(index, event_time)[source]¶
- Parameters:
index (Index) –
event_time (Time) –
- Return type:
None
- class vivarium.framework.state_machine.Transient[source]¶
Used to tell _next_state to transition a second time.
- class vivarium.framework.state_machine.TransientState(state_id)[source]¶
- Parameters:
state_id (str) –
- class vivarium.framework.state_machine.TransitionSet(state_name, *transitions, allow_null_transition=False)[source]¶
A container for state machine transitions.
- Parameters:
state_name (str) – The unique name of the state that instantiated this TransitionSet. Typically a string but any object implementing __str__ will do.
iterable – Any iterable whose elements are Transition objects.
allow_null_transition (bool) –
transitions (Transition) –
- setup(builder)[source]¶
Performs this component’s simulation setup and return sub-components.
- Parameters:
builder (Builder) – Interface to several simulation tools including access to common random number generation, in particular.
- Return type:
None
- append(transition)[source]¶
- Parameters:
transition (Transition) –
- Return type:
None
- extend(transitions)[source]¶
- Parameters:
transitions (Iterable[Transition]) –
- Return type:
None
- class vivarium.framework.state_machine.Machine(state_column, states=())[source]¶
A collection of states and transitions between those states.
- states¶
The collection of states represented by this state machine.
- state_column¶
A label for the piece of simulation state governed by this state machine.
- population_view¶
A view of the internal state of the simulation.
- property sub_components¶