整数编程。 我尝试在Cplex中建模以下约束:
ΣiΣ(τ= s-Dur(i)+1)到s x_(i,r,t,τ)≤1,∀r,∀t,∀s〗< / p>
其中x_(i,r,t,s)是决策变量。 变量τ= s-Dur(i)+1用作辅助变量。 无法对此总和进行建模,包括数组。谢谢。
range I = 1..operations;
range J = 1..surgeons;
range T = 1..timeBlock;
range S = 1..timePeriod;
range R = 1..room;
int Duration[I] =...;
//DVars
dvar int assignment[I][R][T][S] in 0..1;
//Objective function
maximize sum (i in I, r in R, t in T, s in S) (Duration[i] * assignment[i][r][t][s]);
// constraint
forall (r in R, t in T, s in S)
{
sum(i in I, s-Duration[i]+1 in s) (assignment[i][r][t][s-Dur[i]+1]) <= 1;
}
答案 0 :(得分:0)
我会将你的约束重写为
sum(i in I: s-Duration[i]+1 in S) (assignment[i][r][t][s-Duration[i]+1]) <= 1;
和
int operations=2;
int surgeons=3;
int timeBlock=2;
int timePeriod=2;
int room=4;
range I = 1..operations;
range J = 1..surgeons;
range T = 1..timeBlock;
range S = 1..timePeriod;
range R = 1..room;
int Duration[i in I] =i;
//DVars
dvar int assignment[I][R][T][S] in 0..1;
//Objective function
maximize sum (i in I, r in R, t in T, s in S) (Duration[i] * assignment[i][r][t][s]);
subject to
{
// constraint
forall (r in R, t in T, s in S)
{
sum(i in I: s-Duration[i]+1 in S) (assignment[i][r][t][s-Duration[i]+1]) <= 1;
}
}
工作正常
问候