Skip to content

Commit f809e19

Browse files
committed
updated tests and docstrings
1 parent 42a31ac commit f809e19

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/OptimalTransport.jl

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

509-
function ot_reg_plan(mu, nu, C, eps; reg_func = "L2", method = "lorenz", kwargs...)
509+
"""
510+
ot_reg_plan(mu, nu, C, eps; reg_func = "L2", method = "lorenz", kwargs...)
511+
512+
Compute the optimal transport plan between `mu` and `nu` for optimal transport with a
513+
general choice of regulariser `math Ω(γ)`. Solves for `gamma` that minimises
514+
515+
```math
516+
\\inf_{γ ∈ Π(μ, ν)} \\langle γ, C \\rangle + ε Ω(γ)
517+
```
518+
519+
Supported choices of `math Ω` are:
520+
- L2: `math Ω(γ) = \\frac{1}{2} \\| γ \\|_2^2`, `reg_func = "L2"`
521+
522+
Supported solution methods are:
523+
- L2: `method = "lorenz"` for the semi-smooth Newton method of Lorenz et al.
524+
525+
References
526+
527+
Lorenz, D.A., Manns, P. and Meyer, C., 2019. Quadratically regularized optimal transport. Applied Mathematics & Optimization, pp.1-31.
528+
"""
529+
function ot_reg_plan(mu, nu, C, eps; reg_func="L2", method="lorenz", kwargs...)
510530
if (reg_func == "L2") && (method == "lorenz")
511531
return quadreg(mu, nu, C, eps; kwargs...)
512532
else

test/runtests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,13 @@ end
165165

166166
# compute optimal transport map (Julia implementation + POT)
167167
eps = 0.25
168+
<<<<<<< HEAD
168169
γ = ot_reg_plan(μ, ν, C, eps)
169170
γ_pot = POT.Smooth.smooth_ot_dual(μ, ν, C, eps; stopThr=1e-9)
171+
=======
172+
γ = ot_reg_plan(μ, ν, C, eps; reg_func="L2", method="lorenz")
173+
γ_pot = sparse(POT.smooth_ot_dual(μ, ν, C, eps; max_iter=5000))
174+
>>>>>>> d6c9ee3 (updated tests and docstrings)
170175
# need to use a larger tolerance here because of a quirk with the POT solver
171176
@test norm- γ_pot, Inf) < 1e-4
172177
end

0 commit comments

Comments
 (0)