Skip to content

Commit d6c9ee3

Browse files
committed
updated tests and docstrings
1 parent 5ef3170 commit d6c9ee3

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/OptimalTransport.jl

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,27 @@ function sinkhorn_barycenter(
541541
return u_all[1, :] .* (K_all[1] * v_all[1, :])
542542
end
543543

544-
function ot_reg_plan(mu, nu, C, eps; reg_func = "L2", method = "lorenz", kwargs...)
544+
"""
545+
ot_reg_plan(mu, nu, C, eps; reg_func = "L2", method = "lorenz", kwargs...)
546+
547+
Compute the optimal transport plan between `mu` and `nu` for optimal transport with a
548+
general choice of regulariser `math Ω(γ)`. Solves for `gamma` that minimises
549+
550+
```math
551+
\\inf_{γ ∈ Π(μ, ν)} \\langle γ, C \\rangle + ε Ω(γ)
552+
```
553+
554+
Supported choices of `math Ω` are:
555+
- L2: `math Ω(γ) = \\frac{1}{2} \\| γ \\|_2^2`, `reg_func = "L2"`
556+
557+
Supported solution methods are:
558+
- L2: `method = "lorenz"` for the semi-smooth Newton method of Lorenz et al.
559+
560+
References
561+
562+
Lorenz, D.A., Manns, P. and Meyer, C., 2019. Quadratically regularized optimal transport. Applied Mathematics & Optimization, pp.1-31.
563+
"""
564+
function ot_reg_plan(mu, nu, C, eps; reg_func="L2", method="lorenz", kwargs...)
545565
if (reg_func == "L2") && (method == "lorenz")
546566
return quadreg(mu, nu, C, eps; kwargs...)
547567
else

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ end
197197

198198
# compute optimal transport map (Julia implementation + POT)
199199
eps = 0.25
200-
γ = ot_reg_plan(μ, ν, C, eps)
200+
γ = ot_reg_plan(μ, ν, C, eps; reg_func="L2", method="lorenz")
201201
γ_pot = sparse(POT.smooth_ot_dual(μ, ν, C, eps; max_iter=5000))
202202
# need to use a larger tolerance here because of a quirk with the POT solver
203203
@test norm- γ_pot, Inf) < 1e-4

0 commit comments

Comments
 (0)