Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Mysterious UsercutCallback

    Posted 12/11/13 08:27 AM

    Originally posted by: Zacharie_ALES


    Hello,

    I have a confusing behavior that I really don't understand. I will try to explain it as clearly as possible but don't hesitate to ask if some details are not clear. I am using the Java API and I try to evaluate the efficiency of my UserCutCallback. To that end I want to see the improvement of the root relaxation before and after finding cuts in my callback.

    So:

    - I remove the branching to remain at the root (IloCplex.setParam(IloCplex.IntParam.NodeLim, 0));

    - I remove cplex automatic cuts (IloCplex.setParam(IloCplex.DoubleParam.CutsFactor, 0.0)).

    During my callback no violated cut is found, however the optimal solution is obtained. This would be normal if the root relaxation was integer. The strange part is that it is not. Indeed, if I comment the content of the main() function in my UserCutCallback, the problem is not solved optimally.

    So my question is the following: If nothing is done in my callback why is the problem solved optimally? I really have no clue why cplex gives two different results.

    Thanks in advance for any suggestion!


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Mysterious UsercutCallback

    Posted 12/11/13 10:27 AM

    Originally posted by: Zacharie_ALES


    Ok I tried to locate the issue and found something very strange... In the callback I removed some code and added the following (v_edge is a IloIntVar[][] object and n is the size of v_edge in both dimensions):

    for(int l = 0 ; l < n ; ++l){
        for(int o = l+1 ; o < n ; ++o){                                                                                        
                    getValue(rep.v_edge[o][l]);
            }
    }
    

    With these loops I get the optimal solution. If I comment the loops the result is not optimal. The fact that the function getValue changes the solution is quite surprising.

    I tried to find an hint in the code of the method ControlCallback.getValue(IloIntVar) and found this:

        double getValue(CpxNumExpr cpxnumexpr)
            throws IloException
        {
            int i = getCplexI().getNcols();
            double ad[] = new double[i];
            getX(ad, 0, i - 1);
            EvalVisitor evalvisitor = new EvalVisitor(ad);
            cpxnumexpr.accept(evalvisitor);
            return evalvisitor.getValue();
        }
    

    Do you know why getValue() is doing something else than just returning the value? 
    And do you have any idea of what is done? (and is it possible to disable it)


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Mysterious UsercutCallback

    Posted 01/21/14 04:59 AM

    Just curious: where did you get this source code? It is not in the CPLEX distribution, or is it?


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Mysterious UsercutCallback

    Posted 01/21/14 07:05 AM

    Originally posted by: Zacharie_ALES


    Not it's not in the distribution. I used a decompiler since I really did not understand why the getValue() function was changing the result.


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Mysterious UsercutCallback

    Posted 01/21/14 04:57 AM

    Sorry, it is not clear to me what exactly is the difference between the two solves. Is one solve with and without the cut callback? Or are both solves with cut callbacks but in one solve the callback's main() function is just a no-op?

    In general, a solve with a cut callback that does nothing and a solve without any cut callback are not the same. The presence of a cut callback disables dynamic search. If you want to compare a solve with cut callback and a solve without cut callback then you should set parameter MIPSearch to 1 so that dynamic search is disabled in either case.


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Mysterious UsercutCallback

    Posted 01/21/14 07:16 AM

    Originally posted by: Zacharie_ALES


    Ah thanks for the MIPSearch parameter. I read about the dynamic search but I did not realised there was a parameter to disable it.

    The cut callback is used in both cases and does not return any cut. Moreover, in the second case nothing is done in the main() function. So the difference in the results should not be due to the dynamic search. Unfortunately I did not keep the corresponding source code, so I may not be able to reproduce it. Right know it is not a big deal, but I am always interested if you have any idea.

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Mysterious UsercutCallback

    Posted 01/22/14 01:43 AM

    Off the top of my head I have no idea why calling getValue() or not would cause any difference. Analyzing this would require a code example that exhibits the odd behavior.


    #CPLEXOptimizers
    #DecisionOptimization