Hello,

I'm trying to develop a model that allocates the workforce in a railway system for my graduation thesis. I'm completely new to GAMS and cant really figure out what to do. Guides on youtube are so basic and not really helpful. There are 91 train drivers and almost 60 shifts. Shifts are day/night and numbers 1-30 implies morning shifts in each day and number 31-60 implies night shifts. In each day all shifts needs to be assigned to 1 driver.

1-) A driver cant work more than 4 consecutive days. And can only work for one shift a day.

2-) A driver should rest for 2 days after 4 days of work.

3-) Shift numbers that assigned to drivers should be consecutive ;

1-2-3-4 OK , 1-3-6-8 NOT OK

4-) After a week full of day shifts a driver must get night shifts.

1-2-3-4-REST-REST-31-32-33-34-REST-REST-5-6-7-8

And so on.

Right now i dont have enough information to develop this model on my own and really open for advices. Here's what comes to my mind after a while.

SET

dri driversi /dr1*dr91/

day days /d1*d30/

sh shifts /s1*s60/

d(sh) day shifts /s1,s30/

n(sh) night shifts /s31*s60/

;

BINARY VARIABLE

x(dri,day,sh);

## Workforce Allocation

### Re: Workforce Allocation

Hello again, after a hard trying i was able to build a model like this and so far it works,

but there are some constraints that i cant implement to the model.

Which are resting days, and ordering of shifts.

I want the model to make drivers rest 2 days after 4-5 days of working , and i want the model to assign shifts in order like ;

k1-k2-k3-k4-rest-rest... after that a full night shift must come like k1-k2-k3-k4-rest-rest-k31-k32-k33-k34-rest-rest-k5-k6 .....

SET

i drivers /i1*i91/

j days /j1*j30/

k shifts /k1*k30

k45*k75/

h(k) day shifts /k1*k30/

n(k) night shifts /k45*k75/

;

BINARY VARIABLE

x(i,j,k)

;

VARIABLE

z obj variable

;

EQUATIONS

con1(i,j) max shifts for a driver in a day

con2(i,k) a driver can get a shift only once in a planning period

con3(k,j) only 1 driver can get a certain shift in a day

con4(i) max working days for period

con5(i) min working days for period

Obj

;

con4(i).. sum([j,k],x(i,j,k)) =l=23;

con5(i).. sum([j,k],x(i,j,k)) =g=20;

con1(i,j).. sum([k],x(i,j,k)) =l=1;

con2(i,k).. sum((j),x(i,j,k)) =l=1;

con3(k,j).. sum(

but there are some constraints that i cant implement to the model.

Which are resting days, and ordering of shifts.

I want the model to make drivers rest 2 days after 4-5 days of working , and i want the model to assign shifts in order like ;

k1-k2-k3-k4-rest-rest... after that a full night shift must come like k1-k2-k3-k4-rest-rest-k31-k32-k33-k34-rest-rest-k5-k6 .....

SET

i drivers /i1*i91/

j days /j1*j30/

k shifts /k1*k30

k45*k75/

h(k) day shifts /k1*k30/

n(k) night shifts /k45*k75/

;

BINARY VARIABLE

x(i,j,k)

;

VARIABLE

z obj variable

;

EQUATIONS

con1(i,j) max shifts for a driver in a day

con2(i,k) a driver can get a shift only once in a planning period

con3(k,j) only 1 driver can get a certain shift in a day

con4(i) max working days for period

con5(i) min working days for period

Obj

;

con4(i).. sum([j,k],x(i,j,k)) =l=23;

con5(i).. sum([j,k],x(i,j,k)) =g=20;

con1(i,j).. sum([k],x(i,j,k)) =l=1;

con2(i,k).. sum((j),x(i,j,k)) =l=1;

con3(k,j).. sum(

*,x(i,j,k)) =e=1;*

obj.. z =e= sum((i,j,k),x(i,j,k));

MODEL ALLOCATION /all/

SOLVE ALLOCATION using mip minimizing z ;obj.. z =e= sum((i,j,k),x(i,j,k));

MODEL ALLOCATION /all/

SOLVE ALLOCATION using mip minimizing z ;