【问题标题】:CPLEX OPL: Constraint that ensures demand due dates are metCPLEX OPL:确保满足需求到期日期的约束
【发布时间】:2015-11-06 13:08:55
【问题描述】:

我有一个 CPLEX OPL 模型,可以最大限度地降低城市之间货物的总运输成本。 x 是我的主要(整数)决策变量。下面提到的所有其他变量都是整数。我想为这个模型添加截止日期。这意味着时间 t(例如 3)的需求必须在时间段 1 到 t(例如 1 到 3)内运输。但是,我无法在 1 到 t 期间求和。

subject to {
  // Satisfy demands before due date
  forall(i,j in City, t in Times)
      ctDueDate:  
        sum(m in Mode, v in Vehicle, s in 1..t) x[m][i][j][v][s] == sum(s in 1..t) Demand[s][i][j];
}

编写此代码的正确方法是什么?

【问题讨论】:

    标签: integer cplex opl


    【解决方案1】:

    范围城市=1..4;

    范围时间=1..3;

    范围模式=1..2;

    范围车辆=1..2;

    int Demand[Times][City][City];

    dvar int x[Mode][City][City][Vehicle][Times] in 0..10;

    以{

    为准

    // 在截止日期前满足需求

    forall(i,j in City, t in Times)

      ctDueDate:  
    
        sum(m in Mode, v in Vehicle, s in 1..t) x[m][i][j][v][s] 
    
      == sum(s in >  1..t) Demand[s][i][j];
    

    }

    工作正常。

    问候

    【讨论】:

    • 谢谢。那应该行得通。我实际上已经通过将 == 符号更改为 >= 符号自己解决了这个问题。但是我没有分享解决方案,因此您是第一个给出正确答案的回复。
    猜你喜欢
    • 1970-01-01
    • 2019-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多