Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Catlab migration action on morphisms #40

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/literate/game_of_life.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ If we call `AddCoords` on something built out of `LifeState` instances, it will
make the corresponding thing built out of `LifeStateCoords` instances.
=#

AddCoords = Migrate(SchLifeGraph, LifeState, SchLifeCoords, LifeStateCoords; delta=false);
AddCoords = ΣMigration(FinFunctor(SchLifeGraph, SchLifeCoords), LifeStateCoords);

# ## Initial state for the model

Expand Down
13 changes: 8 additions & 5 deletions docs/literate/lotka_volterra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -219,19 +219,22 @@ migration, we can define them in terms of sheep and then migrate along `F` to
obtain the analogous actions for wolves.
=#

F = Migrate(
Dict(:Sheep => :Wolf, :Wolf => :Sheep),
Dict([:sheep_loc => :wolf_loc, :wolf_loc => :sheep_loc,
F = ΔMigration(FinFunctor(
Dict(:Sheep => :Wolf, :Wolf => :Sheep, :Direction => :Direction, :Eng=>:Eng,
:Time=>:Time, :V=>:V, :E=>:E),
Dict(:sheep_loc => :wolf_loc, :wolf_loc => :sheep_loc,
:sheep_eng => :wolf_eng, :wolf_eng => :sheep_eng, :countdown => :countdown,
:sheep_dir => :wolf_dir, :wolf_dir => :sheep_dir,]), SchLV, LV);
:sheep_dir => :wolf_dir, :wolf_dir => :sheep_dir,
:src=>:src,:tgt=>:tgt,:inv=>:inv,:dir=>:dir,:left=>:left,:right=>:right,
), SchLV, SchLV), LV);

#=
We ought to be able to take a state of the world (with no coordinate information)
and obtain a state of the world with coordinates (the canonical way to do this
is to assign "variables" for the values of the coordinates).
=#

Viz = Migrate(SchLV, LV, SchLV_Viz, LV_Viz; delta=false);
Viz = ΣMigration(FinFunctor(SchLV, SchLV_Viz), LV_Viz);

# # Representables
#=
Expand Down
4 changes: 2 additions & 2 deletions src/ABMs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ basis_pattern(r::ABMRule) = isnothing(r.basis) ? codom(left(r)) : dom(basis(r))
get_matches(r::ABMRule, args...; kw...) =
get_matches(getrule(r), args...; kw...)

(F::Migrate)(r::ABMRule) =
(F::SimpleMigration)(r::ABMRule) =
ABMRule(F(r.rule), r.timer; basis=F(r.basis), name=r.name)

"""
Expand Down Expand Up @@ -281,7 +281,7 @@ end

additions(abm::ABM) = right.(abm.rules)

(F::Migrate)(abm::ABM) = ABM(F.(abm.rules), abm.dyn)
(F::SimpleMigration)(abm::ABM) = ABM(F.(abm.rules), abm.dyn)

Base.getindex(abm::ABM, i::Int) = abm.rules[i]
Base.getindex(abm::ABM, n::Symbol) = abm.rules[abm.names[n]]
Expand Down
Loading