You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I make a labelled Petri net, the transition names come out in order of declaration but the state names appear to be in the order that they appear in the transitions, not in the type passed to the @relation.
epi_transitions =LabelledPetriNet(
[:Pop],
:infection=>((:Pop, :Pop)=>(:Pop, :Pop)),
:exposure=>(:Pop=>:Pop),
:recovery=>(:Pop=>:Pop))
seir_uwd =@relation () where (S::Pop, E::Pop, I::Pop, R::Pop) begininfection(S, I, E, I)
exposure(E, I)
recovery(I, R)
end
seir_acst =oapply_typed(epi_transitions, seir_uwd, [:β , :σ, :γ])
seir_lpn =dom(seir_acst) # Extract labelled Petri netsnames(seir_lpn)
Gives:
4-element Vector{Symbol}::S:I:E:R
Is it possible to maintain the order of the states to that declared in the tuple?
I have a similar issue when making a UWD programmatically.
functionmake_age_classes(K, prefix="a")
# Start with a blank UWD with K populations
uwd =RelationDiagram(repeat([:Pop], K))
# Build junctions (just a `Dict`), with the side effect of updating the UWD# `junctions` will be as follows similar to the following# Dict{Symbol, Int64} with n entries:# :a_1 => 1# :a_2 => 2
junctions =Dict(begin
variable =Symbol(prefix *"$(i)")
junction =add_junction!(uwd, :Pop, variable=variable)
set_junction!(uwd, port, junction, outer=true)
variable => junction
endfor (i, port) inenumerate(ports(uwd, outer=true)))
# This generates all combinations of the keys# Here, this will be a matrix of all pairs of keys
pairs =collect(Iterators.product(keys(junctions), keys(junctions)))
# This creates an empty vector to store the transition names in
tnames =Vector{Symbol}(undef,0)
## Cycle through pairs and add boxes for infectionfor pair in pairs
# We need 4 entries in the tuple as :infection is defined as infection(S, I, I, I)
ins_outs = (pair[1], pair[2], pair[1], pair[2])
# In the below, [junction_type(uwd, junctions[p]) for p in ins_outs] is just a vector of 4 :Pop
box =add_box!(uwd, [junction_type(uwd, junctions[p]) for p in ins_outs], name=:infection)
for (rgn, port) inzip(ins_outs, ports(uwd, box))
set_junction!(uwd, port, junctions[rgn])
end# This adds the names (as `Symbol`s) to the vector of transition namespush!(tnames,Symbol("$(pair[1])_$(pair[2])"))
end## Generate an ACSet transformation using the above `epi_transitions`
act =oapply_typed(epi_transitions, uwd, tnames)
return act
end
K=3
age_acst =make_age_classes(K)
age_lpn =dom(age_acst)
snames(age_lpn)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
When I make a labelled Petri net, the transition names come out in order of declaration but the state names appear to be in the order that they appear in the transitions, not in the type passed to the
@relation
.Gives:
Is it possible to maintain the order of the states to that declared in the tuple?
I have a similar issue when making a UWD programmatically.
Gives:
Where does this order come from?
Beta Was this translation helpful? Give feedback.
All reactions