Browse Source

Fixed transition array support (#38)

pull/39/head v1.2.2
Micah Halter 4 months ago
committed by GitHub
parent
commit
10ba5cafe3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 11 deletions
  1. +1
    -1
      Project.toml
  2. +3
    -2
      src/solvers.jl
  3. +1
    -0
      src/types.jl
  4. +4
    -8
      src/visualization.jl
  5. +3
    -0
      test/runtests.jl

+ 1
- 1
Project.toml View File

@ -1,7 +1,7 @@
name = "Petri"
uuid = "4259d249-1051-49fa-8328-3f8ab9391c33"
authors = ["Micah Halter <micah.halter@gtri.gatech.edu>", "James Fairbanks <james.fairbanks@gtri.gatech.edu>"]
version = "1.2.1"
version = "1.2.2"
[deps]
AutoHashEquals = "15f4f7f2-30c1-5605-9d31-71845cf9641f"


+ 3
- 2
src/solvers.jl View File

@ -74,9 +74,10 @@ function SDEProblem(m::Model, u0, tspan, β)
T = m.Δ
ϕ = Dict()
Spos = Dict(S[k]=>k for k in keys(S))
Tpos = Dict(keys(T)[k]=>k for k in keys(keys(T)))
T_keys = collect(keys(T))
Tpos = Dict(T_keys[k]=>k for k in keys(T_keys))
nu = spzeros(Float64, length(S), length(T))
for k in keys(T)
for k in T_keys
l,r = T[k]
for i in keys(l)
nu[Spos[i],Tpos[k]] -= l[i]


+ 1
- 0
src/types.jl View File

@ -13,6 +13,7 @@ represented by states and transition functions
end
Model(s::S, Δ) where S<:UnitRange = Model(collect(s), Δ)
Model(s::S, Δ) where S<:Int = Model(1:s, Δ)
"""
NullPetri


+ 4
- 8
src/visualization.jl View File

@ -7,14 +7,10 @@ node_attrs = Attributes(:shape=>"plain", :style=>"filled", :color=>"white")
edge_attrs = Attributes(:splines=>"splines")
function edgify(δ, transition, reverse::Bool)
attr = Attributes()
return map(collect(keys(δ))) do k
weight = "$(δ[k])"
state = "$k"
attr = Attributes(:label=>weight, :labelfontsize=>"6")
return Edge(reverse ? ["T_$transition", "S_$state"] :
["S_$state", "T_$transition"], attr)
end
return [Edge(reverse ? ["T_$transition", "S_$k"] :
["S_$k", "T_$transition"],
Attributes(:label=>"$(δ[k])", :labelfontsize=>"6"))
for k in collect(keys(δ)) if δ[k] != 0]
end
"""


+ 3
- 0
test/runtests.jl View File

@ -7,8 +7,11 @@ using LabelledArrays
([1], [1])])
sir_2 = Petri.Model(1:3,[([1,1], [2]),
([1], [1])])
sir_3 = Petri.Model(3,[([1,1], [2]),
([1], [1])])
@test typeof(Graph(sir_1)) == Graph
@test sir_1 == sir_2
@test sir_1 == sir_3
@test EmptyPetri(5) == Petri.Model(1:5, [])


Loading…
Cancel
Save