1

This is .mod (model file)

tuple TDayPair{
  string day1;
  string day2;
}

{TDayPair} DAYS={<"Mon","Tue">,<"Thurs","Fri">};
int a[DAYS]= ...;
execute {
  writeln(a[<"Mon","Tue">]); //<--it gives syntax error here
}

This is .dat (data file)

a = #[
  <"Mon","Tue">:1,
  <"Thurs","Fri">:2,
]#;

It gives syntax error at the model file at writeln(a[<"Mon","Tue">]); what's the issue here?

william007
  • 17,375
  • 25
  • 118
  • 194

1 Answers1

2

If you write

tuple TDayPair{
  string day1;
  string day2;
}

{TDayPair} DAYS={<"Mon","Tue">,<"Thurs","Fri">};
int a[DAYS]= ...;
execute {
  writeln(a[DAYS.find("Mon","Tue")]); //<--it gives syntax error here
}

You will get

1

OPL Modeling language is not the same as the OPL Javascript language that helps with preprocessing, postprocessing and flow control.

Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15