NOTICE: developerWorks Community will be offline May 2930, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
Pinned topicMIP tuning tool only runs for a few seconds in MATLAB CPLEX API
20130221T03:35:52Z

Answered question
This question has been answered.
Unanswered question
This question has not been answered yet.
I've been trying to use the tuning tool to improve CPLEX's performance on an MIP. In this case, the MIP is 895 rows and 456 columns
As described in the manual, I typically set
LP.Param.timelimit = 1800
and sometimes I even set
LP.Param.tune.timelimit.Cur = 1800.
However, the tuning itself always takes less than 10 seconds. Does anyone know why? I've posted a copy of the output below.
Tuning on problem
'CPLEX' Test
'dual': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 69% Test
'primal': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 81% Test
'barrier': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 90% Test
'network': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 94% Test
'primal_devex': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 96% Test
'primal_partial': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 98% Test
'primal_steep': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 99% Test
'simplex_perturb': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Default test: Time = 0.00 sec. Best test:
'dual' Time = 0.00 sec. 134 end >> GetTuningParameters Tuning on problem
'CPLEX' Test
'dual': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 73% Test
'primal': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 84% Test
'barrier': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 92% Test
'network': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 95% Test
'primal_devex': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 97% Test
'primal_partial': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 98% Test
'primal_steep': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 99% Test
'simplex_perturb': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Default test: Time = 0.00 sec. Best test:
'dual' Time = 0.00 sec.
I've been trying to use the tuning tool to improve CPLEX's performance on an MIP. In this case, the MIP is 895 rows and 456 columns
However, the tuning itself always takes less than 10 seconds. Does anyone know why? I've posted a copy of the output below.
<pre class="jivepre">
Tuning on problem
'CPLEX' Test
'dual': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 69% Test
'primal': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 81% Test
'barrier': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 90% Test
'network': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 94% Test
'primal_devex': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 96% Test
'primal_partial': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 98% Test
'primal_steep': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 99% Test
'simplex_perturb': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Default test: Time = 0.00 sec. Best test:
'dual' Time = 0.00 sec. 134 end >> GetTuningParameters Tuning on problem
'CPLEX' Test
'dual': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 73% Test
'primal': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 84% Test
'barrier': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 92% Test
'network': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 95% Test
'primal_devex': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 97% Test
'primal_partial': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 98% Test
'primal_steep': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Tuning progress: 99% Test
'simplex_perturb': Optimal. Time = 0.00 sec. (0.00 ticks) Objective = 0 Default test: Time = 0.00 sec. Best test:
'dual' Time = 0.00 sec.
</pre>
From the output it looks like the problem instance you are using for tuning is just too easy: CPLEX always solves the problem to optimality in almost no time  so there is not much that can be tuned.
Does the same happen if you solve the problem instance without the tuning tool?
No unfortunately. For some reason the tuning yields an optimal value of 0 for the MIP. However when I use the LP.solve command (before and after the tuning tool), the MIP solves to a value of about 0.18. I'm pasting the first few lines of the output from LP.solve. I'd also be happy to send over the problem instance if required.
LP.solve Tried aggregator 2 times. MIP Presolve eliminated 1 rows and 1 columns. MIP Presolve modified 24971 coefficients. Aggregator did 1 substitutions. Reduced MIP has 1947 rows, 980 columns, and 13499 nonzeros. Reduced MIP has 967 binaries, 13 generals, 0 SOSs, and 0 indicators. Presolve time = 0.08 sec. (135.47 ticks) Found incumbent of value 0.554033 after 0.08 sec. (137.70 ticks) Probing fixed 0 vars, tightened 6 bounds. Probing time = 0.01 sec. (8.94 ticks) Tried aggregator 1 time. Presolve time = 0.01 sec. (3.58 ticks) Probing time = 0.00 sec. (1.91 ticks) Clique table members: 8. MIP emphasis: balance optimality and feasibility. MIP search method: dynamic search. Parallel mode: none, using 1 thread. Root relaxation solution time = 0.07 sec. (91.51 ticks) Nodes Cuts/ Node Left Objective IInf Best Integer Best Bound ItCnt Gap * 0+ 0 0.5540 0.0000 957 100.00% 0 0 0.0001 858 0.5540 0.0001 957 99.98% * 0+ 0 0.4872 0.0001 957 99.97% Repeating presolve. Tried aggregator 1 time. MIP Presolve eliminated 544 rows and 272 columns. Reduced MIP has 1403 rows, 708 columns, and 9691 nonzeros. Reduced MIP has 695 binaries, 13 generals, 0 SOSs, and 0 indicators. Presolve time = 0.01 sec. (5.24 ticks) Probing time = 0.00 sec. (1.33 ticks) Tried aggregator 1 time. Presolve time = 0.00 sec. (2.57 ticks) Represolve time = 0.02 sec. (9.98 ticks) Probing time = 0.00 sec. (1.33 ticks) MIP emphasis: balance optimality and feasibility. MIP search method: dynamic search. Parallel mode: none, using 1 thread. Root relaxation solution time = 0.04 sec. (43.46 ticks) Nodes Cuts/ Node Left Objective IInf Best Integer Best Bound ItCnt Gap * 0+ 0 0.4872 0.0001 1643 99.97% 0 0 0.0001 593 0.4872 0.0001 1643 99.97% * 0+ 0 0.4590 0.0001 1643 99.97% 0 2 0.0001 593 0.4590 0.0001 1643 99.97% Elapsed time = 0.43 sec. (549.17 ticks, tree = 0.00 MB, solutions = 3)
No unfortunately. For some reason the tuning yields an optimal value of 0 for the MIP. However when I use the LP.solve command (before and after the tuning tool), the MIP solves to a value of about 0.18. I'm pasting the first few lines of the output from LP.solve. I'd also be happy to send over the problem instance if required.
<pre class="jivepre">
LP.solve Tried aggregator 2 times. MIP Presolve eliminated 1 rows and 1 columns. MIP Presolve modified 24971 coefficients. Aggregator did 1 substitutions. Reduced MIP has 1947 rows, 980 columns, and 13499 nonzeros. Reduced MIP has 967 binaries, 13 generals, 0 SOSs, and 0 indicators. Presolve time = 0.08 sec. (135.47 ticks) Found incumbent of value 0.554033 after 0.08 sec. (137.70 ticks) Probing fixed 0 vars, tightened 6 bounds. Probing time = 0.01 sec. (8.94 ticks) Tried aggregator 1 time. Presolve time = 0.01 sec. (3.58 ticks) Probing time = 0.00 sec. (1.91 ticks) Clique table members: 8. MIP emphasis: balance optimality and feasibility. MIP search method: dynamic search. Parallel mode: none, using 1 thread. Root relaxation solution time = 0.07 sec. (91.51 ticks) Nodes Cuts/ Node Left Objective IInf Best Integer Best Bound ItCnt Gap * 0+ 0 0.5540 0.0000 957 100.00% 0 0 0.0001 858 0.5540 0.0001 957 99.98% * 0+ 0 0.4872 0.0001 957 99.97% Repeating presolve. Tried aggregator 1 time. MIP Presolve eliminated 544 rows and 272 columns. Reduced MIP has 1403 rows, 708 columns, and 9691 nonzeros. Reduced MIP has 695 binaries, 13 generals, 0 SOSs, and 0 indicators. Presolve time = 0.01 sec. (5.24 ticks) Probing time = 0.00 sec. (1.33 ticks) Tried aggregator 1 time. Presolve time = 0.00 sec. (2.57 ticks) Represolve time = 0.02 sec. (9.98 ticks) Probing time = 0.00 sec. (1.33 ticks) MIP emphasis: balance optimality and feasibility. MIP search method: dynamic search. Parallel mode: none, using 1 thread. Root relaxation solution time = 0.04 sec. (43.46 ticks) Nodes Cuts/ Node Left Objective IInf Best Integer Best Bound ItCnt Gap * 0+ 0 0.4872 0.0001 1643 99.97% 0 0 0.0001 593 0.4872 0.0001 1643 99.97% * 0+ 0 0.4590 0.0001 1643 99.97% 0 2 0.0001 593 0.4590 0.0001 1643 99.97% Elapsed time = 0.43 sec. (549.17 ticks, tree = 0.00 MB, solutions = 3)
</pre>
That is strange. Your problem is a MIP, yet the output of the tuning tool suggests that you were tuning a plain LP. Are you sure you don't change the model type?
How exactly do you invoke the tuning tool? Did you change any parameter settings other than the time limits? Does the problem persist if you do not change any of the time limits?
The problem persists whether I change the time limits or not. As a matter of fact, the problem persists even if I do not change of the parameter settings after building the model (at the same point, solve would yield at previous output). I am sure that I do not change the model type either.
OK, that is weird and sounds like a potential bug.
Could you please attach your model and maybe also show the relevant parts of your code? If you don't want to disclose that here you may send it directly me: daniel(dot)junglas(at)de(dot)ibm(dot)com
What CPLEX and matlab version do you use? What operating system?
It seems as if invoking the tuning function immediately after setting up the MIP yields an error (as shown above, the tuning function thinks that the MIP is an LP). That said, if I first solve the MIP and then call the tuning function then it seems to behave as it should.
I am attaching a MAT file which contains my model file. Right now I'm running CPLEX 12.5 on MATLAB 2011b and Mac OS X 10.8.2. The code to run this example is shown below:
data = load('tuning_error.mat')
Model = data.Model;
%setup CPLEX Model
MIP = Cplex();
MIP.Model = Model;
%Call the tuning function (DOES NOT WORK)
MIP.tuneParam;
%Solve the MIP (DOES WORK)
MIP.Param.timelimit.Cur = 30; %
MIP.solve;
%Note: after solving once, the tuning function appears to work as it should
MIP.tuneParam;
OK some progress.
It seems as if invoking the tuning function immediately after setting up the MIP yields an error (as shown above, the tuning function thinks that the MIP is an LP). That said, if I first solve the MIP and then call the tuning function then it seems to behave as it should.
I am attaching a MAT file which contains my model file. Right now I'm running CPLEX 12.5 on MATLAB 2011b and Mac OS X 10.8.2. The code to run this example is shown below:
<pre class="java dw" dataeditorlang="java" datapbcklang="java" dir="ltr">data = load('tuning_error.mat')
Model = data.Model;
%setup CPLEX Model
MIP = Cplex();
MIP.Model = Model;
%Call the tuning function (DOES NOT WORK)
MIP.tuneParam;
%Solve the MIP (DOES WORK)
MIP.Param.timelimit.Cur = 30; %
MIP.solve;
%Note: after solving once, the tuning function appears to work as it should
MIP.tuneParam;
</pre>
Thank you. With your code and data I reproduced the problem here.
Unfortunately, this is a bug in the matlab connector :(
The problem is a missing internal update. To work around this issue you can
perform a solve() with a time limit of 0 or
export the model to a file.
These actions should trigger the update that is missing in tuneParam() and after that tuneParam() should work as expected.
Unfortunately, there seems to be another issue with this example in that the tuning function only works when the presolve function is turned on.
I've posted an example below which you should be able to recreate this using the same mat file as my previous post:
%Load CPLEX Model
data = load('tuning_error.mat')
Model = data.Model;
%Call the tuning function with presolve off (DOES NOT WORK... CPLEX finds an objective value of 0)
MIP = Cplex();
MIP.Model = Model;
MIP.Param.preprocessing.presolve = false;
MIP.Param.timelimit = 1;
MIP.solve;
MIP.Param.timelimit.Cur = 30;
MIP.tuneParam; %this DOES NOT work
MIP.solve %After tuning, the objective value stays at 0
In comparison, the following does work:
%Call the tuning function (DOES NOT WORK... CPLEX finds an objective value of 0)
MIP = Cplex();
MIP.Model = Model;
MIP.Param.preprocessing.presolve = false;
MIP.Param.timelimit = 1;
MIP.solve;
MIP.Param.timelimit.Cur = 30;
MIP.tuneParam; %this DOES work
MIP.solve %After tuning, the LP behaves as it should
Unfortunately, there seems to be another issue with this example in that the tuning function only works when the presolve function is turned on.
I've posted an example below which you should be able to recreate this using the same mat file as my previous post:
<pre class="java dw" dataeditorlang="java" datapbcklang="java" dir="ltr">%Load CPLEX Model
data = load('tuning_error.mat')
Model = data.Model;
%Call the tuning function with presolve off (DOES NOT WORK... CPLEX finds an objective value of 0)
MIP = Cplex();
MIP.Model = Model;
MIP.Param.preprocessing.presolve = false;
MIP.Param.timelimit = 1;
MIP.solve;
MIP.Param.timelimit.Cur = 30;
MIP.tuneParam; %this DOES NOT work
MIP.solve %After tuning, the objective value stays at 0
</pre>
In comparison, the following does work:
<pre class="java dw" dataeditorlang="java" datapbcklang="java" dir="ltr">%Call the tuning function (DOES NOT WORK... CPLEX finds an objective value of 0)
MIP = Cplex();
MIP.Model = Model;
MIP.Param.preprocessing.presolve = false;
MIP.Param.timelimit = 1;
MIP.solve;
MIP.Param.timelimit.Cur = 30;
MIP.tuneParam; %this DOES work
MIP.solve %After tuning, the LP behaves as it should
</pre>
%Call the tuning function (DOES NOT WORK... CPLEX finds an objective value of 0)
MIP = Cplex();
MIP.Model = Model;
MIP.Param.preprocessing.presolve = true;
MIP.Param.timelimit = 1;
MIP.solve;
MIP.Param.timelimit.Cur = 30;
MIP.tuneParam; %this DOES work
MIP.solve %After tuning, the LP behaves as it should
Sorry! the second (working) example should be
<pre class="java dw" dataeditorlang="java" datapbcklang="java" dir="ltr">%Call the tuning function (DOES NOT WORK... CPLEX finds an objective value of 0)
MIP = Cplex();
MIP.Model = Model;
MIP.Param.preprocessing.presolve = true;
MIP.Param.timelimit = 1;
MIP.solve;
MIP.Param.timelimit.Cur = 30;
MIP.tuneParam; %this DOES work
MIP.solve %After tuning, the LP behaves as it should
</pre>