0
votes

Colleagues and I are building an optimization model using Pyomo and are trying to reuse the sample concrete model to solve several instances. There are two types of changes in the instances: (1) change in the constraints; and (2) change in the number of decision variables (to coincide with the constraints).

While I have found deactivate/activate for constraints, I have not been able to find how to change the number of decision variables within a model between calls to a solver. Any help would be greatly appreciated.

Regards, Mark

1

1 Answers

1
votes

The equivalent for variables to the activate/deactivate for constraints is the fix/unfix method.

For instance, model.X.fix(0) to fix the variable to a value of 0 (essentially rendering it a non-decision variable). To unfix it, simply write model.X.unfix().