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

removeInitialAssignment results in many variables changing #1195

Open
dalbabur opened this issue Mar 11, 2024 · 3 comments
Open

removeInitialAssignment results in many variables changing #1195

dalbabur opened this issue Mar 11, 2024 · 3 comments

Comments

@dalbabur
Copy link

dalbabur commented Mar 11, 2024

Context
I have a model with many InitialAssignments, such as C12214= v1*0.001*dilution_factor where C12214 is a species and v1 and dilution_factor are variables. In some instances, I'd like to override the InitialAssignment and set the species concentration to a fixed value, say C12214= 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 with r.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.

@luciansmith
Copy link

The way things are supposed to work is that if you have two initial assignments:

a = b+2
b = c+3
c = 5

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?

@dalbabur
Copy link
Author

yup that makes sense, and I also see that behavior. my issue is more like this:

model definition:

C12214= v1*0.001*dilution_factor
...
C00356= v275*0.002*dilution_factor
v1 = 876
v275 = 756
dilution_factor = 1 

change initial concentrations:

r.setValue('init([C12214])', 3.0)

results in:
r['init([C12214])'] = 3.0 and suddenly r['v275'] = 1

@luciansmith
Copy link

Well, that's probably a bug, then! Can you provide a working example? A large one is fine if that's what you have.

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

No branches or pull requests

2 participants