Next: , Up: Statistics Storage   [Contents][Index]


3.1 Types of Storage

There are two types of statistics storage supported: flat and map. The type of statistics storage of an actor has to be specified using the field use_flat_storage of structure qsmm_actor_desc_s when creating the actor by the function qsmm_actor_create.

Flat storage

Flat storage uses preallocated arrays and does not perform memory allocation when statistics is written to storage. Therefore, flat storage operates quickly but may require a huge amount of working memory. To reduce the amount of memory occupied by the flat storage of an actor, specify allowed ranges of signal identifiers in action choice state n-grams using the field range_sig_p of structure qsmm_actor_desc_s as precisely as possible when creating the actor by the function qsmm_actor_create.

Map storage

Map storage uses binary trees to hold statistics and dynamically allocates the working memory in case of need. When map storage does not hold probability profiles, it contains information on action choice states and cycle types that did occur at least one time in the event history. In this case, at the beginning of actor operation the storage occupies a small amount of memory, which gradually increases as more action choice states and cycle types occur the first time in the event history.

Map storage has two shortcomings. The first is that map storage operates slower than flat storage. The second is that when map storage holds statistics for all possible action choice states and cycle types, it occupies much more memory than the flat storage requires. The second shortcoming is not a hindrance, because not all possible action choice states and cycle types usually occur in the event history, and because the actor usually operates shorter time than it is required for a large number of action choice states and cycle types to occur the first time in the event history.

Storage handle

Storage of flat or map type is referred to by a storage handle.

Data type: qsmm_storage_t

This is a type for a storage handle. It is a pointer, so variables of this type can have the NULL value. A storage handle can be obtained for an actor by the function qsmm_get_actor_storage and passed to API functions that take an argument of type qsmm_storage_t until the actor is destroyed.

The number of spur types supported by storage represented by a storage handle can be obtained using the following function.

Function: int qsmm_get_storage_nspur (qsmm_storage_t storage)

This function returns the number of spur types supported by storage. The storage can hold statistics for that number of spur types. The returned value is always non-negative.


Next: , Up: Statistics Storage   [Contents][Index]