GenerateRandomSearch

Transportation Problem Generator

Several warehouses, several destinations, a different shipping cost for every route, and supply that exactly matches demand. The classical starting methods — north-west corner, least cost — give you a feasible plan quickly, and the standard teaching point is that feasible is not the same as cheapest. This page makes that concrete: it solves the problem greedily and then, where the size allows, searches every possible plan and reports the gap.

What this generator does

Builds supplies and demands that balance exactly, assigns a random cost to every route, and fills the cheapest available cell repeatedly until everything is shipped. It verifies that every source ships exactly its supply and every destination receives exactly its demand, then searches all integer plans where the problem is small enough and reports the cheapest one found.

How to use this tool

  1. Choose how many sources and destinations.
  2. Try to build a cheap plan yourself, respecting every supply and demand exactly.
  3. Generate, and compare your total against the least-cost rule's.
  4. Read whether exhaustive search found something cheaper — often it does.

Understanding the controls

How many sources
Between 2 and 5 warehouses. Larger problems quickly exceed what exhaustive search can confirm.
How many destinations
Between 2 and 5 delivery points, each with a demand that the total supply exactly covers.
Seed
Any word reproduces the same costs, supplies and demands.

Common use cases

  • Teaching the transportation problem with the greedy-versus-optimal gap made visible
  • Worked logistics examples with verified feasibility
  • Showing why a starting solution needs a second optimisation stage
  • Test instances for a transportation or min-cost-flow implementation
  • Setting a reproducible exercise from a seed

How this generator works

The least-cost rule repeatedly finds the cheapest route with supply and demand still outstanding and ships as much as it can along it. That always produces a feasible plan and often not the cheapest one. The exhaustive search enumerates integer shipment plans with pruning on cost, bounded so it cannot run away, and returns null rather than a guess when the problem is too large — in which case the page says the answer is unconfirmed.

Randomness and fairness

Supplies, demands and costs are random; the plan and its cost are computed and checked for feasibility. A seed reproduces the problem exactly and is therefore explicitly not cryptographically secure. Without a seed the browser's cryptographically secure generator is used.

For how randomness is produced across the whole site, see how Generate Random works.

Limitations and good to know

  • Balanced problems only — unbalanced ones need a dummy source or destination.
  • Exhaustive confirmation is only attempted on small grids; larger ones are reported as unconfirmed.
  • The stepping-stone and MODI improvement methods are not implemented; this shows the gap rather than closing it.
  • Costs are per unit with no fixed charge per route used.
  • Instances are not kept, so seed one you intend to set as an exercise.

Privacy and your data

The problem and every plan are computed entirely in your browser. Nothing about the figures or your seed is transmitted or kept.