| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (4 out of 11)

Understanding the Knowledge Contained in Items

Each item represents a set of knowledge whose template is based on its class. An item's set of attributes represents such a template. However, each item also contains other information that G2 maintains, such as its status and relationships with other items and objects.

Identifying the Knowledge in Attributes

The class of an item determines its set of attributes. An item's attributes contain knowledge in a form that is easy to work with. Attributes are described in detail in Chapter 11, Attributes and Tables.

Identifying the Knowledge Not Stored in Attributes

Items of some classes can contain one or more values that are distinct from the items' attributes. For instance, a variable or parameter can contain a value, and can be defined to also contain history datapoint values. Also, lists and arrays can contain values and references to other items in their elements. See the appropriate chapter in this document for more information about the knowledge that these items can contain.

Further, items also include a set of hidden attributes, which are those that do not appear in an attribute table and include:

For more information about hidden attributes, see Chapter 12, Attribute Access Facility. Obtaining the relationships in which an item is participating is described in Referring to The Relationships of an Item.

Identifying the Status Knowledge of Items

Items also contain several kinds of status knowledge:

G2 automatically maintains each item's status knowledge.

Permanent/Transient Status

At a given moment, each item in the current KB is either permanent or transient. The permanent/transient status of items is user-settable, but only programmatically.

A permanent item continues to exist in the current KB after the KB is reset or restarted. When you save the current KB to a file, only the KB's permanent items are stored in the KB file.

A transient item does not continue to exist in the current KB after the KB is reset or restarted. Likewise, a KB that has been loaded but not yet started contains no transient items. When you save the current KB to a file, the KB's transient items are not stored in the KB file.

After being created interactively, an item is permanent. For instance, any item that you create by selecting from the KB Workspace > New Object menu is a permanent item.

When you create an item programmatically, using the create action, that item is transient.

To make an item permanent:

To make an item transient:

For instance, this rule creates a new transaction message and makes it permanent:

Changing the permanent/transient status of an item causes G2 to propagate the new status to all items below it in the workspace hierarchy.


Note: You cannot make a permanent item the subordinate item of a transient item. For instance, you cannot transfer a permanent item to a transient workspace, and you cannot make a permanent workspace the subworkspace of a transient item.

G2 provides the g2-system-predicate system procedure to obtain any item's permanent/transient status:

To determine if an item is permanent or transient programmatically:

G2 returns a truth value indicating the predicate you pass to the procedure, which can be permanent, transient, or showing.

Active/Inactive Status

The active or inactive status of an item indicates whether G2 has activated it. When an item is inactive, it cannot be referenced by other items.

You can only set the active/inactive status of activatable subworkspaces. You perform this action programmatically.

To activate an activatable subworkspace programmatically:

When you start or restart the current KB, G2 automatically activates all enabled top-level workspaces, then automatically propagates those workspaces' active/inactive status to all items below them in the KB's workspace hierarchy. All enabled items on active workspaces are activated.

For more information about how G2 activates workspaces, see Activating and Deactivating Workspaces.

In addition, G2 cannot activate these items:

Only an active variable can have a current value and a history. Only an active list or array can contain values in its elements.

Referencing Inactive Definitions

If a class definition is not active, the class that it defines continues to exist. Likewise, relation instances continue to exist even when the relation definitions on which they are based become inactive.

Enabled/Disabled Status

The enabled/disabled status of an item refers to whether the item can be activated. By default, when you create an item interactively, it is enabled and can thus be activated.

You can disable an item only interactively. Once disabled, an item is effectively deactivated, and its activation status is inactive. Changing the enabled/disabled status of an item propagates to the items below it in the KB workspace hierarchy. Enabling or disabling a workspace affects the items that reside upon it, causing them all to become deactivated. Enabling one or more items that reside upon a disabled workspace has no effect until the workspace status is active and enabled.

To change the enabled/disabled status of an item:

To enable all disabled items in the current KB:

You can change an item's enabled/disabled status at any time, regardless of the KB's run-state. Changing this status does not affect the item's other status values.

When you enable an item, G2 immediately activates the item, unless there is another item above it in the workspace hierarchy that is not activated. If the enabled item is an activatable subworkspace, it is activated only when it is the target of an activate action.

When you disable an item, G2 cannot activate it, even if the item meets all other criteria for activation.

When you save the current KB, G2 also saves the knowledge of which items are disabled. Thus, items will continue to be disabled after you next load that KB.

Participation Status

The status of an item can be OK, INCOMPLETE, or BAD and reflects whether the item knowledge is valid for KB participation. G2 changes the participation status of an item appropriately as the knowledge an item contains is updated.

The OK, INCOMPLETE, BAD status of each item appears in its Notes attribute. The next table summarizes the meaning of each setting:

Item status Description
OK
All attributes have valid values, and a sufficient number of attributes have values to permit the item to participate in the KB's processing.
INCOMPLETE
At least one attribute, whose setting is required for the item to participate in KB processing, requires a different value.
BAD
At least one attribute does not have a valid value.

For example, after you create a new class definition, G2 initializes the status of the item to incomplete until you specify new values for the item's Class-name and Direct-superior-classes attributes.

The Notes attribute of an item can also contain other useful information. For example, the status of an item may be OK, but if the item resides upon a disabled workspace, it cannot participate in KB processing. Such a status is displayed in the item Notes attribute with a message such as:

Because G2 reports the participation status of an item in the Notes attribute, you can reference this status in expressions. For instance, when debugging your KB, use the Inspect facility to construct a command like this:

or:

These commands display items whose Notes attribute does not contain the value OK.

The Notes attribute is a composite attribute, as described in Chapter 12, Attribute Access Facility. You can refer directly to the status information of active items that the Notes attribute contains by referring to the item-status of an item, and to the actual notes of an item using the item-notes.

To refer to the item-status of an item:

To refer to the item-notes of an item:

Identifying the Superior and Subordinate Relationships Among Items

An item's knowledge includes whether it has a superior or subordinate relationship to other items. G2 considers information about the following relationships to be part of an item's knowledge:


Tip: You can use expressions to refer to the item that is superior or subordinate to another item. See
Referring to the Superior Item.

G2 propagates knowledge from item to item along the lines of the superior and subordinate relationships, including:

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (4 out of 11)

Copyright © 1997 Gensym Corporation, Inc.