2
$\begingroup$

I am currently new to pyomo and modelling techniques but I came across information mentioning that the CPLEX and Gurobi APIs offer a functionality where you can re-use already computed values and feed them before solving the same model again. It should be useful when performing several similar computations where information from already computed models can be re-used to optimize new computations.

Is someone aware of such functionality?

$\endgroup$

1 Answer 1

2
$\begingroup$

What you are looking for is called warm starting. In the Pyomo documentation you can find more information on this.

Quoting directly from the manual:

Some solvers support a warm start based on current values of variables. To use this feature, set the values of variables in the instance and pass warmstart=True to the solve() method. E.g.,

instance = model.create()
instance.y[0] = 1
instance.y[1] = 0

opt = pyo.SolverFactory("cplex")

results = opt.solve(instance, warmstart=True)
$\endgroup$
4
  • 1
    $\begingroup$ Thank you very much! Was exactly what I was looking for. Is there a way where I can specify what to feed or enabling the option does the magic? $\endgroup$
    – Pia MiA
    Nov 9, 2022 at 19:48
  • 1
    $\begingroup$ The idea is, that you know values for the variables, which may constitute a feasible and hopefully good solution - perhaps from a previous run. Let the known solution be stored in e.g. a list xVal and the variables be x. Then you do something like for i, val in enumerate(xVal): instance.x[i]=val and call Solve with the option warmstart set to True. $\endgroup$
    – Sune
    Nov 9, 2022 at 20:55
  • $\begingroup$ So I found that warmstarting actually feeds only the solution to the problem whereas there are some more complex optimisation techniques which involve passing addition information that was calculated from previous computations before re-solving. The CPLEX api offers this functionality. Is there an equivalent in pyomo? $\endgroup$
    – Pia MiA
    Nov 23, 2022 at 0:46
  • $\begingroup$ @PiaMiA I am not sure about this. But I am inclined to say no. When you use the API provided by cplex, the model and solver is "kept alive" after solving the model, so when you resolve, everything the solver learned during the previous solve is utilized (if it makes sense). As I understand it, pyomo writes the problem to an .lp file, and then asks cplex to solve this problem. Hence, no info is stored when resolving $\endgroup$
    – Sune
    Nov 23, 2022 at 5:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.