arrayssetcplexoplilog

How to convert an array into a set in CPLEX?


Let's say that

int A=[1 2 3 4];

How to convert it into a Set?

{int} SetA =?

Solution

  •  range r=1..4;
    int A[r]=[1, 2 ,3 ,4];
    
    {int} s={A[i] | i in r};
    
    execute
    {
      writeln(s);
    }
    

    gives

    {1 2 3 4}