| OTNetworkSimplex | R Documentation |
Solve the optimal transport problem with the package 'transport'
use the network simplex algorithm
p[double] Power of the plan
plan[matrix] transport plan
success[bool] If the fit is a success or not
C[matrix] Cost matrix
new()Create a new OTNetworkSimplex object.
OTNetworkSimplex$new(p = 2)
p[double] Power of the plan
A new 'OTNetworkSimplex' object.
fit()Fit the OT plan
OTNetworkSimplex$fit(muX0, muX1, C = NULL)
muX0[SparseHist or OTHist] Source histogram to move
muX1[SparseHist or OTHist] Target histogram
C[matrix or NULL] Cost matrix (without power p) between muX0 and muX1, if NULL pairwise_distances is called with Euclidean distance.
NULL
clone()The objects of this class are cloneable with this method.
OTNetworkSimplex$clone(deep = FALSE)
deepWhether to make a deep clone.
Bazaraa, M. S., Jarvis, J. J., and Sherali, H. D.: Linear Programming and Network Flows, 4th edn., John Wiley & Sons, 2009.
## Define two dataset
X = stats::rnorm(2000)
Y = stats::rnorm(2000 , mean = 5 )
bw = base::c(0.1)
muX = SBCK::SparseHist( X , bw )
muY = SBCK::SparseHist( Y , bw )
## Find solution
ot = OTNetworkSimplex$new()
ot$fit( muX , muY )
print( sum(ot$plan) ) ## Must be equal to 1
print( ot$success ) ## If solve is success
print( sqrt(sum(ot$plan * ot$C)) ) ## Cost of plan
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.