cplexoplilog

Initialize tuple with set in IBM CPLEX Automation Studio


I have the following variables:

tuple subtour 
{
    int         size;
    {int}       customers;
};
  
{subtour} S;

Now I want to create a new subtour with OPL script and add it to S. I know that I can create a new subtour with S.add(), but what do I have to put in the braces to create a new set of customers when adding the subtour? I already tried something like S.add(5, new Array(1,5,6)) without success.


Solution

  • tuple subtour 
    {
        int         size;
        {int}       customers;
    };
      
    {subtour} S;
    {int} emptysubset;
    
    execute
    {
      S.add(1,emptysubset);
      Opl.first(S).customers.add(1);
      Opl.first(S).customers.add(5);
      Opl.first(S).customers.add(6);
      writeln(S);
    }
    

    gives

    {<1 {1 5 6}>}