Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  LazyCutCallback: MIP warmstart is ignored

    Posted 06/08/16 12:22 AM

    Originally posted by: JorisK


    I have an optimization problem for which it is easy to find a feasible solution (but hard to find an optimal one). As such I provide an initial feasible solution as a warm start to the solver. Problem: when I use a LazyCutCallback, my warmstart is completely ignored. Is there a way to fix this (cplex 12.6.3, C++)?

    Without a LazyCutCallback:

    1 of 1 MIP starts provided solutions.
    MIP start 'm1' defined initial solution with objective 40609.0000.
    

    With a LazyCutCallback:

    Lazy constraint(s) or lazy constraint callback is present.
        Disabling dual reductions (CPX_PARAM_REDUCE) in presolve.
        Disabling non-linear reductions (CPX_PARAM_PRELINEAR) in presolve.
    Tried aggregator 2 times.
    MIP Presolve eliminated 2 rows and 0 columns.
    Aggregator did 78 substitutions.
    Reduced MIP has 3042 rows, 57837 columns, and 118638 nonzeros.
    Reduced MIP has 1521 binaries, 0 generals, 0 SOSs, and 0 indicators.
    Presolve time = 0.05 sec. (50.47 ticks)
    Tried aggregator 1 time.
    Reduced MIP has 3042 rows, 57837 columns, and 118638 nonzeros.
    Reduced MIP has 1521 binaries, 0 generals, 0 SOSs, and 0 indicators.
    Presolve time = 0.03 sec. (31.37 ticks)
    Probing time = 0.04 sec. (33.60 ticks)
    Clique table members: 78.
    MIP emphasis: balance optimality and feasibility.
    MIP search method: traditional branch-and-cut.
    Parallel mode: none, using 1 thread.
    Root relaxation solution time = 1.05 sec. (2034.50 ticks)
    Delayed MIP starts found nothing.
    

    Code for MIP start:

    IloNumVarArray startVar(env);
    IloNumArray startVal(env);
    for(int i=1; i<tdTSP->nrVertices; i++){
            startVar.add(xVars[i-1][i-1]);
            startVal.add(1);
    }
    cplex.addMIPStart(startVar, startVal,IloCplex::MIPStartEffort::MIPStartRepair);
    startVal.end();
    startVar.end();
    

    To ensure that my LazyCutCallback is implemented correctly, i.e. that it doesn't cut off my initial solution, I added xVars[i-1][i-1].setLB(1); to the previous for loop, thereby fixing the initial solution. In this case, the solver instantly returns this solution as the optimal solution.

     

    Currently, if I don't use a LazyCutCallBack, cplex uses my initial solution and is able to improve upon this solution. If I however add the LazyCutCallback, then cplex doesn't use my initial solution. When the time limit is reached, cplex reports that it couldn't find any solution! This is obviously undesirable. Any suggestions on how to fix this?


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: LazyCutCallback: MIP warmstart is ignored

    Posted 06/09/16 02:15 AM

    The MIP start is not completely ignored. It is delayed and then CPLEX fails to find a solution from it:

    Delayed MIP starts found nothing

    I'm afraid you have hit on a known deficiency of current CPLEX here.

    Do you have values for all integer/binary variables in your MIP start and do you know that the MIP start will not violate any lazy constraints? If so, you can inject the solution with a heuristic callback.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: LazyCutCallback: MIP warmstart is ignored

    Posted 10/06/16 09:33 AM

    Originally posted by: pegonzalez


    Dear Daniel,

    can you give me a small example on how to do what you proposed ? (inject the solution with the heuristic callback)

    Thanks in advance


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: LazyCutCallback: MIP warmstart is ignored

    Posted 10/12/16 03:45 AM

    Here is an example callback implementation:

    // Heuristic callback takes 4 arguments:
    // x - ALL variables in the model.
    // startVar - The variables for which we have a value. You must provide a value
    //            for each binary/integer variable.
    // startVal - The values for the variables in startVar
    // injected - Pass false here.
    ILOHEURISTICCALLBACK4(Callback,
                          IloNumVarArray, x,
                          IloNumVarArray, startVar,
                          IloNumArray, startVal,
                          bool, injected)
    {
       if ( !injected ) { // Attempt to inject the solution only once.
          injected = true;
    
          // Get feasibility statuses of variables. We need this so that we do
          // not attempt to change bounds of variables that have been removed
          // or fixed by presolve (this would throw an exception).
          IntegerFeasibilityArray feas(getEnv());
          getFeasibilities(feas, startVar);
    
          // Fix all variables in startVar (but skip over variables that were
          // removed or fixed by presolve).
          for (IloInt i = 0; i < startVar.getSize(); ++i) {
             if ( feas[i] != ImpliedFeasible )
                setBounds(startVar[i], startVal[i], startVal[i]);
          }
    
          // Solve the model with the fixed variable. If successful then install
          // the solution found as heuristic solution, otherwise print a warning.
          if ( solve() ) {
             std::cerr << "Injecting solution with objective " << getObjValue()
                       << std::endl;
             IloNumArray vals(getEnv());
             getValues(vals, x);
             setSolution(x, vals);
             vals.end();
          }
          else {
             std::cerr << "solve() failed!" << std::endl;
          }
    
          feas.end();
       }
    }
    

    Assuming you have all the variables of the model in an IloNumArray x and have the MIP start values in startVar and startVal then this can be used like so:

    cplex.use(Callback(env, x, startVar, startVal, false));

    Note that this only works if your MIP start provides values for every binary and integer variable.


    #CPLEXOptimizers
    #DecisionOptimization