# ILOG Cplex out of scope

 int nbPilots = 50;
int nbLocations = 7;
int nbDays = 30;

range pilots = 1..nbPilots;
range days = 1..nbDays;
range locations = 1..nbLocations;

/*decision variable*/
dvar boolean assign [pilots][days][locations] ;
dvar boolean rest [pilots][days][locations];

/*objective*/
minimize sum(i in pilots, j in days, l in locations)assign[i][j][l];

/*constraints*/
subject to{

//Kısıt-2: Her pilotun art arda gelen 6 gün içerisinde asgari 1 gün boş bırakılması kısıtı
//forall(i in pilots, j in days, l in locations)(rest[i][j][l]+rest[i][j+1][l]+rest[i][j+2][l]+rest[i][j+3][l]+rest[i][j+4][l]+rest[i][j+5][l]+rest[i][j+6][l]>=1);

forall(i in pilots, j in days, l in locations)(assign[i][j][l]+assign[i][j+1][l]+assign[i][j+2][l]+assign[i][j+3][l]+assign[i][j+4][l]+assign[i][j+5][l]+assign[i][j+6][l]+rest[i][j+7][l]+rest[i][j+8][l] == 9);
}


how can i handle that [j+8] is also in days <=30

      int nbPilots = 50;
int nbLocations = 7;
int nbDays = 30;

range pilots = 1..nbPilots; range days = 1..nbDays; range locations = 1..nbLocations;

//decision variable/

dvar boolean assign [pilots][days][locations] ; dvar boolean rest [pilots][days][locations];

//objective/

minimize sum(i in pilots, j in days, l in locations)assign[i][j][l];

//constraints/
subject to{

forall(i in pilots, j in days, l in locations:(j+8) in days)
(assign[i][j][l]+assign[i][j+1][l]+assign[i][j+2][l]+assign[i][j+3][l]+
assign[i][j+4][l]+assign[i][j+5][l]+assign[i][j+6][l]+rest[i][j+7][l]+rest[i][j+8][l] == 9);

}


works better

• no value for assign and rest.. Apr 30 '20 at 20:03
• execute { writeln(assign); } May 1 '20 at 8:15
• nothing changed, no value for assign and rest May 2 '20 at 12:40