OTNetworkSimplex: Optimal Transport Network Simplex solver

Description Details Public fields Methods References Examples

Description

Solve the optimal transport problem

Details

use the network simplex algorithm

Public fields

p

[double] Power of the plan

plan

[matrix] transport plan

success

[bool] If the fit is a success or not

C

[matrix] Cost matrix

Methods

Public methods


Method new()

Create a new OTNetworkSimplex object.

Usage
OTNetworkSimplex$new(p = 2)
Arguments
p

[double] Power of the plan

Returns

A new 'OTNetworkSimplex' object.


Method fit()

Fit the OT plan

Usage
OTNetworkSimplex$fit(muX0, muX1, C = NULL)
Arguments
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.

Returns

NULL


Method clone()

The objects of this class are cloneable with this method.

Usage
OTNetworkSimplex$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

References

Bazaraa, M. S., Jarvis, J. J., and Sherali, H. D.: Linear Programming and Network Flows, 4th edn., John Wiley & Sons, 2009.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## 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

SBCK documentation built on April 10, 2021, 9:06 a.m.

Related to OTNetworkSimplex in SBCK...