【问题标题】:initializing a set in cplex/opl在 cplex/opl 中初始化一个集合
【发布时间】:2013-06-25 05:16:32
【问题描述】:

我目前正在根据 cplex 中实施的多容量批量大小问题在买方和供应商之间建立谈判。 在一个小场景中,买方负责生产 1-4 项,而供应商负责供应 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 项分配给供应商操作,然后是所有这些项的一组操作。

提前感谢您的帮助。

【问题讨论】:

    标签: javascript cplex opl


    【解决方案1】:

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

    {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]
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-05
      • 2020-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多