Documentation ¶
Index ¶
- func TestEqual(args ...GValue) (bool, error)
- func TestLess(args ...GValue) (bool, error)
- type AliasDeclaration
- type AlphaMem
- func (m *AlphaMem) Activate(w *WME) int
- func (m *AlphaMem) AddSuccessor(successors ...alphaMemSuccesor)
- func (m *AlphaMem) ForEachItem(fn func(*WME) (stop bool))
- func (m *AlphaMem) IsSuccessorsEmpty() bool
- func (m *AlphaMem) NItems() int
- func (m *AlphaMem) RemoveSuccessor(successor alphaMemSuccesor)
- type AlphaNetwork
- func (n *AlphaNetwork) AddFact(f Fact) int
- func (n *AlphaNetwork) AlphaRoot() AlphaNode
- func (n *AlphaNetwork) DestoryAlphaMem(alphaMem *AlphaMem)
- func (n *AlphaNetwork) InitAlphaMem(am *AlphaMem)
- func (n *AlphaNetwork) InitDummyAlphaMem(am *AlphaMem, c Guard)
- func (n *AlphaNetwork) MakeAlphaMem(aliasType TypeInfo, guards []Guard) *AlphaMem
- func (n *AlphaNetwork) RemoveFact(f Fact)
- type AlphaNode
- type BetaMem
- type BetaNetwork
- type BetaNode
- type ConstantTestNode
- func (n ConstantTestNode) AddChild(child AlphaNode)
- func (t *ConstantTestNode) Adjust(c Guard)
- func (n ConstantTestNode) ForEachChild(fn func(AlphaNode) (stop bool))
- func (n ConstantTestNode) GetChild(h uint64) AlphaNode
- func (t *ConstantTestNode) GetNegativeNode() *NegativeTestNode
- func (n *ConstantTestNode) Hash() uint64
- func (n ConstantTestNode) IsParentOf(child AlphaNode) bool
- func (n ConstantTestNode) NChildren() int
- func (n ConstantTestNode) OutputMem() *AlphaMem
- func (n ConstantTestNode) Parent() AlphaNode
- func (n *ConstantTestNode) PerformTest(w *WME) (bool, error)
- func (t *ConstantTestNode) RemoveChild(child AlphaNode)
- func (t *ConstantTestNode) SetNegativeNode(n *NegativeTestNode)
- func (n ConstantTestNode) SetOutputMem(mem *AlphaMem)
- func (n ConstantTestNode) SetParent(p AlphaNode)
- type Fact
- type Guard
- type JoinNode
- type JoinTest
- type NegativeTestNode
- func (n NegativeTestNode) AddChild(child AlphaNode)
- func (t *NegativeTestNode) Adjust(c Guard)
- func (n NegativeTestNode) ForEachChild(fn func(AlphaNode) (stop bool))
- func (n NegativeTestNode) GetChild(h uint64) AlphaNode
- func (n *NegativeTestNode) Hash() uint64
- func (n NegativeTestNode) IsParentOf(child AlphaNode) bool
- func (n NegativeTestNode) NChildren() int
- func (n NegativeTestNode) OutputMem() *AlphaMem
- func (n NegativeTestNode) Parent() AlphaNode
- func (n *NegativeTestNode) PerformTest(w *WME) (bool, error)
- func (n NegativeTestNode) RemoveChild(child AlphaNode)
- func (n NegativeTestNode) SetOutputMem(mem *AlphaMem)
- func (n NegativeTestNode) SetParent(p AlphaNode)
- type PNode
- type Production
- type ReteNode
- type Selector
- type TestAtJoinNode
- type TestFunc
- type TestOp
- type Token
- type TypeTestNode
- func (n TypeTestNode) AddChild(child AlphaNode)
- func (n TypeTestNode) ForEachChild(fn func(AlphaNode) (stop bool))
- func (n TypeTestNode) GetChild(h uint64) AlphaNode
- func (t *TypeTestNode) Hash() uint64
- func (n TypeTestNode) IsParentOf(child AlphaNode) bool
- func (n TypeTestNode) NChildren() int
- func (n TypeTestNode) OutputMem() *AlphaMem
- func (n TypeTestNode) Parent() AlphaNode
- func (t *TypeTestNode) PerformTest(w *WME) (bool, error)
- func (n TypeTestNode) RemoveChild(child AlphaNode)
- func (n TypeTestNode) SetOutputMem(mem *AlphaMem)
- func (n TypeTestNode) SetParent(p AlphaNode)
- type WME
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AliasDeclaration ¶
type AliasDeclaration struct { Alias GVIdentity Type TypeInfo Guards []Guard }
type AlphaMem ¶
type AlphaMem struct {
// contains filtered or unexported fields
}
AlphaMem store those WMEs that passes constant test
func (*AlphaMem) AddSuccessor ¶
func (m *AlphaMem) AddSuccessor(successors ...alphaMemSuccesor)
func (*AlphaMem) ForEachItem ¶
func (*AlphaMem) IsSuccessorsEmpty ¶
func (*AlphaMem) RemoveSuccessor ¶
func (m *AlphaMem) RemoveSuccessor(successor alphaMemSuccesor)
type AlphaNetwork ¶
type AlphaNetwork struct {
// contains filtered or unexported fields
}
func NewAlphaNetwork ¶
func NewAlphaNetwork() *AlphaNetwork
func (*AlphaNetwork) AddFact ¶
func (n *AlphaNetwork) AddFact(f Fact) int
func (*AlphaNetwork) AlphaRoot ¶
func (n *AlphaNetwork) AlphaRoot() AlphaNode
func (*AlphaNetwork) DestoryAlphaMem ¶
func (n *AlphaNetwork) DestoryAlphaMem(alphaMem *AlphaMem)
func (*AlphaNetwork) InitAlphaMem ¶
func (n *AlphaNetwork) InitAlphaMem(am *AlphaMem)
initialize am with any current working memory
func (*AlphaNetwork) InitDummyAlphaMem ¶
func (n *AlphaNetwork) InitDummyAlphaMem(am *AlphaMem, c Guard)
func (*AlphaNetwork) MakeAlphaMem ¶
func (n *AlphaNetwork) MakeAlphaMem(aliasType TypeInfo, guards []Guard) *AlphaMem
func (*AlphaNetwork) RemoveFact ¶
func (n *AlphaNetwork) RemoveFact(f Fact)
type AlphaNode ¶
type AlphaNode interface { Hash() uint64 PerformTest(*WME) (bool, error) Parent() AlphaNode SetParent(AlphaNode) IsParentOf(child AlphaNode) bool AddChild(child AlphaNode) GetChild(hash uint64) AlphaNode RemoveChild(child AlphaNode) NChildren() int SetOutputMem(mem *AlphaMem) OutputMem() *AlphaMem ForEachChild(fn func(AlphaNode) (stop bool)) }
Alpha test nodes
func NewConstantTestNode ¶
func NewTypeTestNode ¶
func NewTypeTestNode(alphaNode *alphaNode, tf TypeInfo) AlphaNode
type BetaMem ¶
type BetaMem struct { ReteNode // contains filtered or unexported fields }
BetaMem holds all the tokens that match all the previous conditions, in another word, all the tokens pass all the join test and usually got activated by an join node
func NewBetaMem ¶
type BetaNetwork ¶
type BetaNetwork struct {
// contains filtered or unexported fields
}
BetaNetwork manage the whole beta net and all the BetaNode
func NewBetaNetwork ¶
func NewBetaNetwork(an *AlphaNetwork) *BetaNetwork
func (*BetaNetwork) AddFact ¶
func (bn *BetaNetwork) AddFact(fact Fact)
AddFact add a fact, and propagete addition to the entire network
func (*BetaNetwork) AddProduction ¶
func (bn *BetaNetwork) AddProduction(p Production) *PNode
AddProduction add an production and register its unique id
func (*BetaNetwork) GetProduction ¶
func (bn *BetaNetwork) GetProduction(id string) *PNode
GetProduction query an production by its id
func (*BetaNetwork) RemoveFact ¶
func (bn *BetaNetwork) RemoveFact(fact Fact)
RemoveFact remove a fact, and propagete removal to the entire network
func (*BetaNetwork) RemoveProduction ¶
func (bn *BetaNetwork) RemoveProduction(id string) error
RemoveProduction remove a production by a production id, along with all the facts related with it. TODO: provide an option for reserving fact, we can just delete the pnode and its parent, grandparent and grand..grandparent if they are not shared, and leave the alpha mem so that it can still be shared and will not activate any successors if there is none
type ConstantTestNode ¶
type ConstantTestNode struct { Field string // which field in WME we gonna test V GValue // the value to be compared TestOp TestOp // test operation // contains filtered or unexported fields }
ConstantTestNode perform constant test for each WME, and implements by 'Dataflow Network'(see 2.2.1(page 27) in the paper)
func (*ConstantTestNode) Adjust ¶
func (t *ConstantTestNode) Adjust(c Guard)
func (ConstantTestNode) ForEachChild ¶
func (*ConstantTestNode) GetNegativeNode ¶
func (t *ConstantTestNode) GetNegativeNode() *NegativeTestNode
func (*ConstantTestNode) Hash ¶
func (n *ConstantTestNode) Hash() uint64
func (ConstantTestNode) IsParentOf ¶
func (*ConstantTestNode) PerformTest ¶
func (n *ConstantTestNode) PerformTest(w *WME) (bool, error)
func (*ConstantTestNode) RemoveChild ¶
func (t *ConstantTestNode) RemoveChild(child AlphaNode)
func (*ConstantTestNode) SetNegativeNode ¶
func (t *ConstantTestNode) SetNegativeNode(n *NegativeTestNode)
func (ConstantTestNode) SetOutputMem ¶
func (n ConstantTestNode) SetOutputMem(mem *AlphaMem)
type Guard ¶
type Guard struct { AliasAttr GVString Value GValue // should never be GVIdentity Negative bool TestOp TestOp }
Guard define constant test on value
type JoinNode ¶
type JoinNode struct { ReteNode // contains filtered or unexported fields }
JoinNode perform join tests between wmes from an alpha memory and tokens from beta mem, that means JoinNode is usually the parent of a beta memory(beta memory store the results of JoinNode)
type NegativeTestNode ¶
type NegativeTestNode struct {
// contains filtered or unexported fields
}
func (*NegativeTestNode) Adjust ¶
func (t *NegativeTestNode) Adjust(c Guard)
func (NegativeTestNode) ForEachChild ¶
func (*NegativeTestNode) Hash ¶
func (n *NegativeTestNode) Hash() uint64
func (NegativeTestNode) IsParentOf ¶
func (*NegativeTestNode) PerformTest ¶
func (n *NegativeTestNode) PerformTest(w *WME) (bool, error)
func (NegativeTestNode) RemoveChild ¶
func (n NegativeTestNode) RemoveChild(child AlphaNode)
func (NegativeTestNode) SetOutputMem ¶
func (n NegativeTestNode) SetOutputMem(mem *AlphaMem)
type PNode ¶
type PNode struct { ReteNode AliasInfo []AliasDeclaration // contains filtered or unexported fields }
PNode, aka production node, store all the tokens that match the lhs(conditions)
func NewPNode ¶
func NewPNode(parent ReteNode, aliasDecls []AliasDeclaration) *PNode
func (*PNode) AnyMatches ¶
AnyMatches check if there is any match in a production node
type Production ¶
type Production struct { ID string When []AliasDeclaration Match []JoinTest }
type ReteNode ¶
type ReteNode interface { Parent() ReteNode AddChild(children ...ReteNode) AnyChild() bool ClearAndRestoreChildren(fn func()) AttachParent(parent ReteNode) RemoveChild(child ReteNode) bool DetachParent() ForEachChild(fn func(child ReteNode) (stop bool)) ForEachChildNonStop(fn func(child ReteNode)) }
func NewReteNode ¶
type TestAtJoinNode ¶
TestAtJoinNode defines join test between WMEs
func (TestAtJoinNode) Hash ¶
func (t TestAtJoinNode) Hash() uint64
func (TestAtJoinNode) String ¶
func (t TestAtJoinNode) String() string
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
Token stores WMEs that match guards or join test
type TypeTestNode ¶
type TypeTestNode struct { TypeInfo TypeInfo `hash:"ignore"` // TypeInfo specified in a Cond // contains filtered or unexported fields }
func (TypeTestNode) ForEachChild ¶
func (*TypeTestNode) Hash ¶
func (t *TypeTestNode) Hash() uint64
func (TypeTestNode) IsParentOf ¶
func (*TypeTestNode) PerformTest ¶
func (t *TypeTestNode) PerformTest(w *WME) (bool, error)
func (TypeTestNode) RemoveChild ¶
func (n TypeTestNode) RemoveChild(child AlphaNode)
func (TypeTestNode) SetOutputMem ¶
func (n TypeTestNode) SetOutputMem(mem *AlphaMem)
type WME ¶
type WME struct { ID GVIdentity Value GValue // contains filtered or unexported fields }
WME is the working memory element, use to store the fact when matching