Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I run a model multiple times changing the parameter value in pyomo?

I am working with a MIP model with multiple parameters and I’d like to test different scenarios (with different parameter values).

I’ve created a df with the parameter values that need to be changed and did a loop where the values are supposed to change but they are not.

for s in model.s:
model.Pmill == model.Smill[s].value

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You want to use = instead of ==.

One equals assigns a value, while two values compare.
What your code does is just comparing both values every iteration without using the result.

for s in model.s:
    model.Pmill = model.Smill[s].value
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading