settuplescplexamplopl

Defining Set of Set in OPL (or indexed set)


I try to define set of set in OPL. The problem is:

  1. I have several Computing Platforms, for example: {"DC1", "DC2", "MP1"}
  2. Each Computing Platforms can have several configuration, for example: DC1 may have {"conf1", "conf3"}, DC2 may have {"conf1", "conf2", "conf3"} and MP1 may have {"conf1", "conf3"}
  3. each Computing Platforms have several attributes like capacity (vcpu)
  4. the set of set in AMPL, and the parameter could be easily written as the following:
set COMPPLATFORMS;
set CONFCP{COMPPLATFORMS}

param vcpu {d in COMPPLATFORMS, CONFCP[d]};

However, in OPL we do not have a straightforward way of declaring an indexed set. I notice that we could use either tuple or maybe some preprocessing. But now I am not sure how to declare the parameter "vcpu" for the indexed set?

I know that we could have an array of sets, or sets of array. But could we have a set of set?

Is there any example in OPL that follow the similar structure? Thank you


Solution

  • See sets of sets in the example power sets in how to with OPL

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