10110https://www.ibm.com/developerworks/community/forums/atom/replies?topicUuid=77777777-0000-0000-0000-000014943085MIP tuning tool only runs for a few seconds in MATLAB CPLEX API Replies2013-02-22T19:51:29.330ZIBM Connections - Discussion Forumurn:lsid:ibm.com:forum:77777777-0000-0000-0000-000014944019Re: MIP tuning tool only runs for a few seconds in MATLAB CPLEX API2013-02-22T19:51:29.330ZBerkUstun270003GUUCactive2014-03-24T22:39:04.549Ziron-man270000AK5Mactive
Sorry! the second (working) example should be <br />
<br />
<pre class="java dw" data-editor-lang="java" data-pbcklang="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>
none, view_forum, view_categoryurn:lsid:ibm.com:forum:77777777-0000-0000-0000-000014944018Re: MIP tuning tool only runs for a few seconds in MATLAB CPLEX API2013-02-22T19:51:05.065ZBerkUstun270003GUUCactive2014-03-24T22:39:09.080Ziron-man270000AK5Mactive
Unfortunately, there seems to be another issue with this example in that the tuning function only works when the presolve function is turned on. <br />
<br />
I've posted an example below which you should be able to recreate this using the same mat file as my previous post: <br />
<br />
<pre class="java dw" data-editor-lang="java" data-pbcklang="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>
<br />
<br />
In comparison, the following does work: <br />
<br />
<pre class="java dw" data-editor-lang="java" data-pbcklang="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>
none, view_forum, view_categoryurn:lsid:ibm.com:forum:77777777-0000-0000-0000-000014943841Re: MIP tuning tool only runs for a few seconds in MATLAB CPLEX API2013-02-22T14:28:15.977ZBerkUstun270003GUUCactive2013-02-22T14:28:15.977Z
Ah so the work around isn't that bad at all. Thanks again!
none, view_forum, view_categoryurn:lsid:ibm.com:forum:77777777-0000-0000-0000-000014943707Re: MIP tuning tool only runs for a few seconds in MATLAB CPLEX API2013-02-22T08:01:19.924ZSystemAdmin110000D4XKactive2013-02-22T08:01:19.924Z
Thank you. With your code and data I reproduced the problem here.<br />
Unfortunately, this is a bug in the matlab connector :-(<br />
The problem is a missing internal update. To work around this issue you can<br />
<ul class="jive-dash">
<li>
perform a solve() with a time limit of 0 or
</li>
<li>
export the model to a file.
</li>
</ul>These actions should trigger the update that is missing in tuneParam() and after that tuneParam() should work as expected.
none, view_forum, view_categoryurn:lsid:ibm.com:forum:77777777-0000-0000-0000-000014943443Re: MIP tuning tool only runs for a few seconds in MATLAB CPLEX API2013-02-21T17:28:36.173ZBerkUstun270003GUUCactive2014-03-24T22:39:25.863Ziron-man270000AK5Mactive2013-04-14T09:39:44.982Z2013-04-14T09:39:44.982Z
OK some progress. <br />
<br />
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. <br />
<br />
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: <br />
<br />
<pre class="java dw" data-editor-lang="java" data-pbcklang="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>
none, view_forum, view_categoryurn:lsid:ibm.com:forum:77777777-0000-0000-0000-000014943262Re: MIP tuning tool only runs for a few seconds in MATLAB CPLEX API2013-02-21T13:21:11.400ZSystemAdmin110000D4XKactive2013-02-21T13:21:11.400Z
OK, that is weird and sounds like a potential bug.<br />
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<br />
What CPLEX and matlab version do you use? What operating system?
none, view_forum, view_categoryurn:lsid:ibm.com:forum:77777777-0000-0000-0000-000014943254Re: MIP tuning tool only runs for a few seconds in MATLAB CPLEX API2013-02-21T13:05:43.159ZBerkUstun270003GUUCactive2013-02-21T13:05:43.159Z
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.
none, view_forum, view_categoryurn:lsid:ibm.com:forum:77777777-0000-0000-0000-000014943185Re: MIP tuning tool only runs for a few seconds in MATLAB CPLEX API2013-02-21T09:43:59.557ZSystemAdmin110000D4XKactive2013-02-21T09:43:59.557Z
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?<br />
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 <u>not</u> change any of the time limits?
none, view_forum, view_categoryurn:lsid:ibm.com:forum:77777777-0000-0000-0000-000014943157Re: MIP tuning tool only runs for a few seconds in MATLAB CPLEX API2013-02-21T08:04:19.046ZBerkUstun270003GUUCactive2013-02-21T08:04:19.046Z
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.<br />
<br />
<pre class="jive-pre">
<code class="jive-code jive-java">
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)</code>
</pre>
none, view_forum, view_categoryurn:lsid:ibm.com:forum:77777777-0000-0000-0000-000014943137Re: MIP tuning tool only runs for a few seconds in MATLAB CPLEX API2013-02-21T07:03:04.320ZSystemAdmin110000D4XKactive2013-02-21T07:03:04.320Z
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.<br />
Does the same happen if you solve the problem instance without the tuning tool?
none, view_forum, view_category