I hope you are doing well.
I am currently teaching myself Python and I've ran into a snag with Pulp. I am struggling to solve the model.
Any help would be much appreciated with solving this.
Scenario:
You are consulting for kitchen oven manufacturer helping to plan their logistics for next month. There are two warehouse locations (New York, and Atlanta), and four regional customer locations (East, South, Midwest, West). The expected demand next month for East it is 1,800, for South it is 1,200, for the Midwest it is 1,100, and for West it is 1000. The cost for shipping each of the warehouse locations to the regional customer's is listed in the table below. Your goal is to fulfill the regional demand at the lowest price.
Customer New York Atlanta East $211 $232 South $232 $212 Midwest $240 $230 West $300 $280
Two Python dictionaries costs and var_dict have been created for you containing the costs and decision variables of the model.
{('New York', 'East'): 211, ('New York', 'South'): 232, ('New York', 'Midwest'): 240, ('New York', 'West'): 300, ('Atlanta', 'East'): 232, ('Atlanta', 'South'): 212, ('Atlanta', 'Midwest'): 230, ('Atlanta', 'West'): 280}```
```print(var_dict)
{('New York', 'East'): ne, ('New York', 'South'): ns, ('New York', 'Midwest'): nm, ('New York', 'West'): nw, ('Atlanta', 'East'): atle, ('Atlanta', 'South'): atls, ('Atlanta', 'Midwest'): atlm, ('Atlanta', 'West'): atlw}```
My code that I ran thus far:
```from pulp import *
# Initialize Model
model = LpProblem("Minimize Transportation Costs", LpMinimize)
# Build the lists and the demand dictionary
warehouse = ['New York', 'Atlanta']
customers = ['East', 'South', 'Midwest', 'West']
regional_demand = [1800, 1200, 1100, 1000]
demand = dict(zip(customers, regional_demand))
# Define Objective
model += lpSum([costs[(w, c)] * var_dict[(w, c)]
for c in customers for w in warehouse])
# For each customer, sum warehouse shipments and set equal to customer demand
for c in customers:
model += lpSum([var_dict[(w, c)] for w in warehouse]) == demand[c]
model.solve()
print("Fulfill regional demand at {} price".format(costs[var_dict]))```