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

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

 

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