Tuning CPLEX options from within AIMMS

The CPLEX solver has a large amount of options that influence the way CPLEX solves your model. For certain types of constraints and/or models, you can make an educated guess which combination of options works best for your problem. Unfortunately, this is not always the case.

To help you out with this problem, CPLEX has the possibility to do some automatic tuning of the options. In AIMMS, you can access this CPLEX tuning tool via the following two functions:

  • GMP::Tuning::TuneMultipleMPS
  • GMP::Tuning::TuneSingleGMP

As the names already suggest, the first function will tune the CPLEX options for a set of LP/MPS files. As an argument, you will have to specify the directory containing the LP/MPS files. The second function will tune the options based on one single GMP, which you will have to provide as an argument. As the GMP::Tuning::TuneSingleGMP works as the other GMP function, the solver to use is known. In case of the function GMP::Tuning::TuneMultipleMPS, you must also provide which solver to use as an argument.

In order to create the MPS files for multiple instances of your problem, you can set the project setting General > MPS under the CPLEX specific solver options to “At every solve”. Each time that you solve an instance of your problem, the solver will generate a MPS file.

The rest of the options that you need to provide are the following three:

  • FixedOptions: A subset of the set AllOptions that are to be considered unchangeable and for which the current project options will be used
  • ApplyTunedSettings: A binary argument indicating whether the found tuned option settings should be set in the project options
  • OptionFileName: File to which the tuned option settings should be written. This file can be imported in the Project Options screen.

To use these functions, we first need the following declarations:

SET:
   identifier : FixedOptions
   subset of  : AllOptions
 
ELEMENT PARAMETER:
   identifier :  genMathProgram 
   range      :  AllGeneratedMathematicalPrograms

To actually tune the solver settings, you can use the following code:

 
!Determine which options we consider to be unchangable by CPLEX
!It will use the current value for this setting in the project options.
!As an example, we will forbid the tuning of the setting mip_search_strategy.
FixedOptions := { ’CPLEX 12.3::mip_search_strategy’ } ;
 
 
!First create the GMP out of the Math Program
genMathProgram := GMP::Instance::Generate( MP );
!Then call the TuneSingleGMP function, which will try to find a good
!combination of settings for the solver options for this instance.
!The settings that are in the set FixedOptions will not be considered
!for tuning.
!The found settings will be applied directly in the project settings
!and also will be written to the file "tuned_options_gmp.opt"
gmp::Tuning::TuneSingleGMP(
   GMP                : genMathProgram , 
   FixedOptions       : FixedOptions , 
   ApplyTunedSettings : 1 , !Save found settings directly in project
   OptionFileName     : "tuned_options_gmp.opt" ) ; !Store found settings in this file
 
 
 
!This call will try to find a combination of settings for
!the solver options that are good for the set of MPS/LP files that 
!are found in the subdirectory mps-files in the directory of 
!the project. 
!The settings that are in the set FixedOptions will not be considered
!for tuning.
!The found settings will be applied directly in the project settings
!and also will be written to the file "tuned_options_gmp_mps.opt"
gmp::Tuning::TuneMultipleMPS(
   DirectoryName      : "mps-files" , ! location of mps files, relative to project 
   Solver             : 'CPLEX 12.3' ,! Which solver to use, in this case CPLEX 12.3 
   FixedOptions       :  FixedOptions , !Consider these options unchangable. 
   ApplyTunedSettings :  1 , !Save found settings directly in project 
   OptionFileName     : "tuned_options_gmp_mps.opt" ) ;  !Store found settings in this file

Please note that you must always be careful when you are tuning: you must always ensure that you have one or more instances that are a good representation of all possible instances. If the instances you are tuning are not representative for all possible instances, you will over tune to one specific instance. This might lead to worse performances with the tuned settings for all instances combined.

Related posts:

  1. Improve performance of for loop containing if-then statement
  2. Using block statement to temporary use other project settings

About Guido Diepen

Guido has been working at AIMMS since August 2008. He is part of the Professional Services team that helps customers getting the most out of AIMMS for their problems. His background is Integer Linear Programming and he is now also looking more at Constraint Programming.
This entry was posted in Advanced, Technical and tagged , , , . Bookmark the permalink.

Facebook comments

One Response to Tuning CPLEX options from within AIMMS

  1. Ming says:

    I would like to add one of example projects, MPS File Functions, which comes with AIMMS standard installation demonstrating the usage of Tuning function. In this example, you can simply upload your existing MPS file, and then solve or tune it.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">