Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  How to implement Complement Sets in CPLEX

    Posted 06/04/18 04:09 AM

    Originally posted by: harrynick


    Hello,

    Can anyone tell me how to implement 'complement sets' in IBM OPL CPLEX?

    Suppose, I have a set named 'Set' as :

    {int} Set = {1,2};

    Now I have a variable say Apple[Set][Setd].

    Here Setd is the complement set of set 'Set'. In other words, if 'Set' takes value 1 then 'Setd' should take value 2(the complement). Also when the value in 'Set' is 2 value in 'Setd' is 1. 

    I hope someone shade some light on this problem.

    Thanks and Regards.

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: How to implement Complement Sets in CPLEX

    Posted 06/04/18 05:23 AM

    Hi,

    have you had a look at diff ?

    {int} Set = {1,2};

    {int} a={1};
    {int} b=Set diff a;

    execute
    {
    writeln(b);
    }

    gives

    {2}

    regards


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: How to implement Complement Sets in CPLEX

    Posted 06/04/18 06:07 AM

    Originally posted by: harrynick


    Thanks for shedding light on the problem.

    But suppose I do not know about 'set a = {1}' as mentioned while implementing in a constraint. So how will I implement it?

    As for an example:

    {int} Set = {1,2};

    forall( i in Set)  sum(j in Setd) Apple[Set][Setd]<=Mango[Any1][Any2]; (Here Mango is any other variable with Any1 and Any2 as two random sets)

    Here Setd is the complement set of set 'Set'.

    Thanks and Regards.

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: How to implement Complement Sets in CPLEX

    Posted 06/04/18 08:04 AM

    Hi,

    {int} Set = {1,2};

    {int} a[i in 1..10]=(rand(2)+i div i-1==0)?{1}:{2};;
    {int} b[i in 1..10]=Set diff a[i];

    execute
    {
    writeln(b);
    }
     
     
     int su=sum(i in 1..10) sum(j in Set diff a[i]) j;
     
     execute
     {
     su;
     }
     
     assert su==sum(i in 1..10) sum(j in b[i]) j;

    regards

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: How to implement Complement Sets in CPLEX

    Posted 06/05/18 02:18 AM

    Originally posted by: harrynick


    Thanks and Regards.


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: How to implement Complement Sets in CPLEX

    Posted 06/05/18 02:18 AM

    Originally posted by: harrynick


    Thanks and Regards.


    #CPLEXOptimizers
    #DecisionOptimization