Next: , Previous: , Up: Creating a Multinode Model   [Contents][Index]


4.2.6 Creating the Model Instance

A multinode model can have an instance holding the parameters of this model specific to its single run against input data or its single course of interaction with external entities. That is, a model represents the structure of a system, and the model instance is this system created to carry out a particular process of interaction or computation—a process of model execution. After finishing the process of model execution, a program can accumulate learned model parameters and recreate the model instance for a new process of model execution. Multiple model runs would provide the average values of learned model parameters.

Creating the model instance includes creating the environment state identification engine and instruction emitting engine. The function qsmm_engine_create creates both engines with parameters complying with every registered instruction class set and every created node. The function qsmm_destroy implicitly destroys the model instance if it exists.

When the model instance exists, nodes have extended parameters listed in Node Parameters. A node takes the initial values of those extended parameters on creating the model instance after creating the node and on creating the node after creating the model instance. All nodes lose their extended parameters on destroying the model instance.

When the model instance exists, attempts to register instruction meta-classes, instruction classes, and instruction class sets and create nodes with identifiers greater than the highest reserved node identifier result in reporting QSMM_ERR_UNTIMELY. You can reserve the highest node identifier before creating the model instance—explicitly by the function qsmm_node_reserve or implicitly by creating a node with that identifier by the function qsmm_node_create_v2 or macro QSMM_NODE_CREATE.

Use the following function to create the model instance.

Function: int qsmm_engine_create (qsmm_t model)

This function creates the instance of a multinode model. A model instance holds parameters specific to a particular process of interaction or computation performed using a model with certain structure. If the model instance already exists, the function first destroys it.

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

QSMM_ERR_BIGMDL

The multinode model has too many variants of content of look-ahead signal segment or contains too many nodes or an instruction class set with a too large maximum allowed number of states or an instruction class set with too many instruction classes or outcomes of those instruction classes.

QSMM_ERR_NOIC

The multinode model contains an instruction class set without instruction classes.

QSMM_ERR_NOMEM

There was not enough memory to create the model instance.

Use the following function to destroy the model instance.

Function: void qsmm_engine_destroy (qsmm_t model)

This function destroys the instance of a multinode model. Destroying that instance includes destroying the environment state identification engine and instruction emitting engine and removing all statistics they might have collected. If the model instance does not exist, the function has no effect. The destruction of model instance removes restrictions on changing model structure imposed when creating the instance.

In the current implementation, an object called actor pair referred to by an actor pair handle is a container of the environment state identification engine and instruction emitting engine in the scope of model instance.

Data type: qsmm_actpair_t

This is a type for an actor pair handle. It is a pointer, so variables of this type can be NULL. The function qsmm_get_actpair returns the handle of an actor pair corresponding to the model instance. That handle is valid until destroying the model instance.

Use the following function to get an actor pair associated with the model instance.

Function: qsmm_actpair_t qsmm_get_actpair (qsmm_t model)

This function returns the handle of an actor pair associated with the instance of a multinode model. That handle is valid until destroying the model instance. If the model instance does not exist, the function returns NULL.

Use the functions described below to get the actors comprising an actor pair and representing the environment state identification engine and instruction emitting engine.

Function: qsmm_actor_t qsmm_get_actpair_actor_env (qsmm_actpair_t actpair)

This function returns the handle of an actor representing the environment state identification engine in an actor pair actpair. This function never returns NULL.

Function: qsmm_actor_t qsmm_get_actpair_actor_opt (qsmm_actpair_t actpair)

This function returns the handle of an actor representing the instruction emitting engine in an actor pair actpair. This function never returns NULL.

To be confident that all key parameters of the environment state identification engine and instruction emitting engine have expected values, explicitly set those parameters after creating the model instance. If the variable qsmm holds the handle of a multinode model, use the following lines of code to assign to the variable actor_env the handle of the environment state identification engine and assign to the variable actor_iee the handle of the instruction emitting engine:

const qsmm_actpair_t actpair=qsmm_get_actpair(qsmm);
const qsmm_actor_t actor_env=qsmm_get_actpair_actor_env(actpair),
    actor_iee=qsmm_get_actpair_actor_opt(actpair);

Some parameters are applicable to a small actor associated with a large actor representing the environment state identification engine. Use the following lines of code to assign the handle of this small actor to the variable actor_env_env:

const qsmm_actor_t actor_env_env=
    qsmm_get_actpair_actor_env(
        qsmm_get_actpair(qsmm_get_actor_large_model(actor_env)));

Some parameters are applicable to a small actor associated with a large actor representing the instruction emitting engine. Use the following lines of code to assign the handle of this small actor to the variable actor_iee_env:

const qsmm_actor_t actor_iee_env=
    qsmm_get_actpair_actor_env(
        qsmm_get_actpair(qsmm_get_actor_large_model(actor_iee)));

Consult with Example of Using the Storage API, for a list of parameters you can set for an actor. The table below summarizes parameters you can set for the aforementioned variables actor_env, actor_iee, actor_env_env, and actor_iee_env—an existing environment state identification engine and instruction emitting engine and their associated small actors if they exist. The table indicates initial parameter values for those actors. Consider explicit setting the initial value of a parameter if a corresponding cell contains “varies”.

Parameter and API function for setting itactor_envactor_ieeactor_
env_env
actor_
iee_env
The mode of behavior: adaptive or random
qsmm_set_actor_random
adaptiveadaptive
The index of a spur type for the automatic spur
qsmm_set_actor_auto_spur_type
0-1varies-1
Discrete time
qsmm_set_actor_discrete_time
0000
Continuous time
qsmm_actor_time_delta
0000
Temperature
qsmm_set_actor_ktemperature
11
Spur values
qsmm_actor_spur_delta
00
Spur weights
qsmm_set_actor_spur_weight
varies1
The way of spur perception: normal or inverse
qsmm_set_actor_spur_perception
normalnormal
The type of time for computing spur increment velocity: discrete or continuous
qsmm_set_actor_spur_time – small actor only
variescontinuousvariescontinuous
The type of a function returning the relative probability of an output signal and, for certain those types, a helper function for computing the relative probability of an output signal
qsmm_set_actor_relprob_type and
qsmm_set_actor_relprob_helper
variesvaries
A function for intercepting the updates of cycle type statistics
qsmm_set_storage_cycle_update_hook for a handle obtained by qsmm_get_actor_storage
NULLNULLNULLNULL

Next: , Previous: , Up: Creating a Multinode Model   [Contents][Index]