You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将子集{inner_beams}的执行结果赋值给{inner_beams2}以用于约束条件?

技术求助:将执行后的子集结果用于主程序约束(不生成新模型)

我多次尝试在不生成新模型的前提下,把执行后的子集inner_beams的结果作为主程序约束条件使用,但一直没能实现,求技术帮助。

原代码如下:

Main {
      //Code here to get the results of the after executing subset {inner_beams} to the other before executing subset {inner_beams2} to be used in the constrains
     }  
{int} inner_beams2;
Subject to
{
const02:
 forall (i in beams: i in inner_beams2)     // {inner_beams2} is the same values of the {inner_beams}
 (beam_firstchannel[i]==beam_firstchannel[i-1]+ beam_nomusedchannel[i-1]); 
}

{int} inner_beams={2,3,4,6,7,8,9,11,12,13};  // this is the results of the after executing 

解决方案

直接在Main块内将执行后的inner_beams集合赋值给inner_beams2,就能让约束条件复用该子集结果,无需生成新模型。修改后的代码如下:

Main {
      // 将执行后的inner_beams赋值给inner_beams2
      inner_beams2 = inner_beams;
     }  
{int} inner_beams2;
Subject to
{
const02:
 forall (i in beams: i in inner_beams2)     // inner_beams2现在和inner_beams值一致
 (beam_firstchannel[i]==beam_firstchannel[i-1]+ beam_nomusedchannel[i-1]); 
}

{int} inner_beams={2,3,4,6,7,8,9,11,12,13};  // 执行后的子集结果

说明

在OPL的执行流程中,Main块负责处理模型运行前后的逻辑操作。通过在Main块中直接赋值,inner_beams2会继承inner_beams的执行结果,约束const02就能基于这个目标子集生效,完全满足不生成新模型的需求。

内容的提问来源于stack exchange,提问作者MO MO MA

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 18:55:30