Skip to content

Commit

Permalink
minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdfish committed Jan 6, 2022
1 parent 5ea955d commit 9e99da4
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ACTRModels"
uuid = "c095b0ea-a6ca-5cbd-afed-dbab2e976880"
authors = ["itsdfish"]
version = "0.10.3"
version = "0.10.4"

[deps]
ConcreteStructs = "2569d6c7-a4a2-43d3-a901-331e8e4be471"
Expand Down
44 changes: 31 additions & 13 deletions src/MemoryFunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@ function baselevel(d, lags)
end

"""
baselevel(d, chunk)
baselevel!(N, L, k, lags, d)
Computes baselevel activation according exact equation.
Computes baselevel activation with hybrid approximation.
# Arguments
- `actr`: an `ACTR` model object
- `chunk`: a chunk
- `N`: the number of times the chunk was used
- `L`: lifetime of chunk in seconds
- `k`: number of timestaps tracked
- `lags`: time since last use for each k
- `d`: decay rate
"""
function baselevel!(actr, chunk)
@unpack N,L,k,lags = chunk
d = actr.parms.d
function baselevel!(N, L, k, lags, d)
exact = baselevel(d, lags)
approx = 0.0
if N > k
Expand All @@ -37,14 +38,30 @@ function baselevel!(actr, chunk)
x2 = (1 - d) * (L - tk)
approx = x1 / x2
end
chunk.act_bll = log(exp(exact) + approx)
return log(exp(exact) + approx)
end

"""
baselevel!(actr, chunk)
Computes baselevel activation with hybrid approximation.
# Arguments
- `actr`: an `ACTR` model object
- `chunk`: a chunk
"""
function baselevel!(actr, chunk)
@unpack N,L,k,lags = chunk
d = actr.parms.d
chunk.act_bll = baselevel!(N, L, k, lags, d)
return nothing
end

"""
baselevel!(actr)
Computes baselevel activation for all chunks according exact equation.
Computes baselevel activation with hybrid approximation.
# Arguments
Expand Down Expand Up @@ -286,10 +303,11 @@ Computes the spreading activation for a given chunk
- `chunk`: the chunk for which spreading activation is computed
"""
function spreading_activation!(actr, chunk)
@unpack γ,ω = actr.parms
imaginal = actr.imaginal
isempty(imaginal.buffer) ? (return nothing) : nothing
w = compute_weights(imaginal)
γ = actr.parms.γ; r = zero(γ); sa = zero(γ)
w = compute_weights(imaginal, ω)
r = zero(γ); sa = zero(γ)
slots = imaginal.buffer[1].slots
denoms = imaginal.denoms
for (v,d) in zip(slots, denoms)
Expand Down Expand Up @@ -323,8 +341,8 @@ function cache_denomitors(actr)
return nothing
end

function compute_weights(mod)
return mod.ω / length(mod.buffer[1].slots)
function compute_weights(mod, ω)
return ω / length(mod.buffer[1].slots)
end

function compute_denom(memory, value)
Expand Down
6 changes: 5 additions & 1 deletion src/Structs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ ACT-R parameters with default values. Default values are overwritten with keywor
- `τ=0.0`: retrieval threshold
- `s=0.2`: logistic scalar for activation noise.
- `γ=1.6`: maximum associative strength
- `blc=0.0`: base level constant
- `δ=0.0`: mismatch penalty
- `ω=1.0`: weight for source of spreading activation
- `blc=0.0`: base level constant
- `ter=0.0`: a constant for encoding and responding time
- `mmp_fun`: a mismatch penalty function. By default, `mmp_fun` subtracts `δ` from each non-matching slot value
- `sa_fun`: a function for spreading activation which requires arguments for actr and chunk
Expand All @@ -56,6 +57,7 @@ ACT-R parameters with default values. Default values are overwritten with keywor
s
γ
δ
ω
blc
ter
mmp_fun
Expand All @@ -81,6 +83,7 @@ function Parms(;
s = .3,
γ = 0.0,
δ = 0.0,
ω = 1.0,
blc = 0.0,
ter = 0.0,
mmp_fun = default_penalty,
Expand All @@ -106,6 +109,7 @@ function Parms(;
s,
γ,
δ,
ω,
blc,
ter,
mmp_fun,
Expand Down
1 change: 0 additions & 1 deletion test/benchmarks.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

using ACTRModels, BenchmarkTools
n = 10
parms = (sa=false, mmp=true, γ=1.3, δ=1.0)
Expand Down

0 comments on commit 9e99da4

Please sign in to comment.