Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  big-M constraint in CPLEX on C# does not work?

    Posted 10/12/12 01:33 AM

    Originally posted by: Chrisontherun


    I encountered trouble when posting big-M constraints in CPLEX on C# environment, here's my case:

    the constraint I want to post can be read as
    (Complete[i]-Due[i])/M <= lateness[i]

    where Complete[i] and Due[i] denotes complete and due time of job i, and lateness[i], which is a binary variable, is set to be 1 when job i is late(that is, Complete[i]-Due[i] < 0 ) and 0 other wise, M represents a sufficiently large number. To impletement this, I code as follows:
    
    ILinearNumExpr a = cp.LinearNumExpr(); 
    
    for (
    
    int i = 0; i < nbJobs; i++) 
    { a.AddTerm(1 / 100000.0, complete[i]); a.AddTerm(-1, lateness[i]); cplex.AddLe(a, Due[i] / 100000.0); 
    }
    

    it can be seen that M is give the value of 100000.0 which is considerably larger than any of Complete[i] and Due[i]. the objective is to minimize the number of late jobs by
    
    ILinearNumExpr b = cp.LinearNumExpr(); 
    
    for (
    
    int i = 0; i < nbJobs; i++) 
    { b.AddTerm(1, lateness[i]); 
    } cplex.AddMinimize(b);
    

    The output shows that even jobs are late, the value of corresponding lateness[i] stays 0. What shocked me is that as I decrease the value of M (from 100000.0 to 1000.0), the number of lateness[i] with value 1 increases as they are not constrained by the big-M constraints posted above. I'm not sure if have missed anything or is there anything wrong with the constraint. Can anybody give me some suggestion?
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: big-M constraint in CPLEX on C# does not work?

    Posted 10/15/12 08:15 AM

    Originally posted by: SystemAdmin


    My guess is that your M is so big here that you are suffering from bad numerics.
    It might be better to rewrite the big-M constraints into something that uses indicator constraints. For example
    // If the job is not late (lateness[i] == 0) then it must complete before its due time.
    cplex.IfThen(cplex.Eq(lateness[i], 0), cplex.Le(Complete[i], Due[i]));
    

    This expresses exactly the same constraint but leaves it to CPLEX to decide how to handle it best.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: big-M constraint in CPLEX on C# does not work?

    Posted 10/15/12 09:49 AM

    Originally posted by: Chrisontherun


    thank you for your advice, I think it addressed my problem pretty well :)
    #DecisionOptimization
    #OPLusingCPLEXOptimizer