The Simulation Clock
The components here provide implementations of different kinds of simulation
clocks for use in vivarium
.
For more information about time in the simulation, see the associated concept note.
- class vivarium.framework.time.SimulationClock[source]
A base clock that includes global clock and a pandas series of clocks for each simulant
- setup(builder)[source]
Defines custom actions this manager needs to run during the setup lifecycle phase.
This method is intended to be overridden by subclasses to perform any necessary setup operations specific to the manager. By default, it does nothing.
- on_initialize_simulants(pop_data)[source]
Sets the next_event_time and step_size columns for each simulant
- Return type:
- Parameters:
pop_data (SimulantData)
- simulant_next_event_times(index)[source]
The next time each simulant will be updated.
- Parameters:
index (pd.Index[int])
- Return type:
pd.Series[ClockTime]
- simulant_step_sizes(index)[source]
The step size for each simulant.
- Parameters:
index (pd.Index[int])
- Return type:
pd.Series[ClockStepSize]
- step_forward(index)[source]
Advances the clock by the current step size, and updates aligned simulant clocks.
- Parameters:
index (pd.Index[int])
- Return type:
None
- step_size_post_processor(value, manager)[source]
Computes the largest feasible step size for each simulant.
This is the smallest component-modified step size (rounded down to increments of the minimum step size), or the global step size, whichever is larger. If no components modify the step size, we default to the global step size.
- Return type:
- Parameters:
values – A list of step sizes
value (Any)
manager (ValuesManager)
- Returns:
The largest feasible step size for each simulant
- class vivarium.framework.time.SimpleClock[source]
A unitless step-count based simulation clock.
-
CONFIGURATION_DEFAULTS:
dict
[str
,Any
] = {'time': {'end': 100, 'standard_step_size': None, 'start': 0, 'step_size': 1}} A dictionary containing the defaults for any configurations managed by this manager. An empty dictionary indicates no managed configurations.
-
CONFIGURATION_DEFAULTS:
- class vivarium.framework.time.DateTimeClock[source]
A date-time based simulation clock.
-
CONFIGURATION_DEFAULTS:
dict
[str
,Any
] = {'time': {'end': {'day': 2, 'month': 7, 'year': 2010}, 'standard_step_size': None, 'start': {'day': 2, 'month': 7, 'year': 2005}, 'step_size': 1}} A dictionary containing the defaults for any configurations managed by this manager. An empty dictionary indicates no managed configurations.
-
CONFIGURATION_DEFAULTS:
- class vivarium.framework.time.TimeInterface(manager)[source]
- Parameters:
manager (SimulationClock)
- simulant_next_event_times()[source]
Gets a callable that returns the next event times for simulants.
- Return type:
Callable[[pd.Index[int]], pd.Series[ClockTime]]
- simulant_step_sizes()[source]
Gets a callable that returns the simulant step sizes.
- Return type:
Callable[[pd.Index[int]], pd.Series[ClockStepSize]]
- move_simulants_to_end()[source]
Gets a callable that moves simulants to the end of the simulation
- Return type:
Callable[[pd.Index[int]], None]
- register_step_size_modifier(modifier, requires_columns=[], requires_values=[], requires_streams=[])[source]
Registers a step size modifier.
- Parameters:
modifier (Callable[[pd.Index[int]], pd.Series[ClockStepSize]]) – Modifier of the step size pipeline. Modifiers can take an index and should return a series of step sizes.
requires_columns (list[str]) – A list of the state table columns that already need to be present and populated in the state table before the modifier is called.
requires_values (list[str]) – A list of the value pipelines that need to be properly sourced before the modifier is called.
requires_streams (list[str]) – A list of the randomness streams that need to be properly sourced before the modifier is called.
- Return type:
None