define-ks |
| ks-name &key
| [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 | |
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 | |
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 | |
ks | A KS |
Returns
The unit instance representing the KS
Detailed syntax
| ( event-signature*) |
| ( event-class-specifier |
[unit-class-or-instance-specifier | |
[{:slot-name slot-name} |
{:slot-names slot-names} | | |
{:path path} |
{:paths paths}]]) | |
| atomic-event-class |
( atomic-event-class subeventing-specifier)
| t |
| event-class | event-class-name |
| :plus-subevents | :no-subevents
+ | = |
The shorthand +
subevents specifier is equivalent to
:plus-subevents
and =
to :no-subevents
.
| unit-instance |
( unit-instance*) | |
atomic-unit-class | | |
( atomic-unit-class subclassing-specifier) |
t | |
| unit-class | unit-class-name |
| :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
activation-cycle
obviation-cycle
nil
, the
pending KSA is removed from the pending KSAs queue, the
current control-shell cycle number is stored in the
obviation-cycle
execution-cycle
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
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
nil
indicating the KS is not to be activated in response to
the event
:stop
(and, optionally, additional values to be returned by the
control shell) indicating that the control shell is to exit immediately
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
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
A revalidation-predicate is a function that is called with one
argument, the unit instance representing the KSA. The
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
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
define-ks |