2

I want to define a tuple in a CPLEX .mod file. There is a main block in the .mod file. When I try to define the tuple inside the main block, an error occurs like: Scripting parser error: missing ';' or newline between statements. This is shown in the next figure:

enter image description here

But when I replace the tuple definition out of the main block, the problem is solved. Like the next figure:

enter image description here

Although the problem is solved with the second approach, I want to ask what is the reason for this.

1 Answers1

3

in the main block you should use thisOplModel to get anything from the model.

tuple minandmax
{
int m;
int M;
}

{minandmax} singletonMinAndMax={<1,5>};

dvar int X;
subject to
{
  
}

main
{
  writeln("give me ",Opl.first(thisOplModel.singletonMinAndMax).M);
}

gives

give me 5
Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15