-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Unexpected Stratify behaviour when applied more than once #331
Comments
Thanks for the detailed explanation! This currently happens any time a parameter is used in multiple rate laws. So e.g., if a parameter |
I appreciate the consideration: the logic is probably tricky to implement! I think the behaviour that the user wants us to support is more or less:
|
@liunelson finally figured this one out. Parameter renaming now depends on the specific strata that were applied to the template that it is involved in. In addition, I added an additional argument to Example: In [1]: from mira.metamodel import *
In [2]: from mira.examples.sir import *
In [3]: for t in sir_parameterized.templates:
...: print(t.get_concept_names(), t.rate_law)
...:
{'susceptible_population', 'infected_population'} beta*infected_population*susceptible_population
{'immune_population', 'infected_population'} gamma*infected_population
In [4]: tm = stratify(sir_parameterized, key='age', strata=['young', 'old'], cartesian_control=True,
param_renaming_uses_strata_names=True)
In [5]: for t in tm.templates:
...: print(t.get_concept_names(), t.rate_law)
...:
{'susceptible_population_young', 'infected_population_young'} beta_young_young*infected_population_young*susceptible_population_young
{'susceptible_population_young', 'infected_population_old', 'infected_population_young'} beta_young_old*infected_population_old*susceptible_population_young
{'susceptible_population_old', 'infected_population_old', 'infected_population_young'} beta_old_young*infected_population_young*susceptible_population_old
{'susceptible_population_old', 'infected_population_old'} beta_old_old*infected_population_old*susceptible_population_old
{'infected_population_young', 'immune_population_young'} gamma_young*infected_population_young
{'infected_population_old', 'immune_population_old'} gamma_old*infected_population_old
{'susceptible_population_young', 'susceptible_population_old'} p_young_old*susceptible_population_young
{'susceptible_population_old', 'susceptible_population_young'} p_old_young*susceptible_population_old
{'infected_population_old', 'infected_population_young'} infected_population_young*p_young_old
{'infected_population_old', 'infected_population_young'} infected_population_old*p_old_young
{'immune_population_old', 'immune_population_young'} immune_population_young*p_young_old
{'immune_population_young', 'immune_population_old'} immune_population_old*p_old_young |
This scenario came up during the Epi Eval Scenario 2 and the user found
Stratify
's handling of parameters undesirable and inconsistent with their expectation.I start with a simple compartmental SCRHD model (
I
renamed toC
to avoid imaginaryi
issue with sympy).I change the rate law between
C
andH
to be the productb * vaxCtoH * ageCtoH * C
based on the assumption that the vax status and age are independent demographic features.S, C
states anda, vaxCtoH
parametersb, vaxCtoH_*
vaxCtoH
correctly depends only on vax status only and (b) the parameterageCtoH
incorrectly depends on both age and vax status. The user expected thatageCtoH
to be stratified by age only.Relevant AMR files:
The text was updated successfully, but these errors were encountered: