| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (5 out of 14)

Obtaining Values for Variables

The purpose of variables is to hold a value and, optionally, to maintain a record of values through history keeping.

Updating a variable value can take several forms. A variable can receive an unrequested value or one that is requested. Both types of update have effects on the KB.

Obtaining Unrequested Values

When variables receive unrequested values, the new value can cause forward chaining which, in turn, can conclude values for other variables. A variable can receive an unrequested value from:

For information on GFI, a superseded capability, see Appendix F, Superseded Practices. For a description of using initial values, see Specifying an Initial Value.

Obtaining Requested Values

The events that create a request for a new variable value are:

When G2 receives a request for a variable value, it first determines whether the Last-recorded-value is still valid by checking the Validity-interval attribute. The validity interval of a variable is described in Specifying a Validity Interval. If the value has not expired, G2 uses it and does not seek a new value. G2 seeks a value for a variable only when an item needs a value for the variable and the variable's value has expired. The attempt to obtain a new value for a variable is called data seeking.

Value expiration does not itself cause G2 to data seek for a value. If a variable value expires and no outstanding request for that value exists, G2 does not try to obtain a value automatically.

G2 begins data seeking by determining which data server the variable specifies in its Data-server attribute. A data server is the process or task that tries to obtain a value for the variable. The variable data servers are as follows:

GFI and the G2 Simulator are superseded capabilities. For more information, see Appendix F, Superseded Practices.

When the data server is other than the inference engine, G2 can receive both requested and unrequested values from that data server. The rest of this section shows how each of the data servers gets a value for the variable. Variable failures are described in Handling a Variable Failure.

Inference Engine Data Server

The inference engine can obtain values from rules or formulas.

To obtain a value for a variable, the inference engine:

  1. Checks to see whether the variable has a specific formula in its Formula attribute.

    If a specific formula exists, G2 uses it to compute a value for the variable.

  2. Checks to see whether there is a generic formula. If one exists, G2 uses that.

  3. When neither a specific nor a generic formula exists for the variable, and backward chaining is permitted, G2 backward chains to a rule to find a value.

    Backward chaining is the process of invoking one or more rules capable of inferring a value for the variable. For a description of backward chaining, see Backward Chaining.

  4. If neither a specific nor a generic formula exists, and backward chaining does not produce a variable, G2 fails to get a value.

Forward and backward chaining are controlled by the Options attribute of both rules and variables. For variables to be able to backward chain to a rule, and for variables and parameters to forward chain to a rule, both items must have their Options attribute set appropriately.

G2-Simulator Data Server

The G2 Simulator is a superseded capability. For more information, see Appendix F, Superseded Practices.

G2, G2 Gateway, or GFI Data Server

If the variable is using one of the other data servers, G2 sends a request to that data server for a value. G2 then performs other tasks until it receives a value.

If G2 does not receive a value within the time specified by the Inference Engine Parameters system table attribute, Timeout-for-variables, G2 fails to get a value for the variable.

GFI is a superseded capability. For more information, see Appendix F, Superseded Practices.

Handling a Variable Failure

A variable fails to receive a value if G2 requests a value and one of the following is true:

A variable is not considered failed if G2 withdraws all requests for the variable's value before the timeout expires, or before it tries all avenues for finding the value.

When a variable fails, G2 does two things:

  1. It invokes any whenever rules that check for a failure in the variable.

  2. It schedules a task to try again to get a value for the variable.

Invoking Whenever Rules for Failed Variables

G2 invokes whenever rules automatically when at least one statement in the antecedent is true.

Two forms of whenever rules that you can write to test variable values are:

You can use whenever rules to initiate specific action in the event of a failed variable. For example, a rule such as this:

could start a procedure whenever G2 detected a variable failure. Using whenever rules this way is analogous to writing on error statements in procedures. Such whenever rules are invoked once after each time the variable fails to receive a value, not after each retry task.

Retrying the Variable

As long as there are pending requests for the variable's value, G2 retries the variable once every retry period, which is specified in the Retry-interval-after-timeout attribute in the Inference Engine Parameters system table. When no more requests for the value of the variable exist, G2 stops retrying the variable, but the variable is still considered failed.

A variable remains failed until it receives a value.

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (5 out of 14)

Copyright © 1997 Gensym Corporation, Inc.