- Setting CPLEX Parameters (October 2012)
- Printing a CP Optimizer Model in Java (March 2014)
- Setting CPLEX Parameters in Java Revisited (May 2014)
In the following description, please assume that cplex and cp are instances of IloCplex and IloCP respectively. The main reason I developed the library is that I like to experiment with different parameter settings for CPLEX and CP Optimizer. Rather than hard coding a parameter (e.g., cplex.setParameter(IloCplex.Param.Emphasis.MIP, 3)) and then having to edit and recompile the code to try a different value, I prefer to pass CPLEX and CP Optimizer parameters to the program through the command line (or, if my program has a graphical interface, through a user dialog). The equivalent code to the previous example might look like cplex.setParameter(pname, pval) where pname is a string with value "Emphasis.MIP" (the minimum portion of the full parameter name necessary to uniquely identify the parameter) and pval is a string with the value "3".
With that as background, here is a summary of the contents of the library:
- CplexParameterSetter: Use an instance of this class to apply parameter settings (each specified by two strings, parameter name and new value) to an instance of IloCplex. Example code appears in the May 2014 post (look for the version 2.0 sample).
- CPOptimizerParameterSetter: Use an instance of this class to apply parameter settings to an instance of IloCP. Again, sample code is in the May 2014 post.
- CPDisplay: The static method CPDisplay.asString(cp) will produce a summary of the model in cp, suitable for printing or displaying. For whatever reason, IloCplex.toString() produces a human-readable version of a CPLEX model, but IloCP.toString() just prints the object's hash code. This class provides a workaround. For the output to really be readable, you need to be assiduous about assigning meaningful names to the variables and constraints in the model. I originally released this (in the March 2014 post) as an override to IloCP.toString(), but I decided a static method was easier to use (does not require extending IloCP).
- Main program: The project comes with a main program. If you run it, you will get an alphabetized list of all parameters known to the versions of CPLEX and CP Optimizer that you are using. For instance, run against CPLEX Studio 12.6.1, the output I get looks like this:
CPLEX: AbsGap double IloCplex.Param.MIP.Pool.AbsGap AbsMIPGap double IloCplex.Param.MIP.Tolerances.AbsMIPGap AbsMIPGap double IloCplex.Param.MIP.PolishAfter.AbsMIPGap Advance int IloCplex.Param.Advance [...] WriteLevel int IloCplex.Param.Output.WriteLevel ZeroHalfCut int IloCplex.Param.MIP.Cuts.ZeroHalfCut CPOptimizer: AllDiffInferenceLevel int IloCP.IntParam.AllDiffInferenceLevel AllMinDistanceInferenceLevel int IloCP.IntParam.AllMinDistanceInferenceLevel [...] WarningLevel int IloCP.IntParam.WarningLevel Workers int IloCP.IntParam.Workers