Constraints of case study exercise
Continue the case study of the Capacitated Plant Location model of a car manufacture. You are given four Pandas data frames demand
, var_cost
, fix_cost
, and cap
containing the regional demand (thous. of cars), variable production costs (thous. $US), fixed production costs (thous. $US), and production capacity (thous. of cars). Two python lists loc
, and size
have also been created, containing the different locations, and the two types of plant capacities. All these variables have been printed to the console for your viewing. The code to initialize the decision variables, define them and create the objective function has been completed for you.
This exercise is part of the course
Supply Chain Analytics in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Initialize, Define Decision Vars., and Objective Function
model = LpProblem("Capacitated Plant Location Model", LpMinimize)
loc = ['USA', 'Germany', 'Japan', 'Brazil', 'India']
size = ['Low_Cap','High_Cap']
x = LpVariable.dicts("production_", [(i,j) for i in loc for j in loc],
lowBound=0, upBound=None, cat='Continuous')
y = LpVariable.dicts("plant_",
[(i,s) for s in size for i in loc], cat='Binary')
model += (lpSum([fix_cost.loc[i,s] * y[(i,s)] for s in size for i in loc])
+ lpSum([var_cost.loc[i,j] * x[(i,j)] for i in loc for j in loc]))
# Define the constraints
for j in loc:
model += lpSum([____ for i in ____]) ____ demand.loc[____,'Dmd']