Skip to content

Commit

Permalink
Add version, description, & parameter info to module interface (#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
asmaloney authored Jul 20, 2023
1 parent b20876b commit d43e23a
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 8 deletions.
15 changes: 14 additions & 1 deletion actr/modules/declarative_memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,23 @@ type DeclarativeMemory struct {
func NewDeclarativeMemory() *DeclarativeMemory {
return &DeclarativeMemory{
Module: Module{
Name: "memory",
Name: "memory",
Version: BuiltIn,
Description: "declarative memory which stores chunks from the buffers for retrieval",
BufferList: buffer.List{
{Name: "retrieval", MultipleInit: true},
},
Params: []ParamInfo{
{"decay", "the 'base-level learning' decay parameter"},
{"finst_size", "how many chunks are retained in memory"},
{"finst_time", "how long the finst lasts in memory"},
{"instantaneous_noise", "turns on the activation noise calculation & sets instantaneous noise"},
{"latency_exponent", "latency exponent (f)"},
{"latency_factor", "latency factor (F)"},
{"max_spread_strength", "turns on the spreading activation calculation & sets the maximum associative strength"},
{"mismatch_penalty", "turns on partial matching and sets the penalty in the activation equation"},
{"retrieval_threshold", "retrieval threshold (τ)"},
},
},
}
}
Expand Down
4 changes: 3 additions & 1 deletion actr/modules/extra_buffers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ type ExtraBuffers struct {
func NewExtraBuffers() *ExtraBuffers {
return &ExtraBuffers{
Module: Module{
Name: "extra_buffers",
Name: "extra_buffers",
Version: BuiltIn,
Description: "allows declaration of one or more extra goal-style buffers in the model",
},
}
}
Expand Down
11 changes: 8 additions & 3 deletions actr/modules/goal.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,23 @@ type Goal struct {

// "spreading_activation": see "Spreading Activation" in "ACT-R 7.26 Reference Manual" pg. 290
// ccm (DMSpreading.weight): 1.0
// pyactr (buffer_spreading_activation): 1.0
// vanilla (:ga): 1.0
// pyactr (buffer_spreading_activation): no default
// vanilla (:ga): 0.0
SpreadingActivation *float64
}

func NewGoal() *Goal {
return &Goal{
Module: Module{
Name: "goal",
Name: "goal",
Version: BuiltIn,
Description: "provides a goal buffer for the model",
BufferList: buffer.List{
{Name: "goal", MultipleInit: false},
},
Params: []ParamInfo{
{"spreading_activation", "spreading activation weight"},
},
},
}
}
Expand Down
7 changes: 6 additions & 1 deletion actr/modules/imaginal.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ type Imaginal struct {
func NewImaginal() *Imaginal {
return &Imaginal{
Module: Module{
Name: "imaginal",
Name: "imaginal",
Version: BuiltIn,
Description: "provides a goal style buffer with a delay and an action buffer for manipulating the imaginal chunk",
BufferList: buffer.List{
{Name: "imaginal", MultipleInit: false},
},
Params: []ParamInfo{
{"delay", "time it takes a request to the buffer to complete (seconds)"},
},
},
}
}
Expand Down
44 changes: 43 additions & 1 deletion actr/modules/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,67 @@ import (
"github.com/asmaloney/gactar/actr/params"
)

const BuiltIn = "built-in"

// Module is an ACT-R module
type Module struct {
Name string
Name string
Version string
Description string

BufferList buffer.List

Params []ParamInfo
}

// ModuleInterface provides an interface for the ACT-R concept of a "module".
type ModuleInterface interface {
ModuleName() string
ModuleVersion() string
ModuleDescription() string

Buffers() buffer.List

HasParameters() bool
ParameterNames() []string
SetParam(param *params.Param) (err error)
}

func (m Module) ModuleName() string {
return m.Name
}

func (m Module) ModuleVersion() string {
return m.Version
}

func (m Module) ModuleDescription() string {
return m.Description
}

func (m Module) Buffers() buffer.List {
return m.BufferList
}

func (m Module) HasParameters() bool {
return len(m.Params) > 0
}

func (m Module) ParameterNames() (names []string) {
for _, param := range m.Params {
names = append(names, param.Name)
}

return names
}

// BuiltInModules returns a slice of all the built-in modules
func BuiltInModules() (modules []ModuleInterface) {
modules = append(modules, NewExtraBuffers())
modules = append(modules, NewGoal())
modules = append(modules, NewImaginal())
modules = append(modules, NewDeclarativeMemory())
modules = append(modules, NewProcedural())

return
}
6 changes: 6 additions & 0 deletions actr/modules/params.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package modules

type ParamInfo struct {
Name string
Description string
}
9 changes: 8 additions & 1 deletion actr/modules/procedural.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ type Procedural struct {

func NewProcedural() *Procedural {
return &Procedural{
Module: Module{Name: "procedural"},
Module: Module{
Name: "procedural",
Version: BuiltIn,
Description: "handles production definition and execution",
Params: []ParamInfo{
{"default_action_time", "time that it takes to fire a production (seconds)"},
},
},
}
}

Expand Down

0 comments on commit d43e23a

Please sign in to comment.