package optiml-transport

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Low-level interface to the optimal transportation solver.

type result_internal =
  1. | Transport_Infeasible
  2. | Transport_Optimal
  3. | Transport_Unbounded
  4. | Transport_Max_iter_reached
type fref = {
  1. mutable field : float;
}

Only ever useful if you plan to use the stubs directly. This is used to store the cost of the transportation plan produced by kanto_solve.

val kanto_solve : vec -> vec -> mat -> mat -> vec -> vec -> fref -> int -> result_internal

kanto_solve x y D G u v cost num_iter computes an optimal transportation plan from x to y according to the cost matrix D. The optimal plan is stored in the matrix G, and the dual optimal variables (the "prices") are stored in u and v. Note that D need not satisfy the triangle inequality.

The cost associated to G is stored in the reference cell cost. num_iter specifies the maximum number of iterations of the algorithm. kanto_solve also returns the state of the solver at the end of the process as a value of type result_internal.

NB: kanto_solve does not allocate memory. All matrices and vectors must be preallocated by the user.

High-level interface to the optimal transportation solver.

type result =
  1. | Infeasible
  2. | Unbounded
  3. | Optimal of {
    1. cost : float;
    2. coupling : mat;
    3. u : vec;
    4. v : vec;
    }
  4. | Max_iter_reached of {
    1. cost : float;
    2. coupling : mat;
    3. u : vec;
    4. v : vec;
    }

The result type encodes the outcome of solving an instance of the optimal mass transportation problem.

val kantorovich : x:vec -> y:vec -> d:mat -> num_iter:int -> result

kantorovich x y d num_iter is a wrapper around kanto_solve which will allocate all intermediate structures for you. If you plan to perform a lot of calls to the solver for fixed sizes of x and y you might want to consider using the low-level interface, to avoid reallocating those intermediate structures.

OCaml

Innovation. Community. Security.