Tuning the Optimizer
Xpress Optimizer solves optimization problems by applying a number of algorithms and techniques, such as cutting planes, heuristics, branch and bound search, etc. These internal algorithms are user customizable through control parameters.
Solver tuning helps the user to identify a favorable set of control parameters that allow the Xpress Optimizer to solve a particular problem (or a set of problems) faster than by using defaults.
Xpress Optimizer has a built-in tuner that can be used through different APIs on all supported platforms.
The Xpress Optimizer built-in tuner
The Xpress Optimizer built-in tuner works with LP and MIP problems, and when Xpress Nonlinear is available it can also work with SLP and MISLP problems. The tuner will solve the problem with its default baseline control settings and then solve the problem mutiple times with each individual control and certain combinations of these controls. As the tuner works by solving a problem mutiple times, it is important and recommended to set time limits. Setting MAXTIME will limit the effort spent on each individual solve and setting TUNERMAXTIME will limit the overall effort of the tuner.
A tuner run produces detailed log files (by default located under the subdirectory tuneroutput of the working directory) and also displays a summary progress log.
The tuner works on an optimization problem loaded into the Optimizer or alternatively it can be launched on a set of matrices in LP or MPS format. The tuning process can be customized by providing pre-defined lists of controls, so-called factory tuner methods, and through various output and tuning target settings—the reader is referred to the section Using the Tuner of the ``Xpress Optimizer Reference Manual'' for further detail.
Applying the tuning results
Copy the control parameter settings of the best strategy into your model or program. Note that any solver parameters need to be set before starting the optimization.
»Scenario 1 (Mosel)
The tuner can be launched for a specific optimization problem directly from within a Mosel model by adding the option XPRS_TUNE to the optimization routine call (see the example in file examples\getting_started\Mosel\foliolptune.mos):
minimize(XPRS_TUNE, MinCost) maximize(XPRS_TUNE+XPRS_LIN, TotalProfit)
Note that the Optimizer output display (parameter XPRS_VERBOSE) needs to be enabled in order to see the tuner progress log displayed.
Applying the tuning results
Any parameter settings need to be made before the call to the solution algorithm. Prefix the parameter name with XPRS_ to obtain its Mosel name:
setparam("XPRS_PRESOLVE", 0)Alternatively, define parameter settings as a system command (requires module mmsystem):
command("PRESOLVE=0")
Xpress Workbench
If you are using Xpress Workbench for working with Mosel models, you can employ the option XPRS_TUNE to the optimization routine in the Mosel source as described above, or alternatively select the 'Tools' button to open the Run Options Dialog window where you can configure the run mode Tune the Model to tune the last optimization problem specified within a model. The summary tuner result files (file with extension .xtr in the tuner log output directory) can be opened in the Workbench editor:

Figure 1: Tuner results display in Xpress Workbench
The displayed lines representing individual tuner runs can be re-ordered by clicking on the column headers. By selecting the copy link in any line of the summary file Workbench opens a message box showing how to apply the corresponding parameter settings in the Mosel model :

Figure 2: Applying tuner results to a Mosel model
»Scenario 2 (BCL)
After loading the problem from BCL into the solver, you can use the Xpress Optimizer API functions to set solver controls and start the tuning for this problem.
- BCL C++:
XPRSprob optprob; XPRBprob bclprob("MyProb"); // Initializes BCL and Optimizer bclprob.loadMat(); optprob = bclprob.getXPRSprob(); // Retrieve the Optimizer problem XPRSsetintcontrol(optprob, XPRS_MAXTIME, 60); // Set a time limit XPRStune(optprob, ""); // Start the tuning
- BCL Java:
XPRBprob bclprob; XPRSprob optprob; bcl = new XPRB(); // Initialize BCL bclprob = bcl.newProb("MyProb"); // Create a BCL problem XPRS.init(); // Initialize Xpress Optimizer optprob = bclprob.getXPRSprob(); // Retrieve the Optimizer problem optprob.setIntControl(XPRS.MAXTIME, 60); // Set a time limit optprob.tune(""); // Start the tuning
Applying the tuning results
You need to retrieve the Xpress Optimizer problem associated with the BCL problem to be able to modify its control parameter settings as shown for the 'MAXTIME' control in the code snippets above.
»Scenarios 3 and 4 (Optimizer)
With a loaded problem, the built-in tuner can be started by calling TUNE from the Optimizer console, or XPRStune from a user application. The Xpress Optimizer API also provides routines for managing tuner methods.
Optimizer Python interface: After loading the problem file into a Python object, use the Xpress Optimizer API functions to set solver controls and start the tuning for this problem.
import xpress as xp p = xp.problem() p.read('foliolp.mps') # reads MPS file into the problem p.chgobjsense(sense=xp.maximize) p.controls.maxtime=60 p.tune(flags='l') # specify flag 'l' (optional)
At the command prompt, the following sequence of commands can be used to tune an LP problem that is provided in the form of an MPS matrix in the file foliolp.mps:
optimizer foliolp readprob chgobjsense max maxtime=60 tune -l quit
Applying the tuning results
With the Optimizer console, you can modify control parameter settings as shown for the 'MAXTIME' control in the command listing above. From an application program you need to use one of the Optimizer API routines XPRSsetdblcontrol / XPRSsetintcontrol / XPRSsetstrcontrol depending on the parameter type.
Further information
- Xpress Optimizer: ``Xpress Optimizer Reference Manual'', Section 5.10 `Using the Tuner'
- Python: see examples in the ``Python interface manual'', Chapter 6