AI Glossary / Computer vision and multimodal AI / Advanced
Optimal transport
Definition
Optimal transport is a mathematical framework for finding the least costly way to redistribute one distribution of mass into another, according to a specified cost of moving mass between locations. In AI, the mass often represents probability or feature weights rather than physical goods.
What it means
Two datasets can differ not only in how much probability each location receives, but also in how far their locations are from one another. Optimal transport makes that geometry part of the comparison. Moving probability a short distance can be treated differently from moving the same amount a long distance.
The word “optimal” is conditional. The result is optimal for the supplied cost, constraints and mathematical formulation. A badly chosen representation or cost can produce a mathematically correct answer that does not reflect the application's meaning.
Transport can describe a plan that splits mass across destinations. It should not be assumed to provide a one-to-one pairing between objects, nor does a computed coupling establish that one real-world population caused another.
How it works
In a discrete balanced problem, the source has nonnegative weights a and the target has nonnegative weights b with equal totals. A cost matrix assigns a cost to every allowed source-to-target movement. The transport plan contains nonnegative amounts whose row sums equal a and whose column sums equal b.
The objective sums each transported amount multiplied by its movement cost. This is the Kantorovich formulation, which permits splitting. A transport-map formulation imposes a more restrictive point-to-point mapping structure.
Algorithms may solve the discrete linear program directly or use a regularized formulation. Entropic regularization changes the objective and can support efficient iterative computation, so its result should not be silently described as the exact unregularized solution.
Unbalanced variants relax the requirement to preserve both marginals exactly, with additional penalties or constraints. They address a different modeling choice rather than simply ignoring a mass mismatch.
Three practical examples
- An imaging experiment compares color distributions using distances between colors, while recognizing that a color histogram alone omits spatial arrangement.
- A machine-learning study aligns weighted feature distributions from two datasets, evaluating whether the alignment improves its intended task.
- A shape-analysis workflow compares distributions of sampled points, with the movement cost defining which geometric differences matter.
Think of it this way
Think of redistributing stock from several depots to meet specified demands. Each route has a cost, and shipments must respect the available supply and required demand.
The analogy stops where physical constraints begin. A basic mathematical cost matrix does not automatically include vehicle capacity, delivery schedules or road restrictions. In AI applications, the “shipments” may instead be fractions of probability with no physical movement at all.
Worked example
Comparing two simple transport plans
Place half the source mass at position 0 and half at position 10 on a line. The target requires half the mass at position 2 and half at position 8. Use absolute distance as the cost per unit mass.
One plan sends 0.5 from 0 to 2 and 0.5 from 10 to 8. Its cost is 0.5 × 2 + 0.5 × 2 = 2. A crossed plan sends 0.5 from 0 to 8 and 0.5 from 10 to 2, costing 0.5 × 8 + 0.5 × 8 = 8. The nearby assignment is cheaper.
More generally, let t be the amount sent from 0 to 2, where 0 ≤ t ≤ 0.5. The marginal constraints force the remaining plan entries to be 0.5 − t, 0.5 − t and t. The cost becomes 2t + 8(0.5 − t) + 8(0.5 − t) + 2t = 8 − 12t. It is smallest at t = 0.5, confirming the cost-2 solution.
The answer changes if the cost definition changes. This is an illustrative calculation, not evidence about real correspondence.
Illustrative case study
Illustrative case study - fictional
A fictional design studio compares the color palettes of two image collections. A simple bin-by-bin difference treats adjacent color bins as entirely separate. The team experiments with optimal transport so that shifting weight between nearby colors has a smaller cost than shifting it between distant colors.
The comparison helps describe palette differences, but two images with different layouts can still have the same color distribution. The studio keeps spatial-composition review as a separate step.
It records the color representation, weights and transport cost rather than presenting one number as an all-purpose similarity judgment. This illustrates modeling choices, not measured improvements.
Common misconceptions and mistakes
- Optimal transport is not automatically ordinary object matching. A general coupling can divide one source weight among several targets.
- Balanced transport requires equal total mass; normalization or an unbalanced formulation is an explicit choice.
- The ground cost is part of the model. Different feature scales or distance definitions can change the answer.
- A regularized objective is not identical to the unregularized one. Report which result is being used.
- Not every transport cost is automatically a metric called a Wasserstein distance; the cost and mathematical conditions matter.
Business use
Businesses may encounter optimal transport in image comparison, dataset analysis and distribution-based modeling. Its value is that the comparison can respect geometry instead of treating every category or bin as unrelated.
Before adopting it, define what a unit of mass represents and why moving it between two locations should incur the chosen cost. Compare the result with simpler alternatives and task-specific judgments. For larger problems, assess computational cost and the effect of approximations. Check that the representation captures the business question.
People also ask
Does it only apply to physical transportation?
No. Probability distributions, feature weights and sampled shapes are common mathematical inputs.
Does it require equal numbers of source and target points?
No. A transport matrix can be rectangular. Balanced transport requires equal total mass, not equal point counts.
Is the solution always unique?
No. Multiple plans can share the same minimum cost. Additional assumptions or regularization can affect uniqueness and the selected plan.
Check your understanding
A source distribution has three weighted points and a target has five. Is balanced optimal transport impossible?
Answer: No. Different point counts are allowed. The total source and target mass must match, and the plan must satisfy their specified weights.
Related terms
- Wasserstein distance
- transport plan
- cost matrix
- Sinkhorn algorithm
- distribution alignment
- entropic regularisation
Learn next
Recalculate the two-point example with squared distance as the ground cost. Then change the target weights and write the row and column sum constraints before searching for a plan. Notice which changes affect the model and which only affect the solver.
More in Computer vision and multimodal AI
- Object recognition - Object recognition is the process of identifying what an object is from visual information, such as an image or video.
- Open set recognition - Open set recognition is a recognition setting in which a system must identify supported classes while allowing inputs from previously unseen classes to be...
- Optical flow - Optical flow is the apparent movement of visual patterns across an image sequence, commonly represented by a two-dimensional vector at each estimated location.
- Oriented projective geometry - Oriented projective geometry is a form of projective geometry that retains a distinction between opposite homogeneous directions.
- Orthographic projection - Orthographic projection maps three-dimensional points onto a plane along parallel lines perpendicular to that plane.
- P-frame - A P-frame, or predictive frame, is a coded video picture that can use previously decoded reference pictures to predict image content.
Sources
Sources: Peyré and Cuturi, Computational Optimal Transport: https://arxiv.org/abs/1803.00567 ; Gabriel Peyré's Numerical Tours, Optimal Transport by Linear Programming: https://www.numerical-tours.com/python/optimaltransp_1_linprog/ ; Unbalanced Optimal Transport: https://www.numerical-tours.com/python/optimaltransp_8_unbalanced/ . Relevant overview, discrete formulation and unbalanced-method explanations were reviewed; source code was not executed.
Previous: Optimal solution Next: Optimality criterion