javascript - 在 cplex/opl 中初始化集合

标签 javascript cplex opl

我目前正在致力于在 cplex 中实现的多容量批量大小问题的基础上建立买方和 vendor 之间的谈判。 在一个小场景中,买方生产商品 1-4,而 vendor 负责 vendor 品 5-7。

我想做的是创建三组:

{int} buyeroperations

{int} supplieroperations

{int} operations = buyerops union supplierops

由于我对 cplex/opl 相当陌生,我现在的问题是如何使用相应的项目初始化集合,以便在我的模型中使用它们。 我想我可以通过以下方式在内部初始化它们:

{int} buyeroperations = asSet(1..4) 

{int} supplieroperations = asSet(5..7) 

{int} operations = buyeroperations union supplieroperations

我说得对吗? 但是我可以通过脚本和 for 循环以不同的方式初始化集合吗?

如上所述,最终我想要三组,其中前四个项目分配给买家操作,项目 5-7 分配给 vendor 操作,然后是关于所有这些操作的一组操作。

感谢您提前提供的任何帮助。

最佳答案

我会将模型和数据文件分开以使事情变得更容易。 在模型文件中,我将有:

{int} buyeroperations = ...;
{int} supplieroperations = ...;
{int} operations = buyeroperations union supplieroperations;

在数据文件中,我将有:

buyeroperations = [1,2,3,4] // same as [1..4]
supplieroperations = [5,6,7] // same as [5..7]

如果有大量数据,初始化集合的最佳方法是使用数据库。你所展示的应该也有效。

关于javascript - 在 cplex/opl 中初始化集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17347644/

相关文章:

javascript - 如何理解 Node js 进程崩溃内存不足的日志

c++ - Cplex Concert 技术 double

cplex - 错误: cplex (default) cannot extract expression; OPL cannot extract expression AND change interface language

java - 在 Java API 中使用 OPL 模型时出现 CPLEX 热启动错误

cplex - 将 Excel 文件连接到 CPLEX

javascript - Bootstrap 4 崩溃在一半停止然后打开时无法顺利工作

javascript - 当翻译 :scale is applied? 时,我如何计算出 div 移动了多少

javascript - 将数组中的最后一项返回到第一个位置

java - 将数据从 Java 传递到 OPL 模型

syntax-error - CPLEX中没有运算符