Warehouse assignment in Python

$ 149,00


This product comprises a downloadable warehouse assignment model in Python and one training hour with me, in the form of a video call. I named this product “simple” warehouse assignment model because the customer and supplier locations in this model are created randomly. In other, more advanced versions of this model, I made it possible to import real-world customer locations through a csv-file and to visualize these locations on a map. Another simplification is that this model only considers one product and that periodicity is neglected (for example, a warehouse could source on-stock, and then serve its customers by consuming inventory over time – this is not included in this model). In yet another, even more advanced downloadable model, I implemented both multiple product types and periodicity. This model is for introductionary training purposes, while other more advanced products are for direct commercial application.

Warehouse assignment models optimize supply chains and their operations

Supply chain managers and supply chain network designers can reduce costs, increase customer satisfaction and end-to-end supply chain lead times by optimizing their warehouse assignments. Managers can do so by applying mathematical models and computational solvers. In combination, this approach allows supply chain managers to assign suppliers and customers to warehouses optimally.

In detail, this means:

  • Overall variable distribution costs in a supply chain are minimized
  • Demand constraints are satisfied, i.e. customers receive the products that they need in the desired quantity
  • Suppliers supply warehouses in accordance with the demand satisfied by the respective warehouse (on average), considering the correct products
  • Supplier relations and customer relations are simplified, allowing supplier to supply certain warehouses and a limited number of warehouses in total, and warehouses to supply certain customer groups and customer amounts

The results are higher profitability, reduced complexity and thus more streamlined operations.

A Python model to get started with warehouse assignment optimization in Python

I have developed an exemplary model in Python that you can use to model a supply chain and solve the warehouse assignment logic. You can purchase this model as a downloadable zip-file here.

The zip-file contains:

  • read-me file with documentation and usage instructions
  • py file for parametrizing the model, i.e. setting supply chain parameters
  • py file implementing the mathematical model and its solutions

On top of that the purchase of this product includes one hour of training with me, the model developer, in the form of a video call at a time that suits you best. If you do not need me to explain the model and its implementation, we can use this hour to adjust the code according to your needs instead, or to discuss other questions that you may have.

Details on the model and its assumptions and constraints

The model is parametrized and its parametrization comprises (i.e. works for any value):

  • number of warehouses
  • number of suppliers
  • number of customers
  • max capacity of any warehouse
  • min and max demand per customer
  • min and max supply per supplier
  • min and max distance between any warehouse and customer
  • min and max distance between any warehouse and supplier
  • how many warehouses a supplier can be assigned to
  • how many warehouses a customer can be assigned to

Parametrization is done by changing the values in the config.py file. This PYTHON script implements a model in which:

  • variable transportation costs are minimized
  • each supplier can only supply a limited amount of warehouses
  • each supplier can only supply up to its capacity
  • a warehouse can only supply up to its capacity
  • a warehouse can only source from supplier, if supplier is assigned to warehouse
  • a warehouse can only supply a customer, if customer is assigned to warehouse
  • a customer can only source from a specified maximum amount of warehouses
  • a customer demand must be satisfied
  • all supply to the warehouse must equal at least the demand satisfied by the warehouse

Exemplary model output

After having set the parameters in the config.py file, the model is executed by using the “python model.py” command in e.g. powershell or some other terminal.

Here is the output for the default model with 10 warehouses, 100 customers and 100 suppliers (during the video call we can adjust the way data is outputted. E.g. we can write the data into an Excel file instead):

Result - Optimal solution found

Objective value:                1173.00000000
Enumerated nodes:               0
Total iterations:               18
Time (CPU seconds):             0.41
Time (Wallclock seconds):       0.41

Option for printingOptions changed from normal to all
Total time (CPU seconds):       0.44   (Wallclock seconds):       0.44

supplier_warehouse_assignment_(11,_9) = 1.0
supplier_warehouse_assignment_(20,_4) = 1.0

.. all other assignments will be in output data in similar format ...

supplier_warehouse_assignment_(96,_7) = 1.0
supplier_warehouse_assignment_(99,_2) = 1.0

supplier_warehouse_transport_(11,_9) = 7.0
supplier_warehouse_transport_(20,_4) = 11.0

... all other transport volumes from suppliers to warehouses in output data in similar format ...

supplier_warehouse_transport_(95,_0) = 21.0
supplier_warehouse_transport_(96,_7) = 84.0

warehouse_customer_transport_(0,_2) = 1.0
warehouse_customer_transport_(0,_20) = 3.0

... all other transport volumes from warehouse to customers in output data in similar format ...
warehouse_customer_transport_(9,_60) = 8.0
warehouse_customer_transport_(9,_64) = 3.0

warehouse_supply_(0,_2) = 1.0
warehouse_supply_(0,_20) = 1.0

... all other warehouse to customer assignments in output data in similar format ...
warehouse_supply_(9,_60) = 1.0
warehouse_supply_(9,_64) = 1.0

Total cost = 1173.0

Learn more about mathematical modeling and network design

You can learn more about mathematical modeling and its application to network design by reading some related SCDA articles:



There are no reviews yet.

Be the first to review “Warehouse assignment in Python”

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.