【问题标题】:Conditional summation in CPLEX using OPLCPLEX 中使用 OPL 的条件求和
【发布时间】:2018-06-28 13:34:40
【问题描述】:

我正在尝试用 OPL 写这个总和:

我这样做了,但这并不是我所需要的。

forall (n in cont, t in tempo, o in portos)
  sum(i in colunap, j in linhap)b[i][j][n][t] + v[n][t] == 1; 

我应该是这样的,但是opl不接受:

forall (n in cont[o], t in tempo[o], o in portos)
  sum(i in colunap[o], j in linhap[o])b[i][j][n][t] + v[n][t] == 1; 

【问题讨论】:

  • 如果 cont 和 tempo 依赖于 o 那么你宁愿写 forall ( o in portos,n in cont[o], t in tempo[o])
  • 感谢您的回答!但是如何将参数声明为矩阵和向量?我试过: int H[o in 1..P-1] = ...;和范围 linhap=1..H[o];但是OPL不接受……抱歉,我刚开始学OPL

标签: sum constraints mathematical-optimization cplex opl


【解决方案1】:

这应该可行:

int P=3;
int H[1..P-1] = [1 , 2]; 
range linhap=1..max(o in 1..P-1) H[o];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多