IBM Support

Stop CPLEX optimization run and resume it at a later time

Question & Answer


Question

How can I stop a CPLEX optimization run and resume it at a later time from the point where it left off?

Answer

With the Interactive Optimizer, pressing Ctrl-C at any time will interrupt an on-going optimization. If you are using the Callable Library or Concert Technology, you can use callbacks to check for the desired conditions and to interrupt the on-going optimization. In addition, all interfaces to CPLEX allow the user to specify a time limit, an iteration limit for barrier and simplex algorithms, and a node limit for the branch and cut algorithm. When any set limit is reached, the optimization algorithm stops.

To resume an optimization from where it left off without quitting CPLEX, simply execute the same command or call the same function that was used to launch the initial optimization. CPLEX will continue from where it left off assuming that no changes to the problem were made in between.

How to resume the optimization from where it left off after quitting CPLEX depends on the algorithm that was running:

  • When you are using any of the simplex algorithms, the basis corresponding to the original problem can be saved to a file before quitting CPLEX. That file can then be reloaded after restarting CPLEX and reloading the problem. Launching the same simplex algorithm will then make CPLEX resume the optimization as follows:
    • If the advance start indicator is set to 1, CPLEX will resume the optimization without presolve because the saved basis corresponds to the original problem. This setting may result in an undesirable slowdown of the optimization, particularly if presolve made significant reductions to the problem. This setting will probably work better when presolve doesn't make significant reductions to the model.
    • If the advance start indicator is set to 2, CPLEX will use the basis to construct the associated solution, translate that solution to the presolved model, then construct a basis for the presolved model from that translated solution. Note that this translated basis may not match the one at the time the optimization was interrupted. This setting will probably work better when presolve does significantly reduce the model.
    The commands to save and read the basis in the interactive optimizer are write filename.bas and read filename.bas respectively, where the bas extension indicates to CPLEX to write and read a basis. If you are using the Callable Library, the routines are CPXmbasewrite and CPXreadcopybase. In Concert, the corresponding methods are IloCplex::writeBasis and IloCplex::readBasis. In MATLAB, the corresponding functions are cplex.writeBasis and cplex.readBasis. You can also use SOL files to save and read solutions for the simplex method. CPLEX will use the solutions to construct a basis. However, in general the basis information in a basis file provides a more precise advanced start, so you should only consider using SOL files when basis information is not available.
  • It is not possible to resume the barrier algorithm where it left off. However, it is possible to save the primal and dual variable values and their associated reduced cost and dual values in a VEC format file. That file can then be loaded after restarting CPLEX and reloading the problem. Launching any of the simplex optimizers then causes CPLEX automatically to invoke crossover and resume using simplex. The commands to save and read the VEC format file in the Interactive Optimizer are write filename.vec and read filename.vec respectively. If you are using the Callable Library, the routines are CPXvecwrite and CPXreadcopyvec. In Concert, the corresponding methods are IloCplex::writeVectors and IloCplex::readVectors.
  • When you are solving a MIP, you can save the current incumbent solution (if one exists) in an MST file, and use that solution as a starting point when you rerun the optimization. This approach won't make CPLEX resume from where it left off. However, CPLEX may perform better with this information than if it could have resumed with the actual branch and bound tree from where it left off. The starting point immediately establishes a cutoff value that can enable additional MIP preprocessing and pruning that was unavailable to the initial optimization. The commands to save and read the MST format file in the Interactive Optimizer are write filename.mst and read filename.mst respectively. If you are using the Callable Library, the routines are CPXmstwrite and CPXreadcopymipstart. In Concert, the corresponding methods are IloCplex::writeMIPStart and IloCplex::readMIPStart. In MATLAB the corresponding functions are cplex.writeMIPStart and cplex.readMIPStart. You can also make use of SOL files to provide a starting point for rerunning the optimization. Like MST files, SOL files contain XML formatted information. Unlike MST files, SOL files contain solution values for all variables rather than just the variables needed to define the integer feasible solution. SOL files are thus larger, take longer to input, and in unusual cases of numerically difficult models are less likely to provide a feasible starting point. So, in general, we recommend using MST files to restart the optimization instead of SOL files. However, if you already use SOL files for other purposes, you can also use them to provide a feasible starting point. The commands to save and read the SOL format file in the Interactive Optimizer are write filename.sol and read filename.sol respectively. If you are using the Callable Library, the routines are CPXsolwrite and CPXreadcopysol. In Concert, the corresponding methods are IloCplex::writeSolution and IloCplex::readSolution.

[{"Product":{"code":"SSSA5P","label":"IBM ILOG CPLEX Optimization Studio"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Not Applicable","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF022","label":"OS X"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"9.2;9.1.3;9.1.2;9.1;9.0;12.5;12.4;12.3;12.2;12.1;12.0;11.2.1;11.2;11.1.1;11.1;11.0.1;11.0;10.3;10.2.1;10.2;10.1.1;10.1;10.0","Edition":"All Editions","Line of Business":{"code":"LOB10","label":"Data and AI"}},{"Product":{"code":"SSSA5P","label":"IBM ILOG CPLEX Optimization Studio"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"General","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF017","label":"Mac OS"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"12.5;12.4;12.3;12.2.0.1;12.2","Edition":"All Editions","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Historical Number

cplex/FAQ/97

Document Information

Modified date:
16 June 2018

UID

swg21400014