OPL CPLEX语法问题与元组数组

发布于 2025-02-10 18:45:25 字数 460 浏览 3 评论 0原文

这是.mod(模型文件)

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
}

这是.dat(数据文件)

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

,它在writeln(a [&lt;“ mon”,“ tue”,“ tue”&gt;]);>>> >>这里有什么问题?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时间你老了 2025-02-17 18:45:25

如果您写的话,

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
}

您将获得

1

OPL建模语言与 OPL JavaScript语言有助于预处理,后处理和流控制。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文