Schedulers maintain Clock objects to track time. The current time in relation to a Scheduler is stored in Scheduler.clock.time or Scheduler.clock.simple_time

class psyneulink.scheduling.time.TimeScale

Represents divisions of time used by the Scheduler, Conditions, and the time_scale argument of a Composition’s run method.

The values of TimeScale are defined as follows (in order of increasingly coarse granularity):


the nuclear unit of time, corresponding to the execution of all Mechanisms allowed to execute from a single consideration_set of a Scheduler, and which are considered to have executed simultaneously.


a full iteration through all of the consideration_sets in a Scheduler's consideration_queue, consisting of one or more TIME_STEPs, over which every Component specified to a Scheduler is considered for execution at least once.


an open-ended unit of time consisting of all action that occurs within the scope of a single input to a Composition.


the scope of a call to the run method of a Composition, consisting of one or more TRIALs.


the scope of time since the creation of an object.

classmethod get_parent(time_scale)
Returns:the TimeScale one level wider in scope than time_scale
Return type:TimeScale
classmethod get_child(time_scale)
Returns:the TimeScale one level smaller in scope than time_scale
Return type:TimeScale
class psyneulink.scheduling.time.Clock

Stores a history of TimeScales that have occurred, and keep track of a current Time. Used in relation to a Scheduler


TimeHistoryTree – a root TimeHistoryTree associated with this Clock

get_total_times_relative(query_time_scale, base_time_scale, base_index=None)

Convenience simplified wrapper for TimeHistoryTree.get_total_times_relative

  • query_time_scale (TimeScale) – the unit of time whose number of ticks to be returned
  • base_time_scale (TimeScale) – the unit of time over which the number of query_time_scale ticks should be returned
  • base_index (int) – the base_indexth base_time_scale over which the number of query_time_scale ticks should be returned

the number of query_time_scale s that have occurred during the scope of the base_index th base_time_scale

Return type:


Parameters:time_scale (TimeScale) –
Returns:the current value of the time unit corresponding to time_scale for this Clock
Return type:int

the current timeTime


the current time in simple formatSimpleTime

class psyneulink.scheduling.time.Time(time_step=0, pass_=0, trial=0, run=0, life=0)

Represents an instance of time, having values for each TimeScale


int : 0 – the TimeScale.LIFE value


int : 0 – the TimeScale.RUN value


int : 0 – the TimeScale.TRIAL value


int : 0 – the TimeScale.PASS value


int : 0 – the TimeScale.TIME_STEP value

class psyneulink.scheduling.time.SimpleTime(run=0, trial=0, time_step=0)

A subset class of Time, used to provide simple access to only run, trial, and time_step

class psyneulink.scheduling.time.TimeHistoryTree(time_scale=<TimeScale.LIFE: 4>, max_depth=<TimeScale.TRIAL: 2>, index=0, parent=None, enable_current_time=True)

A tree object that stores a history of time that has occurred at various TimeScales, typically used in conjunction with a Clock


TimeScale : TimeScale.LIFE – the TimeScale unit this tree/node represents


TimeScale : TimeScale.RUN – the TimeScale unit for this tree’s children


list[TimeHistoryTree] – an ordered list of this tree’s children


TimeScale : TimeScale.TRIAL – the finest grain TimeScale that should be created as a subtree Setting this value lower allows for more precise measurements (by default, you cannot query the number of TimeScale.TIME_STEPs in a certain TimeScale.PASS), but this may use a large amount of memory in large simulations


int – the index this tree has in its parent’s children list


TimeHistoryTree : None – the parent node of this tree, if it exists. None represents no parent (i.e. root node)


Time – a Time object that represents the current time in the tree


dict{TimeScale: int} – stores the total number of units of TimeScales that have occurred over this tree’s scope. Only contains entries for TimeScales of finer grain than time_scale

Parameters:enable_current_time (bool : True) – sets this tree to maintain a Time object. If this tree is not a root (i.e. time_scale is TimeScale.LIFE)

Increases this tree’s current_time by one time_scale

Parameters:time_scale (TimeScale) – the unit of time to increment
get_total_times_relative(query_time_scale, base_indices=None)
  • query_time_scale (TimeScale) – the TimeScale of units to be returned
  • base_indices (dict{TimeScale: int}) –

    a dictionary specifying what scope of time query_time_scale is over. e.g.

    base_indices = {TimeScale.RUN: 1, TimeScale.TRIAL: 5}

    gives the number of query_time_scales that have occurred in the 5th TRIAL of the 1st RUN. If an entry for a TimeScale is not specified but is coarser than query_time_scale, the latest value for that entry will be used


the number of units of query_time_scale that have occurred within the scope of time specified by base_indices

Return type: