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

State labels in mucalc formulas #185

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

ningit
Copy link

@ningit ningit commented Feb 10, 2020

The current syntax of mucalc formulas allows checking state propositions { s = v } where s designates an entry of the state vector and v is an integer or string value. This patch lets s refer to state labels too.

When s is not the name of a state part, it is understood as a state label and eventually checked using the GBgetStateLabelLong function. Syntactic sugar { p } has been defined for writing Boolean state labels { p = 1 }.

The changes are:

  • In pins2pins-mucalc.c,
    • mucalc_add_proposition_values looks for s as a state label in case the identifier is not a state variable. The state_idx attribute of the proposition structure can now be either the index of an entry in the state vector or the index of a state label of the original model. Since their ranges coincide, state labels are enumerated from ctx->len, the length of the state vector.
    • mucalc_long and mucalc_all check the proposition referring to a state label (i.e. state_idx >= ctx->len) using GBgetStateLabelLong.
    • GBaddMucalc sets the dependency matrices based on the original state-label-info matrix for those propositions using state labels instead of state variables.
  • In mucalc-grammar.lemon, { p } has been defined as syntactic sugar for { p = 1 }.

I have tested it with some examples and it works, but perhaps I have missed something, like the reason it had not been done before.

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 this pull request may close these issues.

1 participant