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


4.6 Creating the Model Instance

A multinode model can have an instance that represents model parameters specific to a single interaction of a system with an external entity or to a single run of the system against input data. That is, a model represents system structure, and the model instance is a system of that structure created to carry out a particular process of interaction or computation or, in other words, model execution. After finishing the process of model execution, the model instance can be destroyed or recreated to perform a new process of model execution.

Creating the model instance implies creating the environment state identification engine and the instruction emitting engine and also initializing the instruction execution environment. To determine parameters necessary to create the pair of engines, all instruction class sets registered for the model are scanned, and the engines are set up using parameters that comply with every registered instruction class set and every existing node.

New instruction class sets, instruction meta-classes, and instruction classes cannot be registered for a model when its instance exists. New nodes cannot be created if they have identifiers greater than the highest node identifier reserved before making the model instance. The highest node identifier can be reserved explicitly, but is also reserved implicitly when creating a new node with an identifier greater than identifiers of all previously created nodes.

To create the model instance, the following function can be used.

Function: int qsmm_engine_create (qsmm_t model)

This function creates the instance of a multinode model specified by handle model. A model instance corresponds to a particular process of interaction or computation performed using a model of a certain structure. If there exists a model instance already created, then it will be destroyed first.

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

QSMM_ERR_BIGMDL

The multinode model has too many variants of the contents of the look-ahead signal segment or contains too many nodes or an instruction class set with too big maximum number of states or which has too many instruction classes or outcomes of those instruction classes.

QSMM_ERR_NOIC

There was encountered an instruction class set that does not contain instruction classes.

QSMM_ERR_NOMEM

There was not enough memory to create the model instance.

To destroy the model instance, the following function can be used.

Function: void qsmm_engine_destroy (qsmm_t model)

This function destroys the instance of a multinode model specified by handle model. Destruction of the instance implies destruction of the environment state identification engine and the instruction emitting engine and removing all statistics they might have collected. If the model instance does not exist, then the function will have no effect. Destruction of the model instance removes restrictions on changing model structure, which are imposed when creating the instance.

The pair of engines, which correspond to the model instance, is represented by an object called actor pair. An actor pair is referred to by an actor pair handle.

Data type: qsmm_actpair_t

This is a type for an actor pair handle. It is a pointer, so variables of this type can have the NULL value. The handle of an actor pair, which corresponds to a model instance, can be obtained using the function qsmm_get_actpair (see below). The handle will be valid until the model instance is destroyed.

To get the handle of an actor pair associated with the model instance, the following function can be used.

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 specified by handle model. The handle will be valid until the model instance is destroyed. If the model instance does not exist, then the function will return 0.

Handles of actors, which comprise an actor pair and represent the engines, can be obtained using functions described below.

Function: qsmm_actor_t qsmm_get_actpair_actor_env (qsmm_actpair_t actpair)

This function returns the handle of an actor of actor pair actpair that represents the environment state identification engine. 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 of actor pair actpair that represents the instruction emitting engine. This function never returns NULL.

For the certainty and full awareness of model operating conditions by the developer, it is recommended to explicitly set all key parameters of both engines just after creating the model instance. If the handle of multinode model is stored in the variable qsmm, then to assign to the variable actor_env the handle of the environment state identification engine and to assign to the variable actor_opt the handle of the instruction emitting engine, the following lines of code could be used:

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

For each of two engines, the following parameters are to be set.

  1. The type of a function that returns a relative probability of output signal choice. This parameter is set using a call to qsmm_set_actor_relprob_type. If necessary, a helper function must be provided using a call to qsmm_set_actor_relprob_helper.
  2. A spur type that corresponds to the automatic spur. This parameter is set using the function qsmm_set_actor_auto_spur_type. By default, the environment state identification engine uses automatic spur of type 0, and this can be turned off. Spur of type 0 then can be reused for another purpose.
  3. Ways of perception for all supported spur types. The way of spur perception is set using the function qsmm_set_actor_spur_perception. By default, mode QSMM_SPUR_PERCEPTION_NORMAL is used for all spur types.
  4. Weights for all supported spur types. The weights are set using the function qsmm_set_actor_spur_weight.
  5. The temperature of an engine. This parameter is set using the function qsmm_set_actor_ktemperature.

For a small actor, types of time for all supported spur types are to be set using calls to qsmm_set_actor_spur_time.

If an engine is represented by a large actor, say, referred to by handle actor, then the handle of a small actor associated with the large actor can be obtained by expression

qsmm_get_actpair_actor_env(
    qsmm_get_actpair(qsmm_get_actor_large_model(actor)))

The following parameters are to be additionally set for that small actor.

  1. A spur type that corresponds to the automatic spur. This parameter is set by a call to qsmm_set_actor_auto_spur_type for an actor, which handle was obtained using the above expression. By default, that actor uses automatic spur of type 0, and this mode can be turned off. Spur of type 0 of the small actor then can be reused for another purpose. To spur of type 0 of the small actor there corresponds spur of type -1 of the large actor.
  2. The way of perception for spur of type 0. This parameter is set by a call to qsmm_set_actor_spur_perception either for an actor, which handle was obtained using the above expression, passing 0 for spur type, or for the large actor, passing -1 for spur type. By default, mode QSMM_SPUR_PERCEPTION_NORMAL is used.
  3. Weight for spur type 0. This parameter is set by a call to qsmm_set_actor_spur_weight either for an actor, which handle was obtained using the above expression, passing 0 for spur type, or for the large actor, passing -1 for spur type.

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