AlgebraicJulia / AlgebraicPetri.jl

Build Petri net models compositionally
https://algebraicjulia.github.io/AlgebraicPetri.jl/
MIT License
72 stars 20 forks source link

Tests for DPO rewriting of Petri nets #59

Closed epatters closed 1 year ago

epatters commented 3 years ago

The following tests were removed from @kris-brown's https://github.com/AlgebraicJulia/Catlab.jl/pull/425 to avoid code duplication from this repo. This issue is a reminder to add the tests here once the DPO feature is merged and released in Catlab. Actually, I only see one @test below, so the test assertions should probably be bulked up a bit too.

sir=EpiRxnNet((:S=>100, :I=>1, :R=>0),
              (:inf,.03)=>((:S,:I)=>(:I,:I)),
              (:rec,.25)=>(:I=>:R));

seir = EpiRxnNet((:S=>100,:I=>1,:E=>1,:R=>0),
                 (:inf,.03)=>((:S,:I)=>(:I,:I)),
                 (:rec,.25)=>(:I=>:R),
                 (:inc,.1)=>(:E=>:I),
                 (:exp,.1)=>((:S,:I)=>(:E,:I)));
Rg = EpiRxnNet((:S=>100,:I=>1,:E=>1),
               (:exp,.1)=>((:S, :I)=>(:E, :I)),
               (:inc,.1)=>(:E => :I))
Lg = EpiRxnNet((:S=>100,:I=>1),)

L=ACSetTransformation(Lg,Lg,S=[1,2]);
R=ACSetTransformation(Lg,Rg,S=[1,2]);
m=ACSetTransformation(Lg, sir,S=[1,2]);
@test is_isomorphic(seir, rewrite_match(L,R,m))

Lg = EpiRxnNet((:S=>100,:I=>1),)
Rg = EpiRxnNet((:S=>100,:I=>1), (:sus,.1)=>(:I=>:S))
L=ACSetTransformation(Lg,Lg,S=[1,2]);
R=ACSetTransformation(Lg,Rg,S=[1,2]);
m=ACSetTransformation(Lg, seir,S=[1,2]);
seirs = rewrite_match(L,R,m)

Lg = EpiRxnNet((:I=>1),)
Rg = EpiRxnNet((:I=>1,:D=>0), (:die,.1)=>(:I=>:D))
L=ACSetTransformation(Lg,Lg,S=[1]);
R=ACSetTransformation(Lg,Rg,S=[1]);
m=ACSetTransformation(Lg, seir,S=[2]);
seird = rewrite_match(L,R,m)
bosonbaas commented 3 years ago

Thanks Evan! I've been doing some work that involves applying DPO to PetriNets, so I'll try to put together these tests from that.

slwu89 commented 1 year ago

I think we're good to close this with #112!