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.
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.
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.
There was encountered an instruction class set that does not contain instruction classes.
There was not enough memory to create the model instance.
To destroy the model instance, the following function can be used.
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.
This is a type for an actor pair handle.
It is a pointer, so variables of this type can have the
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.
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.
This function returns the handle of an actor of actor pair actpair that represents the environment state identification engine.
This function never returns
This function returns the handle of an actor of actor pair actpair that represents the instruction emitting engine.
This function never returns
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.
qsmm_set_actor_relprob_type. If necessary, a helper function must be provided using a call to
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.
qsmm_set_actor_spur_perception. By default, mode
QSMM_SPUR_PERCEPTION_NORMALis used for all spur types.
For a small actor, types of time for all supported spur types are to be set using calls to
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
The following parameters are to be additionally set for that small actor.
qsmm_set_actor_auto_spur_typefor 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.
qsmm_set_actor_spur_perceptioneither 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_set_actor_spur_weighteither 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.