1
$\begingroup$
 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

$\endgroup$
2
$\begingroup$
      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

$\endgroup$
3
  • $\begingroup$ no value for assign and rest.. $\endgroup$
    – Eyyüb
    Apr 30 '20 at 20:03
  • $\begingroup$ execute { writeln(assign); } $\endgroup$ May 1 '20 at 8:15
  • $\begingroup$ nothing changed, no value for assign and rest $\endgroup$
    – Eyyüb
    May 2 '20 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.