// // TimeIndexing -- messages shared by Schedule and Swarm // @deftype TimeIndexing CREATING - (void) setRelativeTime: (BOOL)relative; - (void) setConcurrentGroupType: groupType; - (void) setSingletonGroups: (BOOL)singletonGroups; SETTING - (void) setRepeatInterval: (timeval_t)tVal; USING - (BOOL) getRelativeTime; - (timeval_t) getRepeatInterval; - getConcurrentGroupType; - (BOOL) getSingletonGroups; @end
(.. This option is currently supported only on schedules, not swarms.)
(.. This option is currently supported only on schedule, not swarms.)
If a different interpretation of actions at the same time step is needed, the ConcurrentGroupType option may be specified. The argument of this option must be an object that when given a standard create: message will return an object having all the structure of a standard ActionGroup object. For example, if you want to specify that actions at the same time step are to be processed in random order, you could use the following procedure:
concurrentGroupType = [ActionGroup customizeBegin: aZone]; [concurrentGroupType setDefaultOrder: Random]; concurrentGroupType = [concurrentGroupType customizeEnd]; aSchedule = [Schedule createBegin: aZone]; [aSchedule setConcurrentGroupType: concurrentGroupType]; aSchedule = [aSchedule createEnd];Note that instead of using the normal createBegin/End sequence to create an instance, the concurrentGroupType is initialized using the customizeBegin/End sequence to customize a type without creating an instance. For more information, see the defobj library documentation.
In addition to overriding the standard ActionGroup type, the concurrent group type may be implemented by a custom subclass of the ActionGroup implementation which you supply yourself. A custom subclass is free to implement custom rules for how to combine all the actions which happen to arrive at the same time value. For example, it could decide that some actions are not to be executed at all, or it could create entirely new actions to be executed instead of or in addition to those which were originally scheduled. (.. Specific rules for writing a custom ActionGroup subclass will be documented at a future time, but all the apparatus to do so is present today. A concurrent action group is currently used to maintain the proper order of execution among subswarms of an owner swarm.)
Ordinarily, a concurrent action group is created to process actions at the same timestep only if more than one action is scheduled at that timestep. The overhead of these action groups is relatively low, because it just creates a single new object to which actions are directly linked, but it is still faster to avoid creating them if only one action is present at a timestep. If a custom subclass is being provided however, it may need to examine the actions at a timestep even if there is only one.
typedef unsigned timeval_t; // type for time valuesValues of this type are used as keys when inserting actions into a schedule at a particular time, or for querying the current time value of a swarm or schedule during its execution. (The shorter name time_t has already been taken by one the standard C libraries.)
For very long running models using finely divided units of time, it is quite possible that a 32-bit unsigned time value could overflow. Special messages are provided in the execution machinery to reset all times to a different base value if a danger of overflow exists. If this machinery is exercised, all times of all referenced action plans are reset to a different base value in unison, which makes the shift as transparent as possible. Separate support is also available to declare time values that are subunits of the discrete clock values in a containing schedule or swarm. (.. Currently, all this extended time unit support is unsupported, though there is an example of scheduling at subunit times in a GridTurtle test program.)