Learn practical skills, build real-world projects, and advance your career

Warehouse Location Problem

BBasket is an Indian corporation which operates a chain of membership-only grocery clubs. Currently they have thousands of customers in the following locations: Bangalore, Chennai, Hyderabad and Pune. They want to open two warehouses from the given list of locations available to them : Anantapur, Mysore and Vellore. Following is the distance given between warehouse and the customer city. As an analyst, provide them a solution to have minimum total cost of serving all the customers. A customer location can be served by only 1 active warehouse. The table below shows distances between cities in kilometres.

W / CHyderabadChennaiBangalorePune
Anantpur422482215882
Mysore797482144934
Vellore7791572011138

Mathematical formulation / Pyomo components


Sets:

To define the indexes for the given problem

  • Warehouse location, wWw \in W
  • Customer location, cCc \in C

Parameters:

  • Distance between each pair of warehouse-customer location - dw,c\text {d}_{w,c}
  • Maximum number of warehouses that can be opened - P

Decision variables:

  • Binary/Boolean variable for warehouse supplying to a customer location

xw,c  where  0xw,c1cC,wW{x}_{w,c} \ \ where \ \ 0 \leq x_{w,c} \leq 1 \,\,\,\,\,\,\,\,\, \forall c \in C, w \in W

  • Binary/Boolean variable for active warehouse location

yw  where  yw{0,1}wW{y}_{w} \ \ where \ \ y_{w} \in \{0,1\} \,\,\,\,\,\,\,\,\, \forall w \in W


Objective:

To minimize the sum of distances between the warehouses and customer locations

\begin{align}
\textrm {min}\sum \limits {w,c} \text {d}{w,c} * \text {x}_{w,c}
\end{align}


Constraints:

  • One customer location can be satisfied by only one warehouse

wWxw,c=1cC\sum_{w \in W} x_{w,c} = 1 \,\,\,\,\,\,\,\,\, \forall c \in C

  • Customer location can get goods from only active warehouse

xw,cywcC,wWx_{w,c} \leq y_{w} \,\,\,\,\,\,\,\,\, \forall c \in C, w \in W

  • Active warehouses should be less than or equal to the required number of warehouses

wWyw<=P\sum_{w \in W} y_{w} <= P

Step1:

Import Pyomo Environment

#Importing Pyomo environment and other required libraries

from pyomo.environ import *

import pandas as pd

Step2:

Specify / import data