Search code examples
pythonpyomogurobi

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

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