AlgebraicJulia / Catlab.jl

A framework for applied category theory in the Julia language
https://www.algebraicjulia.org
MIT License
614 stars 58 forks source link

Stratification Bug while using apex(pullback(...)) #713

Closed Tom-Szendrey closed 1 year ago

Tom-Szendrey commented 1 year ago

While trying to use apex(pullback(...)) or ob(pullback(...)) sname is the only attribute populated Below is what was ran to reproduce this result. Examples came from both demo notebooks

image

image

I was able to get the expected result using:

res = stratify(modelATyped=>[[:strata],[:strata],[:strata],[]], # S I R D
        modelBTyped=>[[:disease], [:disease,:infect]],# Q NQ 
        typesP
) 

function stratify(petri_net1, petri_net2, type_system)
  return pullback([add_cross_terms(petri_net, type_system) for petri_net in [petri_net1, petri_net2]]) |> apex
end

image

kris-brown commented 1 year ago

if you're following the stratification made easy demo, then you are getting expected results.

The pullback you are trying to construct was called naive_stratification in the notebook, and it was an example intended to demonstrate that "directly" stratifying those two models will produce a model that has no transitions. (nt counts the number of transitions and the notebook showsnt(naive_stratification) == 0). The stratify helper function automates how you have to update the SIRD and Quarantine models such that the stratification that we really want is computed via Catlab's pullback.

Let me know if any of the wording in that notebook can be fixed or if this doesn't actually address your problem!

Tom-Szendrey commented 1 year ago

Thanks! This clears things up. I believe I was misunderstanding due to some online chats we had I will continue using the stratify helper function moving forward