我是CPLEX的初学者,需要你的帮助。 我想为调度解决一个简单的整数编程问题,我的整个代码如下。 错误是在ct2和ct3中生成的,我认为数组范围是错误的。 我的问题是,如何为" forall"制作阵列范围?和"总和"功能
真的希望我能在这里得到一些答案。
int NbGroup = ...;
int NbAutoclave = ...;
int NbTimeslot = ...;
range Group = 1..NbGroup;
range Autoclave = 1..NbAutoclave;
range Timeslot = 1..NbTimeslot;
int MonthlyProduct[Group] = ...;
int CycleTime[Group] = ...;
int CureTime[Group] = ...;
dvar int Assign[Group][Autoclave][Timeslot] in 0..1;
minimize
sum( g in Group, a in Autoclave, t in Timeslot ) t * Assign[g][a][t];
subject to {
forall (g in Group)
ct1:
sum( a in Autoclave, t in Timeslot )
Assign[g][a][t] == MonthlyProduct[g];
forall (g in Group)
forall (t in 1..(NbTimeslot-CycleTime[g]+1))
ct2:
sum( a in Autoclave, cy in 1..CycleTime[g] )
Assign[g][a][t+cy-1] <= 1;
forall( a in Autoclave, t in Timeslot )
ct3:
sum( g in Group, cu in 1..CureTime[g])
Assign[g][a][t-cu+1] <= 1;
}
tuple SolutionT{
int a;
int b;
int c;
int d;
};
{SolutionT} Solution = {<a0,b0,c0,Assign[a0][b0][c0]> | a0 in Group, b0 in Autoclave, c0 in Timeslot};
execute{
writeln(Solution);
}
答案 0 :(得分:0)
forall (g in Group)
forall (t in 1..NbTimeslot:t in (1..NbTimeslot-CycleTime[g]+1))
ct2:
sum( a in Autoclave, cy in 1..CycleTime[g] )
Assign[g][a][t+cy-1] <= 1;
forall( a in Autoclave, t in Timeslot )
ct3:
sum( g in Group, cu in 1..CureTime[g]: t-cu+1 in Timeslot)
Assign[g][a][t-cu+1] <= 1;
应该更好用