Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

The simplest way to define a powerset of S without the empty set?

  • 1.  The simplest way to define a powerset of S without the empty set?

    Posted Wed September 18, 2019 09:22 AM

    Originally posted by: jamebond


    Hi all,

    In the VRP, I have to define a set N ={1,2,...,n} customer and a set S of all subsets of N. S do not include the empty set.

    My Problem is how to defined S without the empty set in the simplest way?

    I presume to define as follows, however, it is not beautiful and too long
     

    int n  = ...;
    {int} N= asSet(1..n) ;
    {} empty = {};
    
    range r=1.. ftoi(pow(2,card(customer)));
    {int} S [k in r] = {i | i in s: ((k div (ftoi(pow(2,(ord(s,i))))) mod 2) == 1)} diff empty;
    

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: The simplest way to define a powerset of S without the empty set?

    Posted Wed September 18, 2019 11:33 AM

    Hi,

    starting from https://www.ibm.com/developerworks/community/forums/html/topic?id=c6fc1845-6679-4bb0-839b-9e455c09badf&ps=25

    you could write

    {string} s={"A","B","C","D","E"};
        range r=1.. ftoi(pow(2,card(s)));
        range rwithoutthelastone=1..ftoi(pow(2,card(s)))-1;
        {string} s2 [k in rwithoutthelastone] = {i | i in s: ((k div (ftoi(pow(2,(ord(s,i))))) mod 2) == 1)};

        execute
        {
         writeln(s2);
        }

    that will give

    [{"A"} {"B"} {"A" "B"} {"C"} {"A" "C"} {"B" "C"} {"A" "B" "C"} {"D"} {"A" "D"}
             {"B" "D"} {"A" "B" "D"} {"C" "D"} {"A" "C" "D"} {"B" "C" "D"} {"A"
             "B" "C" "D"} {"E"} {"A" "E"} {"B" "E"} {"A" "B" "E"} {"C" "E"} {"A"
             "C" "E"} {"B" "C" "E"} {"A" "B" "C" "E"} {"D" "E"} {"A" "D" "E"} {"B"
             "D" "E"} {"A" "B" "D" "E"} {"C" "D" "E"} {"A" "C" "D" "E"} {"B" "C"
             "D" "E"} {"A" "B" "C" "D" "E"}]

    This is part of

    https://www.linkedin.com/pulse/how-opl-alex-fleischer/

     

    For TSP you could have a look at

    https://www.ibm.com/developerworks/community/forums/html/topic?id=f58daf79-f752-48e4-8f25-54b2f6f71b40&ps=25

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: The simplest way to define a powerset of S without the empty set?

    Posted Thu September 19, 2019 04:29 AM

    Originally posted by: jamebond


    thanks Alex.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer