Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Binary Variable is not binary during usercut

    Posted 01/31/16 10:32 PM

    Originally posted by: Ibrahim_Capar


    Hello all,

    I am using lazy constraints to add complicating constraints to my problem. Before add a new constraint, I check whether the current solution is violating any lazy constraint.  Let say that I have only one set of decision variable, "X", which is binary.  I use:

    getValues(XSol, X); to copy current solution (one dimensional array) . Naturally XSol might be epsilon away from 0 or 1, i.e. 0.00001 is 0 and 0.99999 is 1;. However I realized that XSol contains values such as:

    0.2
    0.333333
    0.5
    0.6
    0.666667
    0.8

    From my experimentation, this occurs on CPLEX 12.6.2 (64 bit), and 12.6.3 (64 bit). When I run the same code with 12.5.1 (64 bit), everything works fine.

    I am using C++ on Microsoft Visual Studio Professional 2012 Ver 11.0.6 Update 5 under Windows 7 64 bit. My code structure is:

    ILOLAZYCONSTRAINTCALLBACK1(UserCutName, IloIntVarArray, X){

    ...

    getValues(XSol, X);

    ...

    }

    int main(){

    ....

    IloEnv env;

    IloIntVarArray X(env);

    for (int i=0; i<Node; i++)
      X.add(IloIntVar(env,0,1));   

    .....

    IloCplex cplex(env);

    cplex.use(UserCutName(env, X));

    .....

    }

     

    I appreciate it any help to fix this problem. Thank you in advance.

    Ibrahim


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Binary Variable is not binary during usercut

    Posted 02/01/16 05:34 AM

    This indeed looks odd. The lazy constraint callback should only be invoked with solutions that are integer feasible.

    I take it, you only observe this in LazyConstraintCallbacks, not in UserCutCallbacks? Are the values already fractional if you call getValues() first thing in your callback?


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Binary Variable is not binary during usercut

    Posted 02/01/16 01:01 PM

    Originally posted by: Ibrahim_Capar


    I did not try it with UserCutCallbacks.  I extracted values of X with following code.

     

    ILOLAZYCONSTRAINTCALLBACK1(UserCutName, IloIntVarArray, X){
    ofstream output("output.txt", std::ofstream::app);
    IloEnv env = getEnv();
    IloNumArray XSol(env, Xsize);
    getValues(XSol, X);
        for(int i=0;i<Node;i++){
                if ( XSol[i] > 0.01 &&  XSol[i] < 0.95) output << XSol[i] << endl;
                if ( XSol[i]< -0.01 ||  XSol[i] > 1.01) output << XSol[i] << endl;
            }

    .....

    }


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Binary Variable is not binary during usercut

    Posted 02/02/16 04:52 AM

    Can you double-check that XSol[i].getType() is indeed binary (maybe print this as well)? If that is the case then I have no clue what is going wrong. Do you have a small sample code that reproduces the issue and that I could run here?


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Binary Variable is not binary during usercut

    Posted 02/02/16 11:38 AM

    Originally posted by: Ibrahim_Capar


    I cannot use XSol[i].getType(). It says "Error: expression must have class type". However I was able to use it for X[i].getType(); I have following code and output.

    for(int i=0;i<Node;i++){
        if ( XSol[i] > 0.01 &&  XSol[i] < 0.95) output << XSol[i] << ":" << X[i].getType() << ":" << getValue(X[i])  << endl;
        if ( XSol[i]< -0.01 ||  XSol[i] > 1.01) output << XSol[i] << ":" << X[i].getType() << ":" << getValue(X[i])  << endl;
    }

    0.8:3:0.8
    0.2:3:0.2
    0.2:3:0.2
    0.2:3:0.2
    0.6:3:0.6
    0.8:3:0.8
    0.2:3:0.2
    0.6:3:0.6
    0.6:3:0.6
    0.2:3:0.2
    0.8:3:0.8

    Getting a sample and related code, unfortunately, will take some time.


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Binary Variable is not binary during usercut

    Posted 02/03/16 02:07 AM

    Sorry, my bad. I meant to say X[i].getType().

    One more thing to double-check would be to make sure that Node<=XSol.getSize(). I guess this implied by your code but could you still check in the loop in which you print the values that i<XSol.getSize()?

    I have run a code similar to yours on quite a number of models here and so far I did not see any fractional values in a lazy constraint callback. So I am afraid there is not much I can do without looking at your actual code :-(


    #CPLEXOptimizers
    #DecisionOptimization