current-control-shellAgenda Control Shelldefine-ks-classdefine-ksGoTo Top

define-ks   ks-name &key activation-predicate enabled execution-function ks-class ksa-class obviation-events obviation-predicate precondition-function rating retrigger-events retrigger-function revalidation-predicate trigger-events => ks[Macro]

Purpose
Define or redefine a knowledge source (KS).

Package   :agenda-shell

Module   :agenda-shell

Arguments and values

ks-name     A symbol naming the KS (not evaluated)
activation-predicate     A function designator specifying a function object of two arguments (the KS unit instance and the event object) that returns a generalized boolean or nil (default is nil)
enabled     A generalized boolean (default is t)
execution-function     A function designator specifying a function object of one argument (the KSA unit instance) or nil (default is nil)
ks-class     A class or a symbol specifying a class (not evaluated)
ksa-class     A class or a symbol specifying a class (not evaluated)
obviation-events     An event-specification (see below, not evaluated)
obviation-predicate     A function designator specifying a function object of two arguments (the KSA unit instance and the event object) that returns a generalized boolean or nil (default is nil)
precondition-function     A function designator specifying a function object of two arguments (the KS unit instance and the event object) or nil (default is nil)
rating     A rating (default is 1)
retrigger-events     An event-specification (see below, not evaluated)
retrigger-function     A function designator specifying a function object of two arguments (the KSA unit instance and the event object) or nil (default is nil)
revalidation-predicate     A function designator specifying a function object of one argument (the KSA unit instance) that returns a generalized boolean or nil (default is nil)
trigger-events     An event-specification (see below, not evaluated)
ks     A KS

Returns
The unit instance representing the KS

Detailed syntax

event-specification ::= (event-signature*)

event-signature ::= (event-class-specifier
    [unit-class-or-instance-specifier
        [{:slot-name slot-name} | {:slot-names slot-names} |
          {:path path} | {:paths paths}]])

event-class-specifier ::= atomic-event-class | (atomic-event-class subeventing-specifier) | t
atomic-event-class ::= event-class | event-class-name
subeventing-specifier ::= :plus-subevents | :no-subevents + | =

The shorthand + subevents specifier is equivalent to :plus-subevents and = to :no-subevents.

unit-class-or-instance-specifier ::= unit-instance | (unit-instance*) |
atomic-unit-class |
(atomic-unit-class subclassing-specifier) | t
atomic-unit-class ::= unit-class | unit-class-name
subclassing-specifier ::= :plus-subclasses | :no-subclasses | + | =

The shorthand + subclasses specifier is equivalent to :plus-subclasses and = to :no-subclasses.

Description
A KS definition creates a unit instance of class ks-class which specifies how activations of the KS are created and executed. The lifetime of each KS activation involves the following sequence:

KS functions and predicates

The Agenda Shell provides a rich set of KS functions and predicates to manage the progression of KSAs from initial triggering and activation through obviation or execution. A typical KS will only require a subset of these functions and predicates.

An activation-predicate is a function that is called with two arguments, the unit instance representing the KS and the object representing the triggering event. The activation-predicate should return a generalized boolean that indicates whether the KS should continue to be considered for activation in response to the event. Typically, an activation-predicate is specified for a KS that does not require a precondition-function rating computation, but that does require an activate/don't-activate decision.

A precondition-function is a function that is called with two arguments, the unit instance representing the KS and the object representing the triggering event. The precondition-function should return one of the following sets of values:

An execution-function is a function that implements the KS. When an activation of the KS is executed, this function is called with one argument, the unit instance representing the KSA. If the execution function returns the value :stop (and, optionally, a additional values to be returned by the control shell), the control shell will exit immediately.

An obviation-predicate is a function that is called with two arguments, the unit instance representing the KSA and the object representing the obviation event. The obviation-predicate should return a generalized boolean that indicates whether the KSA should be obviated.

A retrigger-function is a function that is called with two arguments, the unit instance representing the KSA and the object representing the retrigger event. The retrigger-function can perform whatever activities are needed in response to the event. Typically this involves augmenting the triggering context of the KSA or changing its execution rating.

A revalidation-predicate is a function that is called with one argument, the unit instance representing the KSA. The revalidation-predicate is called immediately before a KSA is executed and should return a generalized boolean that indicates whether the KSA should be executed (if true) or obviated (if false).

See also
    define-ks-class
    define-ksa-class
    describe-ks
    ensure-ks
    ks
    ks-enabled-p
    standard-event-instance
    undefine-ks

Examples
Define an initial KS that is triggered when the control shell is started:

  (define-ks initial
     :trigger-events ((control-shell-started-event)) 
     :execution-function #'initial-ks-function)

Define a KS named aggregate-hyps that is triggered whenever a hyp unit instance is created:

  (define-ks aggregate-hyps
     :trigger-events ((instance-created-event hyp))
     :precondition-function #'aggregate-hyps-precondition-function
     :execution-function #'aggregate-hyps-ks-function)

Note
Unit-instance-specific KS triggers are not yet implemented in GBBopen.


The GBBopen Project


current-control-shellAgenda Control Shelldefine-ks-classdefine-ksGoTo Top