2.5.4 Incrementing Time

An actor tracks discrete time and supports tracking multiple types of continuous time.

In QSMM 1.19, discrete time is normally equal to the number of action choice states registered by the function qsmm_actor_reg_ngram_in. As every call to qsmm_actor_reg_ngram_in precedes a call to the function qsmm_actor_reg_sig_out for registering an emitted output signal, the number of registered action choice states is equal to the number of emitted output signals.

An actor can track continuous time equal to a logical period of time the event history occupies from the beginning. There can be multiple types of continuous time tracked by an actor with various logic behind them. The field ntime of qsmm_actor_desc_s structure passed to the function qsmm_actor_create sets the number of continuous time types of an actor. The function qsmm_get_actor_ntime returns that number for a created actor.

Use the function described below to convey to an actor information about passing a period of continuous time with a specific type. The actor should not receive input signals during this period. If there are input signals to receive, split the period into segments containing no input signals to receive and call the function for each segment in consecutive order. Between the calls, call appropriate API functions to convey input signals to the actor and emit output signals.

Function: int qsmm_actor_time_delta_v2 (qsmm_actor_t actor, int time_type, int rez1, double time_delta)

This function increments by time_delta continuous time with type time_type tracked by an actor. Continuous time types have zero-based indices. The argument rez1 must be 0.

The function returns a non-negative value on success or a negative error code on failure. Currently, the function can return the following error codes.

QSMM_ERR_INVAL

One of the following conditions is true:

  • time_type is negative;
  • time_type is too large;
  • time_delta is non-finite.
QSMM_ERR_INFIN

Incremented continuous time would be infinite.

Use the following function to get the current value of continuous time associated with an actor.

Function: int qsmm_get_actor_time (qsmm_actor_t actor, int time_type, double *time_p)

If time_type is non-negative, this function sets *time_p equal to the current value of continuous time with type time_type tracked by an actor. If time_type is −1, the function returns the current value of discrete time (without fractional part) tracked by the actor. If time_p is NULL, the function does not set *time_p. Otherwise, *time_p is finite.

On success, the function returns a non-negative value. If time_type is less than −1 or too large, the function returns negative error code QSMM_ERR_INVAL.

Use the following functions to get the value of discrete time associated with an actor or set discrete time to an arbitrary value.

Function: long qsmm_get_actor_discrete_time (qsmm_actor_t actor)

This function returns the value of discrete time associated with an actor.

Function: void qsmm_set_actor_discrete_time (qsmm_actor_t actor, long tmd)

This function sets to tmd the value of discrete time associated with an actor.

An actor uses discrete or continuous time to compute spur increment velocity for calculating output signal probabilities. Spur increment velocity is equal to a spur value divided by a time value. As an actor supports multiple spur types and time types, there can be various combinations of a spur type and time type for computing spur increment velocity.

If the field ntime of qsmm_actor_desc_s structure passed to the function qsmm_actor_create was zero, the actor uses discrete time for calculating spur increment velocities. If that field was positive, the actor uses continuous time with type 0 for calculating spur increment velocities by default.

Use the following functions to query or set the type of time for calculating increment velocity of spur with a particular type by an actor.

Function: int qsmm_get_actor_spur_time (qsmm_actor_t actor, int spur_type, int *time_type_p)

If time_type_p is not NULL, this function sets *time_type_p equal to the type of time for calculating increment velocity of spur with type spur_type by an actor. Spur types have zero-based indices. If time_type_p is NULL, the function does not set *time_type_p. If the actor is a large actor, the function retrieves the type of time for a small actor associated with the large actor.

A value returned in *time_type_p can be −1 or non-negative. If *time_type_p is −1, the actor uses discrete time to calculate increment velocity for the spur type. If *time_type_p is non-negative, the actor uses continuous time with type *time_type_p to calculate increment velocity for the spur type.

On success, the function returns a non-negative value. If spur_type is negative or greater than or equal to the number of spur types specified in the field nspur of qsmm_actor_desc_s structure when creating the actor, the function returns negative error code QSMM_ERR_INVAL.

Function: int qsmm_set_actor_spur_time (qsmm_actor_t actor, int spur_type, int time_type)

This function sets to time_type the type of time for calculating increment velocity of spur with type spur_type by an actor. Spur types have zero-based indices. If the actor is a large actor, the function sets the type of time for a small actor associated with the large actor.

If time_type is −1, the actor uses discrete time to calculate increment velocity for the spur type. If time_type is non-negative, the actor uses continuous time with type time_type to calculate increment velocity for the spur type.

On success, the function returns a non-negative value. If spur_type is negative or too large, or time_type is less than −1 or too large, the function returns negative error code QSMM_ERR_INVAL.