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

如何将下述增量约束修改为大于等于(>=)而非仅等于(==)?

问题

已在OPL的main块中添加了增量约束,当前实现的逻辑为:
beam_firstchannel[i] == beam_firstchannel[i-1] + beam_nomusedchannel[i-1]
现需将该约束修改为:
beam_firstchannel[i] >= beam_firstchannel[i-1] + beam_nomusedchannel[i-1]

相关原代码如下:

main
{
 for(var i in thisOplModel.inner_beams2 )
  {
  thisOplModel.ctEmptyy[i].setCoef(thisOplModel.beam_firstchannel[i],1);
  thisOplModel.ctEmptyy[i].setCoef(thisOplModel.beam_firstchannel[i-1],-1);
  thisOplModel.ctEmptyy[i].setCoef(thisOplModel.beam_nomusedchannel[i-1],-1);
  thisOplModel.ctEmptyy[i].setBounds(0,0);   
 }
}

// 上述约束实现的逻辑:
// beam_firstchannel[i]==beam_firstchannel[i-1]+beam_nomusedchannel[i-1];

// 需要修改为:
// beam_firstchannel[i]>=beam_firstchannel[i-1]+beam_nomusedchannel[i-1];

subject to 
{
forall (i in inner_beams2 )
ctEmptyy:    
0>=0;
}

修改方案

只需调整约束的边界设置即可,具体修改点如下:

  • 原代码中thisOplModel.ctEmptyy[i].setBounds(0,0);是强制约束表达式等于0(对应等式逻辑)
  • 要实现>=的不等式逻辑,只需将约束的下界设为0,上界放开不限制,把该行代码替换为:
    thisOplModel.ctEmptyy[i].setBounds(0, thisOplModel.INFINITY);
    

修改后的完整main块代码:

main
{
 for(var i in thisOplModel.inner_beams2 )
  {
  thisOplModel.ctEmptyy[i].setCoef(thisOplModel.beam_firstchannel[i],1);
  thisOplModel.ctEmptyy[i].setCoef(thisOplModel.beam_firstchannel[i-1],-1);
  thisOplModel.ctEmptyy[i].setCoef(thisOplModel.beam_nomusedchannel[i-1],-1);
  // 修改边界:下界0,上界无限制,实现表达式 >=0
  thisOplModel.ctEmptyy[i].setBounds(0, thisOplModel.INFINITY);   
 }
}

逻辑说明

原约束表达式整理后为:
beam_firstchannel[i] - beam_firstchannel[i-1] - beam_nomusedchannel[i-1]

  • 原setBounds(0,0)要求该表达式等于0,对应等式逻辑
  • 修改后setBounds(0, INFINITY)要求该表达式大于等于0,整理后就是目标的不等式:
    beam_firstchannel[i] >= beam_firstchannel[i-1] + beam_nomusedchannel[i-1]

内容的提问来源于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.07 20:50:26