Skip to content
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

Add add_observable function with a concept pattern #362

Closed
bgyori opened this issue Sep 11, 2024 · 2 comments · Fixed by #364
Closed

Add add_observable function with a concept pattern #362

bgyori opened this issue Sep 11, 2024 · 2 comments · Fixed by #364

Comments

@bgyori
Copy link
Member

bgyori commented Sep 11, 2024

Per a suggestion from @liunelson, we should implement a function along the lines of

def add_observable(template_model, name, concept_pattern):
    # Find all concepts that match or are refinements of the concept pattern
    # Create an Observable which is a sum of all the above Concepts with the name provided as the input parameter
    # Add the Observable to the template model

This could be implemented as a standalone function or a method of the TemplateModel class.

@liunelson
Copy link

A use case from which my suggestion originated is as follows:

  • I start with a basic SIR compartmental model
  • I stratify the state vars S, I, beta by vaccination status u, v
  • The model now has states S_u, S_v, I_u, I_v, R and parameters beta_u_u, beta_u_v, beta_v_u, beta_v_v, gamma
  • I stratify it again, on the state vars S_*, I_* by age group y, o and location us, eu
  • The new state vars are X_i_j_k where X = S, I, i = u, v, j = y, o, k = us, eu
  • I'm asked to do some model configuration checks on the sums of the state vars; for example, the total unvaccinated population should never increase; however, it is very tedious to type in every expression and add them as new observables.
  • These new observables could be:
    N = \sum_{X, i, j, k} X_i_j_k (total population)
    N_XX = \sum_{X, i, j, k} X_i_j_k * kroneckerdelta_{X, XX} (e.g. N_S total susceptible population)
    N_ii = \sum_{X, i, j, k} X_i_j_k * kroneckerdelta_{i, ii} (e.g. N_u total unvaccinated population)
    N_jj = \sum_{X, i, j, k} X_i_j_k * kroneckerdelta_{j, jj} (e.g. N_o total old population)
    N_XX_ii = \sum_{X, i, j, k} X_i_j_k * kroneckerdelta_{X, XX} kroneckerdelta_{i, ii}(e.g.N_S_u total unvaccinated susceptible population) ... repeating for each stratum group (u, v, y, o, ...`) and stratum (disease status, vacc status, age group, location) combination...

@bgyori
Copy link
Member Author

bgyori commented Sep 18, 2024

In #364 I implemented the ability to very easily add observables by pattern e.g., "total old population" or "total susceptible population" irrespective of how many distinct compartments these are divided into.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants