Time Manager

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.manager.SimulationClock[source]

A time manager that includes a global clock and simulant-specific clocks.

property name: str
property time: Timestamp | datetime | int

The current simulation time.

property stop_time: Timestamp | datetime | int

The time at which the simulation will stop.

property minimum_step_size: Timedelta | timedelta | int

The minimum step size.

property standard_step_size: Timedelta | timedelta | int

The standard varied step size.

property step_size: Timedelta | timedelta | int

The size of the next time step.

property event_time: Timestamp | datetime | int

Convenience method for event time, or clock + step

property time_steps_remaining: int
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.

Return type:

None

Parameters:

builder (Builder) – The builder object used to set up the manager.

on_post_setup(event)[source]
Return type:

None

Parameters:

event (Event)

initialize_individual_clock(pop_data)[source]

Sets the next_event_time and step_size columns for each simulant

Return type:

None

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_backward()[source]

Rewinds the clock by the current step size.

Return type:

None

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

get_active_simulants(index, time)[source]

Gets population that is aligned with global clock

Parameters:
  • index (pd.Index[int])

  • time (ClockTime)

Return type:

pd.Index[int]

move_simulants_to_end(index)[source]
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:

Any

Parameters:
  • index – The index of the population for which the attribute is being produced (not used by this post processor but is required to be used by AttributePipelines).

  • value (Any) – A list of step sizes

  • manager (ValuesManager) – The ValuesManager for this simulation (not used by this post processor but is required to be used by AttributePipelines).

Returns:

The largest feasible step size for each simulant (not used by this post processor but is required to be used by AttributePipelines).

class vivarium.framework.time.manager.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.

property name: str
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.

Return type:

None

Parameters:

builder (Builder) – The builder object used to set up the manager.

vivarium.framework.time.manager.get_time_stamp(time)[source]
Return type:

Timestamp

Parameters:

time (dict[str, int])

class vivarium.framework.time.manager.DateTimeClock[source]

A time manager that uses 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.

property name: str
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.

Return type:

None

Parameters:

builder (Builder) – The builder object used to set up the manager.