A post office requires different numbers of full-time employees on different days of the week. The number of full-time employees required on each day is given in Table 4. Union rules state that each full-time employee must work five consecutive days and then receive two days off. For example, an employee who works Monday to Friday must be off on Saturday and Sunday. The post office wants to meet its daily requirements using only fulltime employees. Formulate an LP that the post office can use to minimize the number of full-time employees who must be hired.
Day | Number of Full-Time Emplyees Requiremed |
---|---|
Mon | 17 |
Tue | 13 |
Wed | 15 |
Thur | 19 |
Fri | 14 |
Sat | 16 |
Sun | 11 |
In [4]:
from gurobipy import *
days = ["Mon", "Tue", "Wed", "Thur", "Fri", "Sat", "Sun"]
assignment_FTE = [
[1,0,0,1,1,1,1],
[1,1,0,0,1,1,1],
[1,1,1,0,0,1,1],
[1,1,1,1,0,0,1],
[1,1,1,1,1,0,0],
[0,1,1,1,1,1,0],
[0,0,1,1,1,1,1]
]
requried_FTE = [17,13,15,19,14,16,11]
# Model
m = Model("post_office_problem")
day_assignment = []
for l in range(len(days)):
day_assignment.append(
m.addVar(obj = 1, vtype=GRB.INTEGER, name="(%s)" % (days[l])))
m.modelSense = GRB.MINIMIZE
m.update()
for l in range(len(days)):
m.addConstr(
quicksum(assignment_FTE[l][c] * day_assignment[c]for c in range(len(days))) >= requried_FTE[l],
"day requirment %s" % days[l])
m.optimize()
for v in m.getVars():
print (v.varName, v.x)
print (m.getObjective().getValue())
In [ ]: