How to #6: Solving an imbalanced multi-commodity transportation problem

Adam Davis
3 min readJun 23, 2023
The Gare St-Lazare -Claude Monet

“I have such a desire to do everything, my head is bursting with it.” — Monet

In the field of operations research there is a common situation to get past known as a transportation problem. The problem starts with a group of locations with a demand of a product that is held in supply at a group of suppliers. The goal generally is to minimize the amount of time that it takes for the demanded products to come from the suppliers to the end locations. This seen as the “cost” to minimize, which can be either money or time.

This article is on solving a multi-commodity which means multiple different products sent from the supplier to the locations with orders. In this case one of the main purposes is to remove the need for explicitly programming the demand greater than the supply or vice versa. The model should be able to adjust itself accordingly. This was written in Python with PuLP as it is a standerd linear program which lends itself well to using PuLP.

Example of possible cost of shipping to destination from supplier

A dummy variable is needed for supply if demand is greater than supply. A dummy variable is needed for demand if supply is greater than demand. A good way to think about this is by having an extra supplier and destination be inventory or a category to let the destination know to order more product and in what amount.

This will make sense in reverse: the DEST variable if short of supply in a category will then enter the remaining product amount needed as “Order_More”. Conversely if a supplier has extra unused supply in a category that will appear in the results as “Inventory”. A sample of each is as follows:

This is achieved by solving the problem in the standard way in PuLP:

By using two dummy variables both possible imbalanced cases are handled. The “Order_more” supplier will then show up for each destination if the supply needed is more for any good that demand exists. The “Inventory” variable then also shows what supply there still exists left over.

Another aspect of this is the way that the end results will be disseminated . A possibility is to have one csv file for each destination and also one for all the suppliers in case there is inventory left over. Code is as follows:

The above will out put the preceding tables showing for each destination as well as the amount needed to order by each separate destination of each separate product as well as the possible inventory per supplier per product if there is any.

--

--