Look-ahead signals are signals that along with the previous node state, an instruction class index, and an instruction outcome take part in selecting the next node state after an instruction invocation. The adjective “look-ahead” indicates that in some situations the signals can convey look-ahead information. For example, when processing a sequence of symbols from left to right, a multinode model can analyze look-ahead symbols as look-ahead signals. In other situations, the signals can pass even look-back information to the model.
When creating a multinode model by the function qsmm_create, the fields ngram_env_la_sz, nsig_ngram_env_la, and range_sig_env_la_p of qsmm_desc_s structure specify look-ahead signal segment length and ranges of signals assignable to segment elements.
You can retrieve the mentioned parameters later by the functions qsmm_get_ngram_env_la_sz and qsmm_get_nsig_ngram_env_la called for the multinode model and by the function qsmm_get_actor_range_sig called for the environment state identification engine.
An important limitation imposed on a multinode model when its look-ahead signal segment has positive length is that the function qsmm_node_asm cannot load assembler programs into the nodes of the model.
The limitation also prevents loading default uniform probability profiles into the nodes using implicitly generated assembler programs when the maximum number of nodes in the model specified by the field nnode_max of qsmm_desc_s is greater than 1 and the environment state identification engine or instruction emitting engine is a large actor—in this case, the model is unusable.
Therefore, if you need to use a look-ahead signal segment with positive length for a model with the environment state identification engine or instruction emitting engine represented by a large actor, set the maximum number of nodes in the model to 1 when creating it.
Use functions described below to query or set signals in the look-ahead signal segment at specific positions.
You can call the functions at any point after creating a multinode model.
For example, you can call them while processing an event QSMM_EVT_NODE_ENTER by the event handler of an instruction class set or an event QSMM_EVT_ACTIVATE by the event handler of an instruction meta-class.
If a model instance exists, the functions access look-ahead signals in a buffer holding an array of signals encoding current action choice state of environment state identification engine.
The buffer is accessible by the function qsmm_get_actor_sig_ngram.
If a model instance does not exist, the functions access another buffer initialized on creating a multinode model.
On creating a model instance, the function qsmm_engine_create copies the latter buffer to the former one.
On destroying a model instance, the function qsmm_engine_destroy copies the former buffer to the latter one.
int qsmm_get_la_sig (qsmm_t model, int pos, qsmm_sig_t *sigp) ¶If sigp is not NULL, this function sets *sigp to an element of look-ahead signal segment of a multinode model at position pos.
On success, the function returns a non-negative value.
If pos is negative or greater than or equal to the length of look-ahead signal segment, the function returns negative error code QSMM_ERR_INVAL.
int qsmm_set_la_sig (qsmm_t model, int pos, qsmm_sig_t sig) ¶This function sets an element of look-ahead signal segment of a multinode model at position pos to sig.
On success, the function returns a non-negative value.
If pos is negative or greater than or equal to the length of look-ahead signal segment, or sig does not fall into a range of allowed signal identifiers at position pos in the look-ahead signal segment, the function returns negative error code QSMM_ERR_INVAL.
If the field range_sig_env_la_p of qsmm_desc_s structure is NULL, the function qsmm_create initializes the elements of look-ahead signal segment to 0.
If that field is not NULL, qsmm_create initializes the elements of look-ahead signal segment to the values of first field in the corresponding elements of range_sig_env_la_p array.
See the file tests/lookup2.c for an example program that uses the look-ahead signal segment.