Refactor ODE analyses to build models in the theory of signed polynomial ODE systems#1251
Refactor ODE analyses to build models in the theory of signed polynomial ODE systems#1251tim-at-topos wants to merge 2 commits into
Conversation
fe17e78 to
90dbf51
Compare
|
@epatters Here's a problem: we cannot push the mass-action analysis for signed stock-flow diagrams through the theory of polynomial ODEs because we interpret negative links as negative exponents, meaning we'd need rational ODEs. For now, since I essentially made up the theory of signed stock-flow diagrams, I've just removed its mass-action analysis. I see two options:
I'm in favour of 1, but would appreciate your thoughts. |
|
Hmm, good question. What would be the code footprint of option (2), i.e., leaving the special-cased ODE analysis code for signed stock-flow as is? |
|
For now it would be reasonably small, essentially just duplicating half of the current |
mass_action.rs to build a model in the theory of signed polynomial ODE systemsb5ccd2e to
fb0ef7a
Compare
Thanks for explaining. Though I'm not sure how to weigh the tradeoff between keeping existing functionality and maintaining a clean codebase, I tend to value the latter a lot and since you also seem inclined in that direction, I'd say go ahead and remove it. |
4acac39 to
e254a8f
Compare
6fac82b to
a5cc41b
Compare
|
@epatters and @tslil-topos this isn't quite ready for review yet, but all that's missing is some extra documentation and then some extra refactoring that I think I might move to a future PR because this one is already quite hefty. (Note, however, that the subsequent PR should hopefully remove as many lines as this one adds!) Would it be possible for one of you to to start taking a look through this when you get a chance please? I think it's very likely that there will be substantial changes requested, and I'd rather put off writing documentation for things that are liable to change 😎 I've included a suggested path through reading the code in the opening comment of this PR! |
|
Sounds good. I've marked this for review despite your caveats because that will help me remember it needs a review. |
5d2c138 to
706e78b
Compare
WIP: Rethinking traits WIP: Some tests only half failing WIP: Tests passing; time to tidy ENH: Build derived model of th_signed_polynomial_ode_system in mass_action ENH: Mass-action for stock-flow; DEL: Mass-action for signed stock-flow ENH: struct for transition / flow interfaces WIP: Starting on Lotka-Volterra WIP: Failing tests FIX: Lotka-Volterra tests passing FIX: Working analysis (frontend) ENH: Lotka-Volterra equations ENH: Linear ODE refactor ENH: Linear ODE equations WIP: Starting on ODESemantics WIP: lotka_volterra_semantics() WIP: build_system_from_ode_semantics WIP: DblModelForODESemantics WIP: ODESemanticsAnalysis and ODESemanticsProblemData WIP: ODESemantics trait WIP: Documentation WIP: ODESemantics for mass-action WIP: Cleaning up types, but mass-action still frustrating WIP: Big reshuffle (moving functions out from a struct) WIP: Fixing mass-action again WIP: terrible code WIP: Changed from ObGen to Ob WIP: Stock-flow mass-action FIX: Passing catlog tests Rename LinearODE -> LCC FIX: Documentation TODO: Redesign
d5550f2 to
aafac79
Compare
This PR includes a massive redesign of the way that we handle ODE semantics, which has the bonus of introducing some new capabilities (#1177) as well as (hopefully) making adding new ODE semantics in the future considerably simpler.
For those reading (or reviewing) this code, my suggested reading order would be:
ode::polynomial_ode::build_system_custom_parametersto see how we interpret models ofth_signed_polynomial_ode_systemas systems of polynomial ODEsode::lotka_volterrato see an example of the main chunk of defining an ODE semantics: giving an implementation forODESemanticsAnalysisode::ode_semanticsto see where all the actual new code isode::mass_actionto see where things are still messy and need some extra finessingFEEDBACK, where I have some specific questions / highlight specific problems with this design.p.s. I know this PR adds quite a lot of code for something called a "refactor", but (a) I added a lot of documentation and some new tests, and (b) a subsequent PR focussing on the front-end parts should now be possible, allowing for much more code removal!
To-do:
PetriNetMassActionAnalysis::mass_action::build_systemwithpolynomial_ode::build_systemStockFlowMassActionAnalysis::mass_action::build_systemwithpolynomial_ode::build_systemlotka_volterra.rsandlinear_ode.rsto build an ODE system #1275catlog::src::stdlib::analyses::ode::signed_coefficients.rs(and anything else)ODESemanticscatlog::src::stdlib::analyses::ode::polynomial_ode.rsODESemanticsfor linear ODEODESemanticsfor mass-actioncatlog-wasm::src::analysescatlog-wasm::src::latex(cf. Traits for LaTeX equations throughout analyses #1172)