-
Notifications
You must be signed in to change notification settings - Fork 25
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
removeInitialAssignment results in many variables changing #1195
Comments
The way things are supposed to work is that if you have two initial assignments: a = b+2 and then you set init(b) to 4, a will change to 6, because its initial assignment is still 'b+2'. Is that what you're seeing? Or is something else going on? |
yup that makes sense, and I also see that behavior. my issue is more like this: model definition:
change initial concentrations:
results in: |
Well, that's probably a bug, then! Can you provide a working example? A large one is fine if that's what you have. |
Did this ever get addressed? Looking at this again, there's another obvious-in-retrospect thing that could be happening: when 'conserved moieties' are on, that means that Roadrunner has detected a reaction network where (say) the total S1+S2 is constant, so if you change S1, you already know what S2 is going to be; you just decrease it by the same amount you increased S1 by. So if that's active, that would explain why a change in C12214 means that v275 also changes. Happily, you can turn that off! r.conservedMoietyAnalysis = False You can also check the current status of the flag: print(r.conservedMoietyAnalysis) |
One issue seems to be understanding when initial assignments are evaluated and how to properly retrigger their evaluation. From my understanding, initial assignments are evaluated during model import. If you modify variables or parameters that influence these initial assignments, you typically need to run a reset or resetAll on the model to trigger their reevaluation. For further clarification, this discussion provides helpful insights into how updates are handled. Essentially, running a reset seems to be required to propagate any changes. I’ve never been able to fully determine the correct way to handle this in libRoadRunner, so I’ve adopted the approach of using assignment rules for everything. While this introduces some computational overhead—since assignment rules are reevaluated at every time step—it provides much clearer behavior. Additionally, the mathematical dependencies are automatically updated at every step, so there’s no need for manual reevaluation. If your model integrates quickly, switching to assignment rules is a straightforward solution for most issues with initial assignments. Another challenge with initial assignments is that many tools discard them upon model import. In such cases, initial assignments are evaluated numerically during import and are no longer part of the model. This means some tools do not support what you’re attempting to achieve, as the initial assignments simply don’t exist in the loaded model. This limitation makes it challenging to reproduce simulation experiments that rely on initial assignments. |
Context
I have a model with many InitialAssignments, such as
C12214= v1*0.001*dilution_factor
whereC12214
is a species andv1
anddilution_factor
are variables. In some instances, I'd like to override the InitialAssignment and set the species concentration to a fixed value, sayC12214= 1.0
.Issue
I'm looping through the variables and species initial concentrations that I want to override and calling
r.setValue('init('+var+')', new_value)
. Everything works as expected when setting variables, but when setting species initial concentrations other variables in the model are changing as well. This happens regardless of which species I'm changing, and it always affects the same variables. The issue seems to be withr.removeInitialAssignment()
Workaround
Setting the concentration,
r.setValue('['+var+']', new_value)
, as opposed to the initial concentration works as expected. In this case I don't need to change the initial concentration so this is okay.The text was updated successfully, but these errors were encountered: