V. Brunelle
V. Brunelle

Reputation: 1068

Initialize and warmstart parameters on Pyomo

If we initialize a variable model.x at a specific value (i.e. model.x = 1) before solving the model, do we need to have warmstart=True as parameter for the call of Pyomo's solve() method in order to keep those initial values for the optimization?

Keep in mind that an initialized variable should not be forced to take the specified value, it only provides the variable with an initial starting value and then the solver will change it if needed.

Upvotes: 1

Views: 2940

Answers (1)

Gabe Hackebeil
Gabe Hackebeil

Reputation: 1436

For now, it depends on the solver interface.

If you are using a solver through the NL-file interface (e.g., AMPL solvers), then initial variable values are always supplied to the solver (if they are not None), and it is up to the solver whether or not it attempts to use those values as a warmstart (e.g., for a MIP) or an initial iterate (e.g., for solvers that are using an optimization method that requires a starting point). For solvers that require a starting point, it is also up to the solver what value will be used for any variables that are not supplied a starting point. Often times zero is used, but this may vary between solvers.

For all other Pyomo solver interfaces (e.g., LP, MPS, Python), which mainly correspond to MIP solvers, I believe the default behavior is to not supply a warmstart. You have to specify warmstart=True when you call solve to have initial values communicated to the solver.

I do not find this consistent, mainly because when going through the the NL-file interface, the solve method does not even accept the warmstart keyword, so you have to have an if-statement when writing some general code that works with multiple interfaces.

I think I'll save further discussion for the GitHub issue.

Upvotes: 1

Related Questions