diff --git a/Project.toml b/Project.toml index 111d733..ec4986f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,11 +1,10 @@ name = "ACTRModels" uuid = "c095b0ea-a6ca-5cbd-afed-dbab2e976880" authors = ["itsdfish"] -version = "0.8.0" +version = "0.8.1" [deps] ConcreteStructs = "2569d6c7-a4a2-43d3-a901-331e8e4be471" -DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" @@ -20,7 +19,6 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] ConcreteStructs = "v0.2.0" -DataFrames = "0.22.0, 1.0" Distributions = "^0.22.0, 0.23, 0.24, 0.25" Parameters = "^0.12.0" PrettyTables = "1.1.0" diff --git a/src/MemoryFunctions.jl b/src/MemoryFunctions.jl index ad2f6e1..2f821a0 100644 --- a/src/MemoryFunctions.jl +++ b/src/MemoryFunctions.jl @@ -916,6 +916,25 @@ function get_parm(actr, p) return getfield(actr.parms, p) end +""" + blend_chunks(actr; request...) + +Computes blended value over chunks given a retrieval request. By default, +values are blended over the set of slots formed by the set difference between all +slots of a chunk and the slots specified in the retrieval request. The default time used +in activation calculations is taken from `get_time`. Currently, blended +is only supported for numeric slot-values. + +# Arguments + +- `actr::AbstractACTR`: an `ACTR` model object +- `request...`: optional keywords for the retrieval request +""" +function blend_chunks(actr; request...) + t = get_time(actr) + return blend_chunks(actr, t; request...) +end + """ blend_chunks(actr, cur_time::Float64=0.0; request...) @@ -926,15 +945,52 @@ is only supported for numeric slot-values. # Arguments -- `actr`: an `ACTR` model object -- `cur_time::Float64=0.0`: current simulated time +- `actr::AbstractACTR`: an `ACTR` model object +- `cur_time::Float64`: current simulated time - `request...`: optional keywords for the retrieval request """ -function blend_chunks(actr, cur_time::Float64=0.0; request...) +function blend_chunks(actr::AbstractACTR, cur_time::Float64; request...) blended_slots = setdiff(keys(actr.declarative.memory[1].slots), keys(request)) return blend_chunks(actr, blended_slots, cur_time; request...) end +""" + blend_chunks(actr; request...) + +Computes blended value over chunks given a retrieval request. By default, +values are blended over the set of slots formed by the set difference between all +slots of a chunk and the slots specified in the retrieval request. The default time used +in activation calculations is taken from `get_time`. Currently, blended +is only supported for numeric slot-values. + +# Arguments + +- `actr::AbstractACTR`: an `ACTR` model object +- `request...`: optional keywords for the retrieval request +""" +function blend_chunks(actr::AbstractACTR; request...) + return blend_chunks(actr, get_time(actr); request...) +end + +""" + blend_chunks(actr; request...) + +Computes blended value over chunks given a retrieval request. By default, +values are blended over the set of slots formed by the set difference between all +slots of a chunk and the slots specified in the retrieval request. The default time used +in activation calculations is taken from `get_time(actr`). Currently, blended +is only supported for numeric slot-values. + +# Arguments + +- `actr::AbstractACTR`: an `ACTR` model object +- `blended_slots`: a set of slots over which slot-values are blended +- `request...`: optional keywords for the retrieval request +""" +function blend_chunks(actr::AbstractACTR, blended_slots; request...) + return blend_chunks(actr, blended_slots, get_time(actr); request...) +end + """ blend_chunks(actr, cur_time::Float64=0.0; request...) @@ -946,10 +1002,10 @@ for numeric slot-values. - `actr`: an `ACTR` model object - `blended_slots`: a set of slots over which slot-values are blended -- `cur_time::Float64=0.0`: current simulated time +- `cur_time`: current simulated time - `request...`: optional keywords for the retrieval request """ -function blend_chunks(actr, blended_slots, cur_time=0.0; request...) +function blend_chunks(actr, blended_slots, cur_time; request...) chunks = retrieval_request(actr; request...) compute_activation!(actr, chunks, cur_time; request...) probs = soft_max(actr, chunks) diff --git a/src/Structs.jl b/src/Structs.jl index 160ebf1..d13f454 100644 --- a/src/Structs.jl +++ b/src/Structs.jl @@ -355,7 +355,6 @@ function Imaginal(;buffer=Chunk[], ω=1.0, denoms=Int64[]) Imaginal(buffer, state, ω, denoms) end - Imaginal(chunk::Chunk, state, ω, denoms) = Imaginal([chunk], state, ω, denoms) Imaginal(T::DataType, state, ω, denoms) = Imaginal(T(undef,1), state, ω, denoms) @@ -584,6 +583,12 @@ function Motor(T::DataType, state, mouse_position) Motor(T(undef,1), state, mouse_position) end +mutable struct Scheduler + time::Float64 +end + +Scheduler(;time=0.0) = Scheduler(time) + abstract type AbstractACTR end """ @@ -626,7 +631,7 @@ end Broadcast.broadcastable(x::ACTR) = Ref(x) function ACTR(;declarative=Declarative(), imaginal=Imaginal(), - goal = Goal(), scheduler=nothing, visual=nothing, visual_location=nothing, + goal = Goal(), scheduler=Scheduler(), visual=nothing, visual_location=nothing, procedural=nothing, motor=nothing, visicon=init_visicon(), parms...) parms′ = Parms(;parms...) ACTR(declarative, imaginal, visual, visual_location, goal, procedural, motor, visicon, parms′, scheduler) diff --git a/src/Utilities/Utilities.jl b/src/Utilities/Utilities.jl index a6fa0dd..1cc9a8a 100644 --- a/src/Utilities/Utilities.jl +++ b/src/Utilities/Utilities.jl @@ -317,15 +317,12 @@ function get_mean_activations(chunks::Vector{<:Chunk}) end get_time(actr::AbstractACTR) = get_time(actr.scheduler) -get_time(scheduler::Float64) = scheduler get_time(scheduler) = scheduler.time add_time(actr::AbstractACTR, t) = add_time(actr.scheduler, t) -add_time(scheduler::Float64, t) = scheduler += t -add_time(scheduler) = scheduler.time += t +add_time(scheduler, t) = scheduler.time += t reset_time!(actr::AbstractACTR) = reset_time!(actr.scheduler) -reset_time!(scheduler::Float64) = scheduler = 0.0 reset_time!(scheduler) = scheduler.time = 0.0 rnd_time(μ) = rand(Uniform(μ * (2/3), μ * (4/3))) \ No newline at end of file