Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  OR constraints

    Posted 05/19/09 08:39 PM

    Originally posted by: SystemAdmin


    [morteza4321 said:]

    Hello,

    I have a program with two constraint sets,  Cons1: x - x[j]>= 1-z[i,j] and Cons2: x[j] - x>= 1-z[i,j]
    for each i and j, I want to add a constraint in which at least one of Cons1 or Cons2 is satisfied.
    For this purpose, I write (in C#):

    for each i,j:
      cplex.Or(cplex.AddGe(cplex.Sum(x, cplex.Prod(-1, x[j]), z[count]), 1), cplex.AddGe(cplex.Sum(x[j], cplex.Prod(-1, x), z[count]), 1));
           
    Cplex solver adds both the constraints Cons1 and Cons2 and solves the program (therefore it obtains z[i,j]=1 and x = x[j]). I was wondering if any could help me to solve the problem.


    Best Regards,
    Morteza
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: OR constraints

    Posted 05/21/09 06:10 AM

    Originally posted by: SystemAdmin


    [EdKlotz said:]

    Hello,

    I have a program with two constraint sets,  Cons1: x - x[j]>= 1-z[i,j] and Cons2: x[j] - x>= 1-z[i,j]
    for each i and j, I want to add a constraint in which at least one of Cons1 or Cons2 is satisfied.
    For this purpose, I write (in C#):

    for each i,j:
      cplex.Or(cplex.AddGe(cplex.Sum(x, cplex.Prod(-1, x[j]), z[count]), 1), cplex.AddGe(cplex.Sum(x[j], cplex.Prod(-1, x), z[count]), 1));
           
    Cplex solver adds both the constraints Cons1 and Cons2 and solves the program (therefore it obtains z[i,j]=1 and x = x[j]). I was wondering if any could help me to solve the problem.



    Can you reproduce this in a simple example program that essentially only has those constraints?
    If so, why don't you upload that to this thread?

    Meanwhile, as a workaround, you could try using the IloMPModeler.abs method.  Based on your
    description above, aren't your OR constraints really a single constraint involving the absolute
    value  |x - x[j]|?

    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: OR constraints

    Posted 05/22/09 03:32 AM

    Originally posted by: SystemAdmin


    [EdKlotz said:]

    I have a program with two constraint sets,  Cons1: x - x[j]>= 1-z[i,j] and Cons2: x[j] - x>= 1-z[i,j]
    for each i and j, I want to add a constraint in which at least one of Cons1 or Cons2 is satisfied.
    For this purpose, I write (in C#):

    for each i,j:
      cplex.Or(cplex.AddGe(cplex.Sum(x, cplex.Prod(-1, x[j]), z[count]), 1), cplex.AddGe(cplex.Sum(x[j], cplex.Prod(-1, x), z[count]), 1));
           
    Cplex solver adds both the constraints Cons1 and Cons2 and solves the program (therefore it obtains z[i,j]=1 and x = x[j]). I was wondering if any could help me to solve the problem.

    Paul Rubin pointed out the problem here.  When you call cplex.AddGe, it not only returns the constraint,
    but it adds it to the model contained in the IloCplex class.  So the above call actually creates
    3 constraints:

    x - x[j]>= 1-z[i,j]
    x[j] - x>= 1-z[i,j]
    x - x[j]>= 1-z[i,j] or x[j] - x>= 1-z[i,j]

    That explains why CPLEX always gave you a solution that satisfied the first two constraints.
    To solve this, create the first two constraints without adding them to the IloCplex object.
    In other words, create separate IloRanges or IloConstraints for the first two constraints,
    then call IloCplex.Or with the two constraints.
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: OR constraints

    Posted 06/01/09 01:46 AM

    Originally posted by: SystemAdmin


    [notdarkyet said:]

    You can formulate this also on your own - if both regions are bounded. You'll need an additional binary variable.
    This is called disjunctive inequalities and you'll find it in nearly all the textbooks on mixed-integer programming.
    If the regions aren't bounded I doubt that CPLEX can also not handle this.
    #CPLEXOptimizers
    #DecisionOptimization