Reputation: 199
I have a model in Pyomo which I rerun many times with different data. There is no addition of new constraints or variables, only the data (values of the coefficients in the expressions) are changed between runs. Currently, in each run I rebuild the model with the new values. This implies in an overhead, since the model is rebuilt every time. How can I rerun the model without having to rebuild it every time?
Upvotes: 2
Views: 839
Reputation: 2828
Declare any data in your model that you wish to change as mutable parameters:
m = ConcreteModel()
m.p = Param(initialize=5, mutable=True)
Then you can just update the values of those parameters without needing to rebuild the model:
m.p = 10
Upvotes: 4