Skip to content

Commit

Permalink
Fix matching by SSSet distance (#144)
Browse files Browse the repository at this point in the history
* remove filter line, which leads to problems in rmaps when keys are retracted

* remove filter line and add test with synthetic multistable system which originally caught the error with the filter+retraction

* simplify test

* increment patch version
  • Loading branch information
KalelR authored Aug 6, 2024
1 parent 0bd6178 commit 835f6a7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/matching/sssdistance.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ function _matching_map_distances(keys₊, keys₋, distances::Dict, threshold;
end
end

# the final step is to filter out equivalent mappings where key and value are the same
filter!(p -> p.first p.second, rmap)
return rmap
end

Expand Down
16 changes: 16 additions & 0 deletions test/continuation/matching_attractors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ end
end
end

@testset "synthetic multistable matching" begin
attractors_cont_simple = Dict{Int64, SVector{1, Float64}}[Dict(1 => [0.0]), Dict(1 => [0.0]), Dict(2 => [2.0], 1 => [0.0]), Dict(2 => [0.0], 1 => [2.0]), Dict(2 => [2.0], 3 => [4.0], 1 => [-5.0]), Dict(2 => [4.0], 3 => [-5.0], 1 => [2.0]), Dict(4 => [6.0], 2 => [0.0], 3 => [2.0], 1 => [4.0]), Dict(4 => [4.0], 2 => [0.0], 3 => [2.0], 1 => [6.0]), Dict(5 => [8.0], 4 => [6.0], 2 => [0.0], 3 => [2.0], 1 => [4.0])]
attractors_cont = [Dict(k=>StateSpaceSet(Vector(v)) for (k,v) in atts) for atts in attractors_cont_simple]

mapped_atts = deepcopy(attractors_cont)
rmaps = match_sequentially!(mapped_atts, default)

fractions_cont = [Dict(1 => 1.0), Dict(1 => 1.0), Dict(2 => 0.8, 1 => 0.2), Dict(2 => 0.2, 1 => 0.8), Dict(2 => 0.2, 3 => 0.6, 1 => 0.2), Dict(2 => 0.6, 3 => 0.2, 1 => 0.2), Dict(4 => 0.4, 2 => 0.2, 3 => 0.2, 1 => 0.2), Dict(4 => 0.2, 2 => 0.2, 3 => 0.2, 1 => 0.4), Dict(5 => 0.2, 4 => 0.2, 2 => 0.2, 3 => 0.2, 1 => 0.2)]
mapped_fracs = deepcopy(fractions_cont)
match_sequentially!(mapped_fracs, rmaps)

@test all(keys.(attractors_cont) .== keys.(mapped_atts) )
@test all(keys.(attractors_cont) .== keys.(mapped_fracs) )
@test all(Set.(values.(fractions_cont)) .== Set.(values.(mapped_fracs)))
end

@testset "global_continuation matching" begin
# Make fake attractors with points that become more "separated" as "parameter"
# is increased
Expand Down

0 comments on commit 835f6a7

Please sign in to comment.