Learn R Programming

transport (version 0.15-4)

semidiscrete1: Compute Semidiscrete Optimal Transport for Euclidean Distance Cost

Description

Computes the weight vector of the Apollonius diagram describing the semidiscrete optimal transport plan for the Euclidean distance cost function and the associated Wasserstein distance.

Usage

semidiscrete1(
  source,
  target,
  xrange = c(0, 1),
  yrange = c(0, 1),
  verbose = FALSE,
  reg = 0
)

Value

A list describing the solution. The components are

weights

A vector of length equal to the first dimension of target containing the weights for the Apollonius diagram discribing the optimal semidiscrete transport from source to target.

wasserstein_dist

The \(L_1\)-Wasserstein distance between source and target.

ret_code

A return code. Equal to 1 if everything is OK, since our code interrupts the usual lbfgs code. Other values can be converted to the corresponding return message by using ret_message.

Arguments

source

A matrix specifing the source measure.

target

A three-column matrix specifing the target measure in the form x-coordinate, y-coordinate, mass.

xrange, yrange

Vectors with two components defining the window on which the source measure lives. Defaults to \([0,1] \times [0,1]\). source is interpreted as an image of equally sized quadratic pixels on this window.

verbose

Logical. Shall information about multiscale progress and L-BFGS return codes be printed?

reg

A non-negative regularization parameter. It is usually not necessary to deviate from the default 0.

Author

Valentin Hartmann valentin.hartmann@epfl.ch (stand-alone C++ code)
Dominic Schuhmacher schuhmacher@math.uni-goettingen.de (R-port)

References

V. Hartmann and D. Schuhmacher (2017). Semi-discrete optimal transport --- the case p=1. Preprint arXiv:1706.07650

Menelaos Karavelas and Mariette Yvinec. 2D Apollonius Graphs (Delaunay Graphs of Disks). In CGAL User and Reference Manual. CGAL Editorial Board, 4.12 edition, 2018

Naoaki Okazaki (2010). libLBFGS: a library of Limited-memory Broyden-Fletcher-Goldfarb-Shanno (L-BFGS). Version 1.10

See Also

ret_message, semidiscrete.

Examples

Run this code
if (FALSE) {
# the following function rotates a matrix m clockwise, so
# that image(rococlock(m)) has the same orientation as print(m):
roclock <- function(m) t(m)[, nrow(m):1]

set.seed(30)
n <- 20
nu <- matrix(c(runif(2*n), rgamma(n,3,1)), n, 3)
pixelbdry <- seq(0,1,length=33)
image(pixelbdry, pixelbdry, roclock(random32a$mass), asp=1, col = grey(seq(0,1,length.out=32)))
points(nu[,1], nu[,2], pch=16, cex=sqrt(nu[,3])/2, col=2)

res <- semidiscrete1(random32a$mass, nu)
plot_apollonius(nu[,1:2], res$weights, show_weights = FALSE, add = TRUE)
points(nu[,1], nu[,2], pch=16, cex=sqrt(nu[,3])/2, col=2)}


Run the code above in your browser using DataLab