2015-11-06 96 views
0

我有一个CPLEX OPL模型,可以最大限度地减少城市间货物的总运输成本。 x是我的主要(整数)决策变量。下面提到的所有其他变量都是整数。我想为此模型添加截止日期。这意味着时间t(例如3)处的需求必须在时间段1到t(例如1到3)内运输。但是,我不能总结1到t的时间。CPLEX OPL:确保满足需求到期日的约束条件

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]; 
} 

这是什么编码的正确方法?

回答

1

范围城市= 1..4;

范围Times = 1..3;

范围Mode = 1..2;

range Vehicle = 1..2;

int需求[次] [城市] [城市];

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

受到{

//手托到期日

FORALL(I,J在市,吨时报)

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]; 

之前要求}

工作正常。

Regards

+0

谢谢。这应该工作。我实际上已经通过将==符号更改为> =符号来解决它。但是我没有分享这个解决方案,因此你是第一个回答正确的答案。 – FabianW