TriggerTree class

A trigger tree organizes evaluators according to generalization/specialization in order to make it easier to use rules.

Constructors

TriggerTree()

Intializes a new instance of the TriggerTree class.

Properties

comparers

A dictionary of PredicateComparer values, with string keys.

optimizers

A list of Optimizer for optimizing claues.

root

The root node instance.

totalTriggers

The total number of triggers.

Methods

addTrigger(string | Expression, any, Quantifier[])

Add a trigger expression to the tree.

matches(MemoryInterface | any)

Return the possible matches given the current state.

removeTrigger(Trigger)

Remove trigger from tree.

toString()
treeToString(number)

Generates a string describing the tree.

verifyTree()

Verify the tree meets specialization/generalization invariants.

Constructor Details

TriggerTree()

Intializes a new instance of the TriggerTree class.

new TriggerTree()

Property Details

comparers

A dictionary of PredicateComparer values, with string keys.

comparers: PredicateComparers

Property Value

optimizers

A list of Optimizer for optimizing claues.

optimizers: Optimizer[] = []

Property Value

root

The root node instance.

root: Node

Property Value

totalTriggers

The total number of triggers.

totalTriggers: number = 0

Property Value

number

Method Details

addTrigger(string | Expression, any, Quantifier[])

Add a trigger expression to the tree.

function addTrigger(stringOrExpression: string | Expression, action: any, quantifiers: Quantifier[]): Trigger

Parameters

stringOrExpression

string | Expression

Trigger to add.

action

any

Action when triggered.

quantifiers

Quantifier[]

Quantifiers to use when expanding expressions.

Returns

New trigger.

matches(MemoryInterface | any)

Return the possible matches given the current state.

function matches(state: MemoryInterface | any): Trigger[]

Parameters

state

MemoryInterface | any

State to evaluate against.

Returns

List of possible matches.

removeTrigger(Trigger)

Remove trigger from tree.

function removeTrigger(trigger: Trigger): boolean

Parameters

trigger
Trigger

Trigger to remove.

Returns

boolean

True if removed trigger.

toString()

function toString(): string

Returns

string

A string the represents the current object.

treeToString(number)

Generates a string describing the tree.

function treeToString(indent: number): string

Parameters

indent

number

Current indent level.

Returns

string

String describing the tree.

verifyTree()

Verify the tree meets specialization/generalization invariants.

function verifyTree(): Node

Returns

Bad node if found.