Transportation Problem: Balancing

This is part of the course “Optimization for Programmers”.

Image for post
Image for post
GitHub Repository with Source Code

Introduction

Transportation Simplex Method works with a balanced transportation problem. Therefore we need to learn how to make problem balanced if it is not such. And it means to cover two cases — when supply is less than demand and otherwise.

Supply Less Than Demand

Image for post
Image for post
40 + 30 < 30 + 50

Here we can see that supply is less than demand. In such a case, we add a fake origin (d₃=10) so that supply became equal to demand. Values c₃₁, c₃₂ represent financial loss related to unmet demand.

Image for post
Image for post
c₃₁ = 3. It can mean that the first customer will lose 3$ with each not shipped unit.

Demand Less Than Supply

Image for post
Image for post
40 + 30 > 30 + 30

Here we can see that demand is less than supply. In such a case we add a fake destination (s₃ = 1) so that supply became equal to demand. for unused capacity there no cost involved therefor values c₁₃ and c₂₃ are equal to 0.

Image for post
Image for post

Programming

Let’s write a simple function that receives a transportation problem and returns its balanced version. When supply less than demand we also need to pass penalties(financial losses related to unmet demands).

Next part ->

Reach the next level of focus and productivity with increaser.org.

Image for post
Image for post
Increaser

Written by

Software engineer, creator of increaser.org. More at geekrodion.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store