Class: InfernalEngine

InfernalEngine(maxGenopt, traceopt)

This is the inference engine class.

Constructor

new InfernalEngine(maxGenopt, traceopt)

Create a new InfernalEngine instance.
Parameters:
Name Type Attributes Default Description
maxGen Number <optional>
50 The maximum number of agenda generation when executing inference.
trace function <optional>
A tracing function that will be called with a trace object parameter.
Source:

Methods

(static) fact(path, value)

Create a new Fact with the given path and value.
Parameters:
Name Type Description
path string Mandatory path of the fact.
value any Value of the fact, can be 'undefined' to retract the given fact.
Source:

(async) assert(path, value)

Asserts a new fact or update an existing fact for the given path with the provided value. Asserting a fact with an undefined value will retract the fact if it exists.
Parameters:
Name Type Description
path String The full path to the desired fact.
value * The fact value to set, must be a scalar.
Source:

(async) assertAll(facts)

Asserts all recieved facts.
Parameters:
Name Type Description
facts Array.<Fact> A list of facts to assert at in one go.
Source:

(async) def(path, rule)

Add a rule to the engine's ruleset and launche the inference.
Parameters:
Name Type Description
path String The path where to save the rule at.
rule function The rule to add. Must be async.
Source:

(async) defRule(path, rule)

Parameters:
Name Type Description
path String The path where to save the rule at.
rule function The rule to add. Must be async.
Deprecated:
  • Use InfernalEngine#def instead. Add a rule to the engine's ruleset and launche the inference.
Source:

(async) export(contextopt) → {object}

Export internal facts from the given optional path as a JSON object. Do not export rules.
Parameters:
Name Type Attributes Default Description
context String <optional>
"/" The context to export as an object.
Source:
Returns:
a JSON object representation of the engine internal state.
Type
object

(async) exportChanges()

Exports all changed facts since the last call to exportChanges or reset as a Javascript object. Reset the change tracker.
Source:
Returns:
a JSON object containing the cumulative changes since last call.

(async) import(obj, context)

Import the given Javascript object into the engine. Scalar values and arrays as facts, functions as rules. Launches the inference on any new rules and any existing rules triggered by importing the object facts. Infers only when eveything have been imported.
Parameters:
Name Type Description
obj Object The object to import.
context String The path where the object will be imported.
Source:

(async) peek(path) → {Promise.<*>}

Returns the fact value for a given path.
Parameters:
Name Type Description
path String The full path to the desired fact.
Source:
Returns:
The fact value.
Type
Promise.<*>

(async) reset()

Resets the change tracker.
Source:

(async) retract(path)

Retracts a fact or multiple facts recursively if the path ends with '/*'.
Parameters:
Name Type Description
path String The path to the fact to retract.
Source:

(async) undef(path)

Undefine a rule at the given path or a group of rules if the path ends with '/*'.
Parameters:
Name Type Description
path String The path to the rule to be undefined.
Source:

(async) undefRule(path)

Parameters:
Name Type Description
path String The path to the rule to be undefined.
Deprecated:
  • Use InfernalEngine#undef instead. Undefine a rule at the given path or a group of rules if the path ends with '/*'.
Source: