Question: Adapt the code with the new information provided We have feedback from our drivers that we need to allow an extra 1 5 minutes between

Adapt the code with the new information provided We have feedback from our drivers that we need to allow an extra 15 minutes between pairs of farms on a milk run. Additionally, we need to allow 60 minutes cleaning time between milk runs made by the same tanker.
Taking these times into account, which of the milk runs should we now use? Please provide us with the minimum total cost of collections.
The previuos code is:
from gurobipy import *
from Milkruns import Milkruns
# Farms
farms =['Cowbell', 'Creamy Acres', 'Milky Way', 'Happy Cows', 'Udder Delight', 'Fresh Pail', 'Cowabunga', 'Utopia', 'Moo Meadows', 'Bluebell', 'Harmony', 'Velvet Valley', 'Moonybrook', 'Cloven Hills', 'Midnight Moo', 'Willows Bend', 'Moosa Heads', 'Dreamy Dairies', 'Happy Hooves', 'Highlands']
F= range(len(farms))
# Supply from each farm
Supply =[9100,6100,6500,9400,6800,6900,4300,3000,5000,4700,3600,3000,3700,3300,3300,3200,4700,3400,4000,3400]
# Processing facilities
facilities =['P1','P2','P3']
P=range(len(facilities))
Tankers = range(5)
#Data Milkruns
#R[0]- facility tanker must leave from
#R[1]- list of farms visited
#R[2]- total time taken(mins)
#R[3]- total cost of milk run($)
R = range(len(Milkruns))
# Processing facility capacities
PMin =[19000,25000,19000]
PMax =[35000,43000,43000]
# Create a new model
m = Model("Teal Cow Dairy")
#VARIABLES
#binary variable-1 if milkrun r is assigned to tanker k at facility j
X ={(j,k,r): m.addVar(vtype= GRB.BINARY) for r in R for j in P for k in Tankers}
#binary variable -1 if tanker k is part of the fleet at processing facility j
Z ={(j,k): m.addVar(vtype=GRB.BINARY) for k in Tankers for j in P}
#OBJECTIVE: Minimise total cost of collections
m.setObjective(quicksum(Milkruns[r][3]* X[j, k, r] for r in R for j in P for k in Tankers)+
quicksum((500-30* k)* Z[j, k] for k in Tankers for j in P), GRB.MINIMIZE)
#Constraints
#each milkrun is assigned to one tanker at a processing facility
for r in R:
m.addConstr(quicksum(X[j,k,r] for j in P for k in Tankers if j != Milkruns[r][0])==0)
#each farm i is srvicied by exactly one milkrun
for i in F:
m.addConstr(quicksum(X[j,k,r] for j in P for k in Tankers for r in R if i in Milkruns[r][1])==1)
for j in P:
#Processing capacity constraint
m.addConstr(quicksum(Supply[i]*X[j,k,r] for r in R for k in Tankers for i in Milkruns[r][1])>= PMin[j])
m.addConstr(quicksum(Supply[i]*X[j,k,r] for r in R for k in Tankers for i in Milkruns[r][1])<= PMax[j])
for k in Tankers:
#each tanker can only be used for 10 hours
m.addConstr(quicksum(Milkruns[r][2]*X[j,k,r] for r in R)<=600*Z[j,k])
#unlock tankers in order and check if total timeis within the limits
if k>0:
m.addConstr(Z[j,k]<= Z[j,k-1])
m.addConstr(quicksum(Milkruns[r][2]*X[j,k-1,r] for r in R)>=600*Z[j,k])
#each milkrun r is assigned to at most one processing facility and a tanker
for r in R:
m.addConstr(quicksum(X[j,k,r] for j in P for k in Tankers)<=1)
m.optimize()
print("Min total cost of collection: ", m.ObjVal)
Consider this info :
When the questions states 'extra 15 minutes between pairs of farms on a milk run', does this mean if there are 2 farms, it will take 15 minutes and if there are 3 farms, it will take 30 minutes to unload the milk
So a tanker doing three milk runs would require 120 minutes of cleaning, while a tanker doing a single run would require no cleaning during the day (it can be done at night, before the next day).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!