# Transportation Problem Solver (Min-Cost Flow)

Balanced transportation problems as min-cost flow: successive shortest paths, MODI duals, reduced-cost optimality certificate, and full shipping plan.

> Canonical page: https://elysiatools.com/en/tools/transportation-problem

- **Category:** Math & Numbers

- **Keywords:** transportation problem, min cost flow, minimum cost flow, modi method, uv method, dual variables, operations research, logistics, shipping plan, supply demand

## Overview

The Transportation Problem Solver calculates the minimum-cost shipping plan for balanced supply-and-demand networks using successive shortest path augmentations and the MODI (u-v) method. It verifies global optimality by generating reduced costs, dual variable potentials, and an itemized shipment allocation matrix.

## Inputs

- **Cost matrix (rows = sources, one per line)** (textarea): Unit shipping cost from each source (row) to each destination (column). 2–8 rows × 2–8 columns.
- **Supply (per source)** (text): Amount available at each source, one per matrix row (non-negative).
- **Demand (per destination)** (text): Amount required at each destination, one per matrix column (non-negative).
- **Decimal Places** (number)

## When to use

- Determining optimal distribution allocations from multiple production sources to regional demand points.
- Checking manual operations research homework solutions involving the MODI method, stepping-stone method, or u-v dual variables.
- Validating minimum-cost flow calculations and inspecting reduced-cost optimality certificates.

## How it works

- Enter the unit cost matrix with one row per supply source (2–8 rows) and comma-separated values for destination columns (2–8 columns).
- Specify the non-negative available capacities in the Supply field and required quantities in the Demand field, ensuring both sums are equal.
- Set the desired decimal precision for flow allocations and dual values, then compute the solution.
- Review step-by-step min-cost flow augmentations, the complete shipping allocation grid, and the MODI dual variables (u, v) certifying optimality.

## Use cases

- Multi-warehouse logistics route planning to minimize total freight expenses across distribution centers.
- Operations research coursework verification for linear programming transport problems and MODI optimality tests.
- Supply chain allocation modeling between regional manufacturing plants and retail fulfillment hubs.

## Frequently asked questions

### What should I do if total supply does not equal total demand?

Add a dummy supply source or dummy demand destination with zero (or penalty) unit shipping costs to balance total supply and total demand before running the solver.

### What matrix sizes are supported by the solver?

The tool supports matrices ranging from 2 to 8 supply rows by 2 to 8 destination columns.

### What algorithm does this tool use to find the optimal shipping plan?

It models the network as a minimum-cost flow problem, using successive shortest path augmentations with SPFA and computing MODI dual variables (u_i, v_j) for optimality verification.

### How do MODI dual variables certify optimality?

An allocation is optimal when the reduced cost (cost minus u_i minus v_j) is zero on all basic routed cells and non-negative on all non-basic cells.

### Can I use decimal values for costs, supply, and demand?

Yes, numerical values with decimals are supported, and the decimal precision option adjusts output formatting accordingly.

## Related tools

- [Linear Programming Simplex Solver (Two-Phase)](https://elysiatools.com/en/tools/linear-programming-simplex): Two-phase simplex for 2–6 variables and 1–8 ≤/≥/= constraints: Bland's rule, per-iteration pivot log, optimal/unbounded/infeasible status, and substitution checks.
- [Shaft Critical Speed Calculator](https://elysiatools.com/en/tools/shaft-critical-speed): Calculate the critical (resonance) speed of a rotating shaft using the single-DOF rotor model. ω_n = √(k/m), n_cr = (60/2π)·√(k/m) rpm. Also returns the natural frequency f_n in Hz.
- [PDF PAdES Certificate Signer](https://elysiatools.com/en/tools/pdf-pades-certificate-signer): Sign PDFs with a PKCS#12 certificate using an ETSI CAdES detached signature.
- [Primitive Root Finder](https://elysiatools.com/en/tools/primitive-root-finder): Smallest primitive root mod n with certificate g^(φ/q) ≠ 1, root count φ(φ(n)), up to 50 listed roots, and candidate verification. n ≤ 10¹².
- [Quadratic Residue Checker (Legendre / Jacobi Symbol)](https://elysiatools.com/en/tools/quadratic-residue-checker): Jacobi/Legendre symbol with deterministic Miller–Rabin primality, Tonelli–Shanks square roots for prime moduli, and brute-force resolution for small composite moduli.
- [Scientific Calculator](https://elysiatools.com/en/tools/scientific-calculator): Advanced scientific calculator with support for complex mathematical functions and expressions
- [Spring Rate Calculator](https://elysiatools.com/en/tools/spring-rate-calculator): Calculate the stiffness (spring rate) of a cylindrical helical compression/extension spring. k = G·d⁴ / (8·D³·n) in N/mm. Includes shear-modulus presets for common spring materials.
- [Young's Modulus Calculator](https://elysiatools.com/en/tools/youngs-modulus-calculator): Solve Young's modulus (modulus of elasticity) in the linear-elastic region using E = σ/ε (Hooke's law). Three directions: modulus E = σ/ε, stress σ = E·ε, strain ε = σ/E. Pick the unknown, supply the other two positive values. Result in MPa with a GPa reading (e.g. steel ≈ 200 000 MPa).

## Samples

- [Android Image Processing Java Samples](https://elysiatools.com/en/samples/android-image-processing-java): Android Java image processing examples including reading/saving images, scaling, and format conversion
- [Android Image Processing Kotlin Samples](https://elysiatools.com/en/samples/android-image-processing-kotlin): Android Kotlin image processing examples including reading/saving images, scaling, and format conversion
- [Web Image Processing Python Samples](https://elysiatools.com/en/samples/web-image-processing-python): Web Python image processing examples using PIL/Pillow including reading, saving, resizing, and format conversion
- [Web Image Processing Rust Samples](https://elysiatools.com/en/samples/web-image-processing-rust): Web Rust image processing examples including image read/save, scaling, and format conversion
