There are 22 drivers. Each driver has to work min of 7.6 hrs and can work max of 10 hrs. Each driver cost and productivity is different.
if some driver works overtime (more than 7.6 hrs), for first 2 hrs, we need to pay 1.5 times. For remaining 0.4 hrs, we need to pay 2 times.
195 hrs of work has to be completed by 22 drivers. We need to schedule in such a way that cost can be minimized.
Driver,Cost,Productivity
A,70,0.8
B,22,0.8
C,24,0.8
D,26,0.8
E,28,0.8
F,30,0.8
G,32,0.8
H,34,0.8
I,36,0.8
J,38,0.8
K,40,0.8
L,42,0.9
M,44,0.9
N,46,0.9
O,48,0.9
P,50,0.9
Q,52,0.9
R,54,0.9
S,56,0.9
T,58,0.9
U,60,0.9
V,62,0.5
Decision Variables:
X1,X2 ........X22 represents the total number of hours allocated to each driver
Objective Function:
Min Z = 20*X1 +22*X2......62*X22
Constraints:
X1>=7.6,X2>=7.6....X22>=7.6
X1<=10,X2<=10....X22<=10
X1+X2.....+X22 <= 195
I have tried following python program so far.
import pulp
import pandas as pd
def main():
model = pulp.LpProblem("Cost minimising scheduling problem", pulp.LpMinimize)
totalHours = 192
minHourEachDriver = 7.6
maxHourEachDriver = 10
# importing data from CSV
drivers = pd.DataFrame.from_csv('csv/drivers.csv', index_col=['Driver', 'Cost', 'Productivity'])
# Decision Variables
drv = pulp.LpVariable.dicts("driverName", indexs=((i) for i, j, k in drivers.index), lowBound=0,
cat='Continuous')
# Objective
model += pulp.lpSum([j * (1 / k) * drv[i] for i, j, k in drivers.index]), "Cost"
# Constraints
# total no of hours work to be done
model += pulp.lpSum([drv[i] for i, j, k in drivers.index]) == totalHours
for i, j, k in drivers.index:
# minimum hours driver has to work
model += drv[i] >= minHourEachDriver
# Maximum hour driver can work
model += drv[i] <= maxHourEachDriver
model.solve()
# model status
print(pulp.LpStatus[model.status])
# Total Cost
print(pulp.value(model.objective))
# No of hrs allocated to each driver
for i, j, k in drivers.index:
var_value = drv[i].varValue
# print(var_value)
print("The number hours for driver {0} are {1}".format(i, var_value))
if __name__ == '__main__':
main()
But, I am not able to figure out, how do we put following constraint.
if some driver work overtime (more than 7.6 hrs), for first 2 hrs, we need to pay 1.5 times. For remaining 0.4 hrs, we need to pay 2 times.