Skip to content

Commit

Permalink
make disimm_func more flexible
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdfish committed Jan 22, 2024
1 parent 2dcd84d commit 528e606
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 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.12.6"
version = "0.13.0"

[deps]
ConcreteStructs = "2569d6c7-a4a2-43d3-a901-331e8e4be471"
Expand Down
2 changes: 1 addition & 1 deletion src/MemoryFunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ function partial_matching!(actr::AbstractACTR, chunk::AbstractChunk; request...)
slots = chunk.slots
p = 0.0; δ = actr.parms.δ
for (k,v) in request
dissim = actr.parms.dissim_func(slots[k], v)
dissim = actr.parms.dissim_func(k, slots[k], v)
p += δ * dissim
end
chunk.act_pm = p
Expand Down
5 changes: 3 additions & 2 deletions src/Structs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -416,16 +416,17 @@ function Declarative(;memory=Chunk[], filtered=(:isa,:retrieved))
end

"""
default_dissim_func(v1, v2)
default_dissim_func(s, v1, v2)
A default dissimilarity function which returns 1 for a mismatch and 0 otherwise.
# Arguments
- `s`: the slot
- `v1`: slot value 1
- `v2`: slot value 2
"""
default_dissim_func(v1, v2) = v1 v2 ? 1.0 : 0.0
default_dissim_func(s, v1, v2) = v1 v2 ? 1.0 : 0.0

Broadcast.broadcastable(x::Declarative) = Ref(x)

Expand Down
2 changes: 1 addition & 1 deletion test/Memory_Tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ using SafeTestsets
using ACTRModels
using Test

function dissim_func(x, y)
function dissim_func(s, x, y)
if (x == :a1 && y == :a2) || (y == :a1 && x == :a2)
return 0.1
elseif (x == :a1 && y == :a3) || (y == :a1 && x == :a3)
Expand Down

0 comments on commit 528e606

Please sign in to comment.