0
votes

Integer programming. I try to model the following constraint in Cplex:

i ∑(τ=s-Dur(i)+1)to s x_(i,r,t,τ) ≤1, ∀r,∀t,∀s〗

where x_(i,r,t,s) is the decision variable. The variable τ=s-Dur(i)+1 is used as auxiliary variable. It is not possible to model this sum including an array. Thank you.

 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;
}
1
You probably need to do some preprocessing to create different sets and subsets of values to use as index sets instead of the current way you are writing your sum. - TimChippingtonDerrick

1 Answers

0
votes

I would rewrite your constraint into

sum(i in I: s-Duration[i]+1 in S) (assignment[i][r][t][s-Duration[i]+1]) <= 1;

And

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

works fine

regards