Forum Discussion

FICO's avatar
FICO
Community Manager
3 years ago

Execute multiple runs without reloading the optimizer

Dear support,

We would like to be able to run a large amount of optimization problems that are very similar among them.

Ideally we would like to avoid loading the data, building the model, loading Xpress on and on.

Is there a way of doing so using Xpress? I was thinking using callbacks every time a solution is found that first saves the current results, then waits for updated values, uses them to marginally modify the optimization problem (RHS mainly) and finally calculates new results.

Is there any relevant limitation? I was thinking that maybe presolve is not an option here, and that both problems should have exactly the same constraints. We believe the savings can be large as we are not only avoiding many processes to be repeated but we are also warm starting the problem.

Any suggestion on how to achieve this?

Thank you,

1 Reply

  • FICO's avatar
    FICO
    Community Manager

    You cannot modify the problem from within a callback (that would potentially invalidate presolve and many other things).

    Instead you should solve your problem and once the optimize() call returns you can modify the problem, for example via XPRSchgrhs(), XPRSchgmcoef() or XPRSchgobj(). Then you can optimize() the modified problem.

    Some things to consider for this approach:

    • You can stop optimization from within a callback by means of XPRSinterrupt().
    • You can also use things like MIPRELSTOP,MIPABSSTOP, MAXMIPSOL, ... to stop the solution process before optimality is proven.
    • If the optimize() call returns before proving optimality or infeasiblity, then your problem will be in a presolved state and you will have to call XPRSpostsolve() to get it back into the original state in which you can then modify it. Actually, in your scenario I suggest to just always call XPRSpostsolve() after optimize() returned (it will be a no-op if the problem is not in presolved state).
    • You may want to transfer solutions from one problem to the other by means of XPRSaddmipsol(). Even if the old solution is (slighty) infeasible in the new problem, this may help Xpress to find a first feasible solution faster. Whether transferring solutions can help depends on your actual problem, so you will have to conduct performance experiments to assess whether this is useful or not in your case.