【问题标题】:How we can use a set (defined in OPL) in script (CPLEX/execute)我们如何在脚本 (CPLEX/execute) 中使用集合(在 OPL 中定义)
【发布时间】:2020-12-06 16:45:34
【问题描述】:

我在 OPL/CPLEX 中定义了一个这样的集合

{string} S1={"a","b","c"};
{string} S2= S1 diff {"a"}; //which return S2={"b","c"}; 

然后我想在脚本中执行此操作

execute {
`var m=Opl.item(S1,0);`    //which return a

var S3=S1 diff {m}; //或 var S3=S1 Opl.diff {m}; //但它不起作用 }

其实我需要cplex脚本中的Opl set函数,比如diff inter union等

我该怎么做?

提前谢谢你...

【问题讨论】:

    标签: set cplex opl


    【解决方案1】:
    {string} S1={"a","b","c"};
    {string} S2= S1 diff {"a"}; //which return S2={"b","c"}; 
    {string} Sm;
    {string} S3;
    execute {
    var m=Opl.item(S1,0);    //which return a
    Sm.add(m);
    S3=Opl.operatorDIFF(S1,Sm);
    writeln(S3);
    }
    

    给予

    {"b" "c"}
    

    【讨论】:

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