Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  cplex with matlab - function InfoCallback

    Posted 01/29/11 11:36 AM

    Originally posted by: Stulu


    Hello,

    we have a question concerning cplex use in matlab, specifically, the function InfoCallback. Following the example mipex4.m we set the callback function. Our objective is that the optimizations stops when a certain value is reached.

    We noticed that if we set value, cplex optimization process is changed and the result is not the same as when doing the optimization step without using the callback function.

    Here is our result without using the callback function:

    ________________________________________
    MATLAB command line result:

    Tried aggregator 4 times.
    MIP Presolve eliminated 3142 rows and 2422 columns.
    MIP Presolve modified 934 coefficients.
    Aggregator did 592 substitutions.
    Reduced MIP has 1720 rows, 2421 columns, and 8476 nonzeros.
    Reduced MIP has 953 binaries, 0 generals, 0 SOSs, and 0 indicators.
    Probing time = 0.00 sec.
    Tried aggregator 1 time.
    Reduced MIP has 1720 rows, 2421 columns, and 8476 nonzeros.
    Reduced MIP has 953 binaries, 0 generals, 0 SOSs, and 0 indicators.
    Presolve time = 0.06 sec.
    Probing time = 0.00 sec.
    Clique table members: 151.
    MIP emphasis: balance optimality and feasibility.
    MIP search method: dynamic search.
    Parallel mode: deterministic, using up to 2 threads.
    Root relaxation solution time = 0.08 sec.

    Nodes Cuts/
    Node Left Objective IInf Best Integer Best Node ItCnt Gap

    0 0 1303.5345 170 1303.5345 1122
    0+ 0 1139.0000 1303.5345 1122 14.45%
    0 0 1209.2727 105 1139.0000 Cuts: 270 2923 6.17%
    0+ 0 1165.0000 1209.2727 2923 3.80%
    0 0 1203.9356 89 1165.0000 Cuts: 59 4849 3.34%
    0 0 1201.9446 84 1165.0000 Flowcuts: 22 5136 3.17%
    0 0 1200.9461 81 1165.0000 Cuts: 18 5229 3.09%
    0 0 1199.9491 78 1165.0000 Flowcuts: 7 5233 3.00%
    0 0 1199.9486 84 1165.0000 Flowcuts: 5 5237 3.00%
    0 0 1199.9461 50 1165.0000 Flowcuts: 1 5240 3.00%
    0 0 1198.9521 46 1165.0000 Flowcuts: 4 5244 2.91%
    0+ 0 1176.0000 1198.9521 5244 1.95%
    0 2 1198.9521 46 1176.0000 1198.9521 5244 1.95%
    Elapsed real time = 1.39 sec. (tree size = 0.01 MB, solutions = 3)
    26 28 1193.9868 65 1176.0000 1196.9891 8387 1.78%
    60+ 60 1178.0000 1196.9891 10278 1.61%
    60 62 1190.9900 19 1178.0000 1196.9891 10278 1.61%
    61 63 1190.9837 17 1178.0000 1196.9891 10279 1.61%
    86 88 1190.9807 16 1178.0000 1196.9891 12206 1.61%
    105 105 1189.9827 46 1178.0000 1196.9891 17142 1.61%
    118 117 1189.9817 49 1178.0000 1196.9891 22444 1.61%
    138 136 1187.9824 52 1178.0000 1196.9891 33082 1.61%
    143 141 1187.9824 37 1178.0000 1196.9891 38427 1.61%
    167 163 1187.9824 43 1178.0000 1196.9891 46260 1.61%
    226+ 197 1180.0000 1196.9891 50636 1.44%
    454+ 272 1181.0000 1184.9947 66278 0.34%
    454 273 1184.9947 8 1181.0000 1184.9947 66278 0.34%
    Elapsed real time = 12.88 sec. (tree size = 4.80 MB, solutions = 7)
    472 244 1182.9980 38 1181.0000 1183.9950 73791 0.25%
    GUB cover cuts applied: 1
    Clique cuts applied: 107
    Cover cuts applied: 4
    Implied bound cuts applied: 3
    Flow cuts applied: 188
    Mixed integer rounding cuts applied: 119
    Zero-half cuts applied: 1
    Gomory fractional cuts applied: 53

    Root node processing (before b&c):
    Real time = 1.33
    Parallel b&c, 2 threads:
    Real time = 14.99
    Sync time (average) = 1.89
    Wait time (average) = 2.69

    Total (root+branch&cut) = 16.31 sec.

    fmin =

    1.1810e+003
    Status =

    integer optimal solution



    And here the result when setting the InfoCallback function to stop the optimization if the optimal value (1181 from the previous optimization) is reached:

    Tried aggregator 0 times.
    Presolve time = 0.00 sec.
    Probing fixed 64 vars, tightened 0 bounds.
    Probing time = 0.00 sec.
    Clique table members: 431.
    MIP emphasis: balance optimality and feasibility.
    MIP search method: dynamic search.
    Parallel mode: deterministic, using up to 2 threads.
    Root relaxation solution time = 0.72 sec.

    Nodes Cuts/
    Node Left Objective IInf Best Integer Best Node ItCnt Gap

    0 0 1324.7067 189 1324.7067 3984
    0+ 0 1144.0000 1324.7067 3984 15.80%
    0 0 1209.7943 100 1144.0000 Cuts: 392 5898 5.75%
    0+ 0 1165.0000 1209.7943 5898 3.85%
    0 0 1204.4334 90 1165.0000 Cuts: 57 6794 3.38%
    0 0 1203.4300 110 1165.0000 Cuts: 26 8689 3.30%
    0 0 1202.4300 93 1165.0000 Cuts: 17 8715 3.21%
    0 0 1202.4295 101 1165.0000 Flowcuts: 3 8724 3.21%
    0 0 1202.4295 67 1165.0000 Flowcuts: 2 8728 3.21%
    0 0 1202.4295 70 1165.0000 Cuts: 3 8733 3.21%
    0+ 0 1177.0000 1202.4295 8733 2.16%
    0 2 1202.4295 69 1177.0000 1202.4295 8733 2.16%
    Elapsed real time = 4.70 sec. (tree size = 0.01 MB, solutions = 3)
    18 20 1196.3164 73 1177.0000 1201.4365 13105 2.08%
    22 24 1194.9798 82 1177.0000 1201.4365 16027 2.08%
    33 35 1191.9854 71 1177.0000 1201.4365 16892 2.08%
    52 52 1185.9920 59 1177.0000 1201.4365 19952 2.08%
    65 64 1185.9920 50 1177.0000 1201.4365 22620 2.08%
    141 133 1197.4836 51 1177.0000 1201.4365 26282 2.08%
    151 143 1192.9898 69 1177.0000 1200.4315 32982 1.99%
    175+ 165 1179.0000 1200.4315 35730 1.82%
    175 167 1190.9897 60 1179.0000 1200.4315 35730 1.82%
    262 210 1179.9970 42 1179.0000 1200.4315 46607 1.82%
    409 347 1189.9870 31 1179.0000 1199.4433 61634 1.73%
    Elapsed real time = 15.97 sec. (tree size = 2.94 MB, solutions = 4)
    608 527 1191.9882 77 1179.0000 1198.4575 82999 1.65%
    825 723 1180.9870 53 1179.0000 1197.4799 103074 1.57%
    1115 975 1192.4866 40 1179.0000 1197.4468 120624 1.56%
    1381 1204 1185.9918 56 1179.0000 1196.4819 139226 1.48%
    1604 1407 1184.9898 50 1179.0000 1196.4687 162481 1.48%
    1823 1595 1190.4816 60 1179.0000 1196.4687 182999 1.48%
    2119 1836 1179.9922 33 1179.0000 1195.9667 210663 1.44%
    2421 2089 1181.9910 25 1179.0000 1195.7308 225839 1.42%
    2974 2556 1179.9888 64 1179.0000 1195.4623 245427 1.40%
    3190 2738 1185.9938 64 1179.0000 1194.9866 263370 1.36%
    Elapsed real time = 39.31 sec. (tree size = 8.05 MB, solutions = 4)
    3369 2886 1191.4876 63 1179.0000 1194.9831 288076 1.36%
    3572 3060 1181.9948 52 1179.0000 1194.9814 313479 1.36%
    Clique cuts applied: 209
    Cover cuts applied: 6
    Implied bound cuts applied: 56
    Flow cuts applied: 78
    Mixed integer rounding cuts applied: 5
    Gomory fractional cuts applied: 74

    Root node processing (before b&c):
    Real time = 4.56
    Parallel b&c, 2 threads:
    Real time = 40.47
    Sync time (average) = 2.79
    Wait time (average) = 4.42

    Total (root+branch&cut) = 45.03 sec.

    fmin =

    1.1790e+003

    **we were using a time limit of 45s, but even without the time limit, the result using the callback function is the same as posted here and what we see is that the presolve steps are changed when setting the callback function (which is said to not afect the optimization procedure).
    Could you please help us concerning this issue?

    Many thanks in advance.
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: cplex with matlab - function InfoCallback

    Posted 01/29/11 12:08 PM

    Originally posted by: Stulu


    Ahh, sorry, I just forgot, here is how we set the callback function:


    cplex.InfoCallback.MIPCallback.func = @tostop;
    cplex.InfoCallback.MIPCallback.data.maxval = MaxValue;

    cplex.solve();
    % Callback function
    function stop = tostop(info,data)
    if ~isempty(info.IncObj)
    if (info.IncObj >= data.maxval)
    display ('Maximum value reached: stopping optimization');
    stop = true;
    else
    stop = false;
    end

    end
    end


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: cplex with matlab - function InfoCallback

    Posted 01/29/11 09:09 PM

    Originally posted by: John Cui


    Yes, IncObj is correct.

    But why did you add MIPCallback between InfoCallback with data?

    John Cui
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: cplex with matlab - function InfoCallback

    Posted 01/30/11 07:53 AM

    Originally posted by: Stulu


    Hello,

    oops, this was my mistake when copying, in fact no MIPCallback was used, only InfoCallback, like this:


    cplex.InfoCallback.func = @tostop;
    cplex.InfoCallback.data.maxval = MaxValue;

    cplex.solve();

    % Callback function
    function stop = tostop(info,data)
    if ~isempty(info.IncObj)
    if (info.IncObj >= data.maxval)
    display ('Maximum value reached: stopping optimization');
    stop = true;
    else
    stop = false;
    end

    end
    end


    And like this we get the difference in the presolve and also in the time.
    So when we don't set the callback, the optimal solution is reached in few seconds (<16s) and it is for this case 1181).

    When we set the callback using as maximum value 1181 (but it actually does not matter, we also used other values to see what was going on), then it takes a longer time (~40s) and it reaches an optimal value of 1179.

    The differences we saw with the two cases are marked in bold on the first post and it seems to be related with presolve steps (?) :S

    Thanks for your help.
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: cplex with matlab - function InfoCallback

    Posted 02/01/11 05:27 AM

    Originally posted by: Stulu


    Hello,

    Still concerning our problem using the callback function and the change in the presolve steps, we saw that the following parameters are automatically changed by using the callback function (which is probably the origin of the different optimal value obtained):

    cplex.Param.preprocessing.reduce.Cur=3;
    Originally =3, changed to 2 by InfoCallback

    cplex.Param.preprocessing.linear.Cur=1;
    Originally =1, changed to 0 by InfoCallback

    Thank you for your attention.
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: cplex with matlab - function InfoCallback

    Posted 02/04/11 05:06 AM

    Originally posted by: Stulu


    Hello,

    please excuse me that I'm back again with the same question.. I was waiting for a reply but may be you haven't seen it.

    we are using the InfoCallback function on matlab but we saw that the optimization steps as well as the optimal value reached are changed when we use the callback function.

    here are our settings:


    cplex.InfoCallback.func = @tostop;
    cplex.InfoCallback.data.maxval = MaxValue;

    cplex.solve();

    % Callback function
    function stop = tostop(info,data)
    if ~isempty(info.IncObj)
    if (info.IncObj >= data.maxval)
    display ('Maximum value reached: stopping optimization');
    stop = true;
    else
    stop = false;
    end



    And here the results:

    Without setting the callback function:

    Tried aggregator 4 times.
    MIP Presolve eliminated 3142 rows and 2422 columns.
    MIP Presolve modified 934 coefficients.
    Aggregator did 592 substitutions.
    Reduced MIP has 1720 rows, 2421 columns, and 8476 nonzeros.
    Reduced MIP has 953 binaries, 0 generals, 0 SOSs, and 0 indicators.
    Probing time = 0.00 sec.
    Tried aggregator 1 time.
    Reduced MIP has 1720 rows, 2421 columns, and 8476 nonzeros.
    Reduced MIP has 953 binaries, 0 generals, 0 SOSs, and 0 indicators.
    Presolve time = 0.06 sec.
    Probing time = 0.00 sec.
    Clique table members: 151.

    Total (root+branch&cut) = 16.31 sec.

    fmin =

    1.1810e+003



    Setting the callback function:

    Tried aggregator 0 times.
    Presolve time = 0.00 sec.
    Probing fixed 64 vars, tightened 0 bounds.
    Probing time = 0.00 sec.
    Clique table members: 431.
    Root relaxation solution time = 0.72 sec.

    fmin =

    1.1790e+003



    Additionally, we found the following automatic changes in the presolve steps, when using the callback function:
    cplex.Param.preprocessing.reduce.Cur=3;
    Originally =3, changed to 2 by InfoCallback

    cplex.Param.preprocessing.linear.Cur=1;
    Originally =1, changed to 0 by InfoCallback



    Any help concerning why this happens and if there's a solution to this problem would be very appreciated since it's relevant for our process to stop the optimization when a certain maximum value calculated in a previous step is reached; but for the moment we stopped using the callback function due to this differences.
    Thank you very much.
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: cplex with matlab - function InfoCallback

    Posted 02/11/11 09:33 PM

    Originally posted by: John Cui


    Ah, could you please send me your all matlab scripts to me?
    jcui@cn.ibm.com

    Maybe it is a bug in our connector. Thanks a lot.

    John Cui
    #CPLEXOptimizers
    #DecisionOptimization