Solving the Transportation Problem: Northwest Corner, VAM and MODI Step by Step
How to build a first shipping plan with northwest corner, least cost or Vogel's method, then reach the optimal plan with MODI iterations and loops.

The transportation problem is one of the first optimisation models taught in operations research, and it appears in almost every exam on the subject. Several factories hold stock, several shops or warehouses need it, and each route has a cost per unit. The aim is the cheapest plan that uses no more than each source holds and meets every demand. The method has two stages and quite a lot of bookkeeping, so this guide explains each step and how the free Transportation Problem Solver shows the working.
Setting up the table
Draw a grid with one row per source and one column per destination. Each cell holds the cost of shipping one unit along that route. Add the supply of each source at the end of its row and the demand of each destination at the bottom of its column.
Check that total supply equals total demand. If supply is larger, add a dummy destination that absorbs the surplus at zero cost; units sent there are simply left in stock. If demand is larger, add a dummy source; units shipped from it are demand that cannot be met. The solver adds the dummy for you and labels it clearly.
If a route is impossible, mark its cell with M, meaning a very large cost. The optimal plan will avoid it whenever another route can do the job.
Stage one: a starting plan
Every method fills cells one at a time, giving each chosen cell as much as its row supply and column demand allow, then crossing out whichever is used up.
The northwest corner rule always starts in the top-left cell and moves right or down. It ignores costs completely, which makes it quick but usually far from optimal.
The least cost method always picks the cheapest remaining cell. It tends to give a much better start, though an early cheap choice can force expensive ones later.
Vogel's approximation method looks one step ahead. For every row and column it computes a penalty: the difference between the two smallest remaining costs. A large penalty means that missing the cheapest cell in that line would be costly, so the method allocates to the cheapest cell of the line with the largest penalty. Penalties are recomputed after every allocation. In the solver's initial tab you can step through each allocation and see the penalty column and row exactly as you would write them on paper.
Counting basic cells
A proper starting plan, called a basic feasible solution, uses exactly m + n − 1 cells, where m is the number of sources and n the number of destinations. Sometimes a row and a column are used up at the same moment, and the plan ends up one cell short. This is called degeneracy. The fix is to add a cell carrying zero, written ε, chosen so that it does not form a closed loop with the others. The solver does this automatically and explains which cell it added.
Stage two: MODI
The modified distribution method tests whether the current plan can be improved. Give each row a number u and each column a number v such that, for every used cell, u plus v equals its cost. Start with the first u equal to zero and the rest follow one by one.
For every empty cell, compute the reduced cost: its cost minus u minus v. This tells you how much the total would change if one unit were shipped along that route. If every reduced cost is zero or positive, no route can save money and the plan is optimal. Otherwise the cell with the most negative value enters.
Next, trace a closed loop that starts at the entering cell and turns only at used cells, alternating plus and minus signs. The amount moved, θ, is the smallest quantity sitting on a minus cell. Add θ on plus cells, subtract it on minus cells, and the cell that drops to zero leaves the plan. Then repeat with new u and v values.
A worked example
The solver's first sample is a classic textbook problem with three sources and four destinations. The northwest corner rule starts at a total cost of 520. In the first MODI iteration the route from the third source to the first destination has a reduced cost of −9, five units move around the loop, and the cost falls to 475. One more iteration reaches the optimum of 435. Vogel's method and the least cost method both start at 475 and need only one iteration. The MODI tab lets you move between iterations and highlights the entering cell, the loop signs and the leaving cell on the grid.
Profit and other variations
Some exercises give profits instead of costs. Tick the profit option and the solver converts each profit into a regret, the largest profit minus that profit, minimises the regret, and reports the plan and the total profit in the original figures.
Checking your answer
After working a problem by hand, compare each stage with the solver: the starting cost from your chosen method, the u and v values, the reduced costs and the final plan. A mismatch usually comes from a missed degenerate cell or a loop that turns at an empty cell. The full working can be printed, and the final plan can be saved as a CSV file or a network diagram.


