semidiscrete1 {transport} | R Documentation |
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
)
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 |
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. |
Value
A list describing the solution. The components are
weights |
A vector of length equal to the first dimension of |
wasserstein_dist |
The |
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 |
Note
This function requires the Computational Geometry Algorithms Library (CGAL), available at https://www.cgal.org. Adapt the file src/Makevars according to the instructions given there and re-install from source.
Internally the code from liblbfgs 1.10 by Naoaki Okazaki (2010) is used. See http://www.chokkan.org/software/liblbfgs/.
A stand-alone version of the C++ code of this function is available at https://github.com/valentin-hartmann-research/semi-discrete-transport.
Author(s)
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
Examples
## Not run:
# 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)
## End(Not run)