我有一个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];
}
对此进行编码的正确方法是什么?
答案 0 :(得分:1)
范围城市= 1..4;
范围时间= 1..3;
范围Mode = 1..2;
范围车辆= 1..2;
int Demand [Times] [City] [City];
dvar int x [Mode] [City] [City] [Vehicle] [Times] in 0..10;
受{{/ p>
//在截止日期之前满足要求
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];
}
工作正常。
此致