x <- otgrid(rbind(c(0, 0, 0, 0, 0, 0, 0, 0, 0),
c(0, 0, 1, 0, 0, 0, 0, 0, 0),
c(0, 1, 2, 1, 0, 0, 0, 0, 0),
c(0, 0, 1, 0, 0, 0, 0, 0, 0),
0, 0, 0, 0, 0))
y <- otgrid(rbind(0, 0, 0, 0,
c(0, 0, 0, 0, 0, 0, 0, 0, 0),
c(0, 0, 0, 0, 0, 0, 1, 0, 0),
c(0, 0, 0, 0, 0, 1, 2, 1, 0),
c(0, 0, 0, 0, 0, 0, 1, 0, 0), 0))
pm <- pivot_measure(x, y, p.1 = 1, p.2 = 2, dual.method = "epsilon-discrete")
print(pm)
plot(pm)
# use pivot measure to calculate cost and plan
pm <- transport_cost(pm)
pm <- transport_df(pm)
print(pm)
# calculate pivot from plan
pm2 <- pivot_measure(pm$df, x, y)
plot(pm2)
Run the code above in your browser using DataLab