NodeBrain Module Reference
Release 0.6.4 - April 2006

< Prev Table of Contents Next >

1        Introduction. 5

1.1      Module Declaration. 5

1.2      Skill Declaration. 7

1.3      Expert Definition. 8

1.4      Expert Assertion. 9

1.5      Expert Condition. 10

1.6      Expert Command. 11


1         Introduction

 

This document prepares the reader for using expert skill modules distributed with NodeBrain.  In the introduction we cover basic concepts that apply to all NodeBrain expert skill modules.  These concepts are also covered in various sections of the NodeBrain Uses Guide, but here we bring it all together in one place for review.  In the chapters that follow, we describe the specific features of individual skill modules not covered in the NodeBrain User Guide.

 

What is a NodeBrain expert skill module?

 

You should think of an expert skill module as a NodeBrain plug-in.  It is simply a module that plugs into NodeBrain to provide additional functionality.  To do this, it must conform to the NodeBrain Expert Skill Module API described in the NodeBrain API Reference.  NodeBrain calls functions (or methods) within a module to perform specific types of tasks that NodeBrain associates with an expert.

 

Here we are not concerned with the internal mechanics; we are concerned with the relationship between NodeBrain’s command syntax and the general tasks performed by a module.

 

1.1        Module Declaration

 

 

   Syntax:

 

 

moduleDeclareCmd

::= declare š term š module š  moduleSpec [ ; comment ] •

 

 

 

 

moduleSpec

::= [ { “pathList” } ] [ module | fileSpec ] [ ( cellist ) ] [ : text ]

 

 

 

 

pathList

::= path { ( ; | : ) path }

A colon may not be used as a path separator on Windows

 

 

 

 

Module

::= identifier

Platform independent variable part of preferred module filename.

nb_mod_identifier.suffix

 

 

 

 

Suffix

::= .so | .sl | .dylib | .dll

NodeBrain uses the platform standard.

 

 

 

 

fileSpec

::= [ path / ] filename

 

 

 

 

Cellist

::= cellExpression { , cellExpression }

 

 

 

 

Text

Any sequence of characters understood by the skill module.

 

 

 

 

 

When NodeBrain is installed, it is normally not necessary to declare the modules distributed with it.  If you are testing your own custom module or a module provided by a third party that is not installed in a location that is searched by default, you should first consider the use of the NB_MOD_PATH environment variable, or a platform specific environment variable.

 

          NB_MOD_PATH=”.:..” nb …             [platform independent variable]

          LD_LIBRARY_PATH=”.:..” nb …        [platform specific variable]

 

Although the environment variable NB_MOD_PATH is platform independent, the path separator (“:” in the example above) may be platform dependent.  Use a semi-colon (“;”) as a platform independent path separator.

 

          NB_MOD_PATH=”.;..” nb …             [platform independent variable and value]

 

There may be times when you will want to declare a module identifier to direct NodeBrain to use a substitute module.  For example, if you have a set of rules that use the tree module, and you want these rules to use an alternate “high performance” tree module, you might use the following declare command.

 

          declare tree module myhypertree;  # use high performance tree module

 

You may also want to declare a module to direct it to use a special option.  For example, suppose a hypothetical sqlstore module provided 5 related skills and had a high performance option “hyper”.  The following declaration might be used to select the high performance option.

 

          declare sqlstore module :hyper;

 

Again, when you are using standard options of an installed module, there is no need to declare it.  NodeBrain will find it when referenced in an expert definition command.

 

 


1.2        Skill Declaration

 

 

   Syntax:

 

 

skillDeclareCmd

::= declare š term š skill š  skillSpec [ ; comment ] •

 

 

 

 

skillSpec

::= [ module . ] skill [ ( cellList ) ] [ : text ]

 

 

 

 

module

::= identifier

 

 

 

 

skill

::= identifier

 

 

 

 

cellList

::= cellExpression { , cellExpression }

 

 

 

 

text

Any sequence of characters understood by the skill module.

 

 

 

 

A skill is a set of related methods provided by a skill module.  Like module declaration, skill declaration is optional.  You only need to declare a skill if you want to change the name or specify options to alter the behavior of the skill.

 

Let’s say we have a skill for computing mortgage payments given the amount of a loan, interest rate and number of monthly payments.  We’ll call this the “payment” skill of the “money” module.  If this skill had an “integer” option to round all computed payments to an integer value, we could choose this option by declaring the skill.

 

          declare money.payment skill money.payment:integer;

 

We might also want to change the name of our skill.

 

          declare mortpay skill money.payment:integer;

 

Now the “mortpay” skill is implemented by the “payment” skill of the “money” module using the “integer” option supported by the “payment” skill.

 

 


1.3        Expert Definition

 

 

   Syntax:

 

 

expertDefineCmd

::= define š term š expert expertSpec ] •

 

 

 

 

expertSpec

::= skill [ ( cellList ) ] [ ; comment | : text  ]

 

 

 

 

skill

::= [ module . ] identifier

 

 

 

 

cellList

::= cellExpression { , cellExpression }

 

 

 

 

text

Any sequence of characters understood by the skill module.

 

 

 

 

Independent of skill modules, an expert is an important NodeBrain object type used to group rules and facts to create a context for the interpretation of commands.  When combined with a skill module as described in this document, it has extended capabilities. 

 

An expert combines skill with knowledge (information).  The skill is provided by a skill module, and includes a unique ability to interpret, store, manipulate and reference a set of information that is foreign to NodeBrain’s core interpreter.  The common understanding is in the expert skill module API, a communication agreement between NodeBrain and a skill module.

 

At expert definition time, NodeBrain must:

 

1)     locate or load and bind the appropriate skill module

2)     locate and bind the appropriate skill within the module

3)     call the skill’s construction method to create the skill’s definition of the expert

 

To use a skill module, you must always define at least one expert with a reference to a skill provided by the module.  If you do not specify a module identifier, it is assumed to be the same as the skill identifier.

 

          define trapper expert snmptrap;               # implicit module reference

          define trapper expert snmptrap.snmptrap;  # explicit module reference

 

 

 

 

 


1.4        Expert Assertion

 

 

   Syntax:

 

 

assertCmd

::= ( assert š | ` ) [ assertionList ] [ ; [ comment ] ] •

 

 

 

 

assertionList

::= cellAssertion { ,  cellAssertion }

 

 

 

 

cellAssertion

::= [ ! | ? ] cellIdentifier | cellIdentifier ( = | == ) cellExpression

 

 

 

 

cellIdentifier

::= identifier | [ identifier ] ( [ cellist ] )

 

 

 

 

In an ASSERT command, a reference to an expert identifier with an argument list is handled by the associated skill module.  NodeBrain has no idea what an assertion of this form will do.  It simply passes the argument list to the assert method of the skill associated with the expert.  You will have to reference the documentation for a given skill module to understand what to expect and what is possible. 

 

As an example, the tree module and cache modules will respond in unique ways to an assertion.

 

          define joe expert tree;

          assert joe(1,2,3),joe(“abc”,”def”);

 

          define sam expert cache:(~(1h):a,b(5));

          assert sam(1,2),sam(“abc”,”def”);

 

An argument list that is not preceded by an expert identifier is a reference to the context expert.

 

          sam. assert (1,”def”);         # assertion with implicit expert reference

          assert sam(1,”def”);           # assertion with explicit expert reference

 

Some skill modules will not provide an implementation of the assert method.  In that case, you will get an error message if you attempt an assertion.

 

 


1.5        Expert Condition

 

 

   Syntax:

 

 

expertCondition

::=  expert [ ( cellist ) ]

 

 

 

 

expert

Term defined as expert.

 

 

 

 

cellList

::= cellExpression { , cellExpression }

 

 

 

 

An expert condition may be used within a cell expression.  NodeBrain calls the “evaluate” method of the associated skill, passing the cell list as arguments, to get a value for the expression.

 

You will notice that the expert condition looks like a function call in familiar programming languages.  It actually is, since NodeBrain calls the skill’s evaluate method to get a result.  What is peculiar to NodeBrain, at least relative to most languages, is the timing of calls to this function.  The function may be called any time the value of one of the argument cells changes.  NodeBrain reacts to cell changes much like a spreadsheet.

 

You will need to refer to documentation for a given skill module to understand what to expect as a value for an expert condition for a given set of arguments.

 

As an example, the tree module returns a value that has been asserted for a given leaf.

 

          define leaf expert tree

          assert leaf(1,2,3)=4,!leaf(“abc”);

          assert a=”abc”;

          define r1 on(leaf(1,2,3)>2 and !leaf(a));

 

The expert condition “leaf(1,2,3)” has a value of 4 and the expert condition leaf(a) has a value of zero (false).  So the rule r1 condition is currently true.

 


1.6        Expert Command

 

 

   Syntax:

 

 

expertCmd

::= ( expert ( cellist ) ( : [ text ] | ; [ comment ] ) |  

        expert : [ text ] ) •

 

 

 

 

expert

Term defined as expert.

 

 

 

 

cellist

::= cellExpression { , cellExpression }

 

 

 

 

text

Any sequence of characters understood by the skill module.

 

 

 

 

An expert command begins with a term defined as an expert that uses a defined skill.  NodeBrain simply passes the cell list and text to the command method of the skill associated with the expert.  This enables (but does not require) a skill module to implement a unique command language for operating on an expert.  You must reference the documentation for individual skill modules, since their command languages will vary.

 

Notice that an expert command starts with an expert term that is followed by either a left parenthesis “(“ or a colon “:”.  The same expert term with a trailing period and space is recognized as a context prefix.  The same expert term followed by a space will be interpreted as a verb.  When issuing an expert command with no parameters and no text message, include the colon or a null parameter list.

 

> expert:

> expert();

 

Some skill modules will not implement the command method.  In that case, you will get an error message if you attempt an expert command.

 

 

 



Copyright © 2003-2006 The Boeing Company