Documentation
¶
Overview ¶
Package actr implements our internal, parsed version of the amod file which is passed to a Framework to generate their code.
Index ¶
- Variables
- func IsInternalChunkType(name string) bool
- func IsReservedType(name string) bool
- func ValidLogLevel(e string) bool
- type ACTRLogLevel
- type BufferPatternMatch
- type BufferStateMatch
- type Chunk
- type ClearStatement
- type Comparison
- type Constraint
- type Initializer
- type Match
- type Model
- func (model *Model) AddImplicitChunk(chunkName string)
- func (model *Model) AddImplicitChunksFromPattern(pattern *Pattern)
- func (model *Model) AddInitializer(initializer *Initializer)
- func (model *Model) AddSimilarity(similar *Similarity)
- func (model Model) BufferNames() (list []string)
- func (model Model) Buffers() (list buffer.List)
- func (model *Model) CreateExtraBuffers() *modules.ExtraBuffers
- func (model *Model) CreateImaginal() *modules.Imaginal
- func (model *Model) FinalizeImplicitChunks()
- func (model Model) HasAnyBufferMatch() bool
- func (model Model) HasImplicitChunks() bool
- func (model Model) HasPrintStatement() bool
- func (model Model) ImaginalModule() *modules.Imaginal
- func (model *Model) Initialize()
- func (model Model) LookupBuffer(bufferName string) buffer.Interface
- func (model Model) LookupChunk(typeName string) *Chunk
- func (model Model) LookupInitializer(buffer string) *Initializer
- func (model Model) LookupModule(moduleName string) modules.Interface
- func (model *Model) SetParam(kv *keyvalue.KeyValue) (err error)
- func (m *Model) SetRunOptions(options *Options)
- type ModuleStateMatch
- type Options
- type Pattern
- type PatternSlot
- type PatternVar
- type PrintStatement
- type Production
- func (p *Production) AddDoStatement(statement *Statement)
- func (p *Production) AddSlotToSetStatement(statement *SetStatement, slot *SetSlot)
- func (p Production) LookupMatchByBuffer(bufferName string) *BufferPatternMatch
- func (p Production) LookupMatchByVariable(varName string) *BufferPatternMatch
- func (p Production) LookupSetStatementByBuffer(bufferName string) *SetStatement
- type RecallStatement
- type SetSlot
- type SetStatement
- type Similarity
- type Statement
- type StopStatement
- type Value
- type VarIndex
Constants ¶
This section is empty.
Variables ¶
var ACTRLoggingLevels = []string{
"min",
"info",
"detail",
}
Functions ¶
func IsInternalChunkType ¶ added in v0.10.0
func IsReservedType ¶ added in v0.10.0
IsReservedType checks if the slot name is reserved. See "Default Chunks" pg. 80 of ACT-R manual.
func ValidLogLevel ¶
Types ¶
type ACTRLogLevel ¶
type ACTRLogLevel string
type BufferPatternMatch ¶ added in v0.12.0
type BufferStateMatch ¶ added in v0.12.0
type Chunk ¶
type Chunk struct { TypeName string SlotNames []string NumSlots int AMODLineNumber int // line number in the amod file of the this chunk declaration }
func (Chunk) IsInternal ¶
type ClearStatement ¶
type ClearStatement struct {
BufferNames []string
}
ClearStatement clears a list of buffers.
type Comparison ¶ added in v0.8.0
type Comparison int
const ( Equal Comparison = iota NotEqual )
func (Comparison) String ¶ added in v0.8.0
func (c Comparison) String() string
type Constraint ¶ added in v0.8.0
type Constraint struct { LHS *string Comparison Comparison RHS *Value }
func (Constraint) String ¶ added in v0.8.0
func (c Constraint) String() string
type Initializer ¶
type Match ¶
type Match struct { BufferPattern *BufferPatternMatch // If the buffer and the module's buffer are the same, we will have one of each of these. BufferState *BufferStateMatch ModuleState *ModuleStateMatch }
type Model ¶
type Model struct { Name string Description string Authors []string Examples []*Pattern Modules []modules.Interface Memory *modules.DeclarativeMemory // memory is always present Goal *modules.Goal // goal is always present Procedural *modules.Procedural // procedural is always present Chunks []*Chunk // ExplicitChunks are ones which are named in the initializer like this: // castle [meaning: 'castle'] // We keep track of these to remove them from the implicit list & to check for duplicates. ExplicitChunks []string // ImplicitChunks are chunks which aren't declared, but need to be created by some frameworks. // e.g. by default vanilla will create them and emit a warning: // #|Warning: Creating chunk SHARK with no slots |# // These chunk names come from the initializations & similarities. // We keep track of them so we can create them explicitly to avoid the warnings. ImplicitChunks []string Initializers []*Initializer Similarities []*Similarity Productions []*Production Options // contains filtered or unexported fields }
Model represents a basic ACT-R model. This is used as input to a Framework where it can be run or output to a file. (This is incomplete w.r.t. all of ACT-R's capabilities.)
func (*Model) AddImplicitChunk ¶ added in v0.10.0
func (*Model) AddImplicitChunksFromPattern ¶ added in v0.10.0
AddImplicitChunksFromPattern walks a pattern and adds any IDs to our list of implicit chunks.
func (*Model) AddInitializer ¶ added in v0.10.0
func (model *Model) AddInitializer(initializer *Initializer)
AddInitializer adds the initializer to our list and adds any IDs to ImplicitChunks so we can (possibly) create them in the framework output.
func (*Model) AddSimilarity ¶ added in v0.10.0
func (model *Model) AddSimilarity(similar *Similarity)
AddSimilarity will add a similarity to the list and keep track of the chunk names.
func (Model) BufferNames ¶ added in v0.6.0
BufferNames returns a slice of valid buffer names.
func (*Model) CreateExtraBuffers ¶ added in v0.9.0
func (model *Model) CreateExtraBuffers() *modules.ExtraBuffers
CreateExtraBuffers creates the "extra_buffers" module and adds it to the list.
func (*Model) CreateImaginal ¶
CreateImaginal creates the imaginal module and adds it to the list.
func (*Model) FinalizeImplicitChunks ¶ added in v0.10.0
func (model *Model) FinalizeImplicitChunks()
FinalizeImplicitChunks will remove already-declared chunks from the implicit list and make the list unique.
func (Model) HasAnyBufferMatch ¶ added in v0.13.0
HasAnyBufferMatch checks if this model uses an "any" match. In this case a framework may need to declare a new chunk type for "any_chunk".
func (Model) HasImplicitChunks ¶ added in v0.10.0
func (Model) HasPrintStatement ¶
HasPrintStatement checks if this model uses the print statement. This is used to include extra code to handle printing in some frameworks.
func (Model) ImaginalModule ¶ added in v0.7.0
ImaginalModule gets the imaginal module (or returns nil if it does not exist).
func (*Model) Initialize ¶
func (model *Model) Initialize()
func (Model) LookupBuffer ¶
LookupBuffer looks up the named buffer in the model and returns it (or nil if it does not exist).
func (Model) LookupChunk ¶
LookupChunk looks up the chunk (by type name) in the model and returns it (or nil if it does not exist).
func (Model) LookupInitializer ¶ added in v0.6.0
func (model Model) LookupInitializer(buffer string) *Initializer
LookupInitializer returns an initializer or nil if the buffer does not have one.
func (Model) LookupModule ¶ added in v0.2.0
LookupModule looks up the named module in the model and returns it (or nil if it does not exist).
func (*Model) SetRunOptions ¶ added in v0.12.0
type ModuleStateMatch ¶ added in v0.12.0
type ModuleStateMatch struct { Module modules.Interface // The generated code for the frameworks actually uses a buffer name, not the module name. // So store (one) here for convenience. If the module has multiple buffers it should not // matter which one we pick as the requests should be on its module. Buffer buffer.Interface State string }
type Options ¶ added in v0.12.0
type Options struct { // "log_level": one of 'min', 'info', or 'detail' LogLevel ACTRLogLevel // "trace_activations": output detailed info about activations TraceActivations bool // "random_seed": the seed to use for generating pseudo-random numbers (allows for reproducible runs) // For all frameworks, if it is not set it uses current system time. // Use a uint32 because pyactr uses numpy and that's what its random number seed uses. RandomSeed *uint32 }
type Pattern ¶
type Pattern struct { AnyChunk bool Chunk *Chunk Slots []*PatternSlot }
func (*Pattern) AddSlot ¶
func (p *Pattern) AddSlot(slot *PatternSlot)
func (Pattern) LookupVariable ¶
func (p Pattern) LookupVariable(varName string) *PatternVar
type PatternSlot ¶
type PatternSlot struct { // The item is one of the following: Nil bool Wildcard bool ID *string Str *string Var *PatternVar Num *string // we don't need to treat this as a number anywhere, so keep as a string Negated bool // this item is negated }
func (PatternSlot) String ¶
func (p PatternSlot) String() (str string)
type PatternVar ¶ added in v0.8.0
type PatternVar struct { Name *string Constraints []*Constraint // any constraints on this var }
type PrintStatement ¶
type PrintStatement struct {
Values *[]*Value
}
PrintStatement outputs the string, id, or number to stdout.
func (PrintStatement) IsBufferOutput ¶ added in v0.12.0
func (p PrintStatement) IsBufferOutput() bool
IsBufferOutput returns whether or not we have an argument list consisting of one ID.
type Production ¶
type Production struct { Model *Model // link back to its model so we can add implicit chunks Name string Description *string // optional description to output as a comment in the generated code VarIndexMap map[string]VarIndex // track the buffer and slot name each variable refers to Matches []*Match DoStatements []*Statement AMODLineNumber int // line number in the amod file of the this production }
Production stores information on how to match buffers and perform some operations. It uses a small language to modify states upon successful matches.
func (*Production) AddDoStatement ¶ added in v0.10.0
func (p *Production) AddDoStatement(statement *Statement)
AddDoStatement adds the statement to our list and adds any IDs to ImplicitChunks so we can (possibly) create them in the framework output.
func (*Production) AddSlotToSetStatement ¶ added in v0.10.0
func (p *Production) AddSlotToSetStatement(statement *SetStatement, slot *SetSlot)
AddSlotToSetStatement is used to add slot info to an already-existing set statement. See LookupSetStatementByBuffer() above.
func (Production) LookupMatchByBuffer ¶
func (p Production) LookupMatchByBuffer(bufferName string) *BufferPatternMatch
func (Production) LookupMatchByVariable ¶
func (p Production) LookupMatchByVariable(varName string) *BufferPatternMatch
LookupMatchByVariable checks all matches for a variable by name. This is pretty inefficient, but given the small number of matches in a production, it's probably not worth doing anything more complicated. We could store all the vars used in all the matches on the Match itself and look it up there.
func (Production) LookupSetStatementByBuffer ¶
func (p Production) LookupSetStatementByBuffer(bufferName string) *SetStatement
LookupSetStatementByBuffer is used when combining several set consecutive statements on one buffer. So this:
set goal.foo to 1 set goal.bar to 10
is treated like this:
set foo, bar on goal to 1, 10
type RecallStatement ¶
type RecallStatement struct { Pattern *Pattern MemoryModuleName string RequestParameters map[string]string }
RecallStatement is used to pull information from memory.
type SetStatement ¶
type SetStatement struct { Buffer buffer.Interface // buffer we are manipulating Slots *[]SetSlot // (1) set this slot Chunk *Chunk // (1) if we are setting slots, point at the chunk they reference for easy lookup Pattern *Pattern // (2) pattern if we are setting the whole buffer }
SetStatement will set a slot or the entire contents of the named buffer to a string or a pattern. There are two forms:
(1) set (Buffer).(SetSlot) to (SetSlot.Value) (2) set (Buffer) to (Pattern)
type Similarity ¶ added in v0.10.0
type Statement ¶
type Statement struct { Clear *ClearStatement Print *PrintStatement Recall *RecallStatement Set *SetStatement Stop *StopStatement }
type StopStatement ¶ added in v0.8.0
type StopStatement struct { }
StopStatement outputs a stop command. There are no parameters.