SemiDiscreteOT 1.0
Semi-Discrete Optimal Transport Library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
OptimalTransportPlanSpace::OptimalTransportPlan< spacedim > Class Template Reference

A class for computing and managing optimal transport map approximations. More...

#include <OptimalTransportPlan.h>

Inheritance diagram for OptimalTransportPlanSpace::OptimalTransportPlan< spacedim >:
Inheritance graph
[legend]
Collaboration diagram for OptimalTransportPlanSpace::OptimalTransportPlan< spacedim >:
Collaboration graph
[legend]

Public Member Functions

 OptimalTransportPlan (const std::string &strategy_name="modal")
 Constructor taking an optional strategy name.
 
void set_distance_function (const std::function< double(const Point< spacedim > &, const Point< spacedim > &)> &dist)
 Set the distance function used to compute distances between points. This function accepts a callable object (e.g., lambda) that takes two points as input and returns a double representing their distance.
 
void set_source_measure (const std::vector< Point< spacedim > > &points, const std::vector< double > &density)
 Set the source measure data.
 
void set_target_measure (const std::vector< Point< spacedim > > &points, const std::vector< double > &density)
 Set the target measure data.
 
void set_potential (const Vector< double > &potential, const double regularization_param=0.0)
 Set the optimal transport potential.
 
void set_truncation_radius (double radius)
 Set the truncation radius for map computation. Points outside this radius will not be considered in the map computation. A negative value means no truncation (all points are considered).
 
void compute_map ()
 Compute the optimal transport map approximation using the current strategy.
 
void save_map (const std::string &output_dir) const
 Save the computed transport map to files.
 
void set_strategy (const std::string &strategy_name)
 Change the approximation strategy.
 

Static Public Member Functions

static std::vector< std::string > get_available_strategies ()
 Get available strategy names.
 

Static Private Member Functions

static std::unique_ptr< MapApproximationStrategy< spacedim > > create_strategy (const std::string &name)
 

Private Attributes

std::vector< Point< spacedim > > source_points
 
std::vector< double > source_density
 
std::vector< Point< spacedim > > target_points
 
std::vector< double > target_density
 
Vector< double > transport_potential
 
double epsilon
 
double truncation_radius = -1.0
 
std::function< double(const Point< spacedim > &, const Point< spacedim > &)> distance_function
 
std::unique_ptr< MapApproximationStrategy< spacedim > > strategy
 

Detailed Description

template<int spacedim>
class OptimalTransportPlanSpace::OptimalTransportPlan< spacedim >

A class for computing and managing optimal transport map approximations.

This class provides various strategies for approximating the optimal transport map given source/target measures and optimal transport potentials.

Template Parameters
spacedimThe dimension of the space the mesh is embedded in.

Definition at line 46 of file OptimalTransportPlan.h.

Constructor & Destructor Documentation

◆ OptimalTransportPlan()

template<int spacedim>
OptimalTransportPlanSpace::OptimalTransportPlan< spacedim >::OptimalTransportPlan ( const std::string &  strategy_name = "modal")

Constructor taking an optional strategy name.

Parameters
strategy_nameThe name of the approximation strategy to use.

Definition at line 9 of file OptimalTransportPlan.cc.

Here is the call graph for this function:

Member Function Documentation

◆ set_distance_function()

template<int spacedim>
void OptimalTransportPlanSpace::OptimalTransportPlan< spacedim >::set_distance_function ( const std::function< double(const Point< spacedim > &, const Point< spacedim > &)> &  dist)
inline

Set the distance function used to compute distances between points. This function accepts a callable object (e.g., lambda) that takes two points as input and returns a double representing their distance.

Parameters
distance_functionFunction to compute distance between two points.

Definition at line 61 of file OptimalTransportPlan.h.

◆ set_source_measure()

template<int spacedim>
void OptimalTransportPlanSpace::OptimalTransportPlan< spacedim >::set_source_measure ( const std::vector< Point< spacedim > > &  points,
const std::vector< double > &  density 
)

Set the source measure data.

Parameters
pointsVector of source points
densityVector of density values at source points

Definition at line 17 of file OptimalTransportPlan.cc.

Here is the caller graph for this function:

◆ set_target_measure()

template<int spacedim>
void OptimalTransportPlanSpace::OptimalTransportPlan< spacedim >::set_target_measure ( const std::vector< Point< spacedim > > &  points,
const std::vector< double > &  density 
)

Set the target measure data.

Parameters
pointsVector of target points
densityVector of density values at target points

Definition at line 27 of file OptimalTransportPlan.cc.

Here is the caller graph for this function:

◆ set_potential()

template<int spacedim>
void OptimalTransportPlanSpace::OptimalTransportPlan< spacedim >::set_potential ( const Vector< double > &  potential,
const double  regularization_param = 0.0 
)

Set the optimal transport potential.

Parameters
potentialVector of potential values at target points
regularization_paramThe regularization parameter used (if any)

Definition at line 37 of file OptimalTransportPlan.cc.

Here is the caller graph for this function:

◆ set_truncation_radius()

template<int spacedim>
void OptimalTransportPlanSpace::OptimalTransportPlan< spacedim >::set_truncation_radius ( double  radius)

Set the truncation radius for map computation. Points outside this radius will not be considered in the map computation. A negative value means no truncation (all points are considered).

Parameters
radiusThe truncation radius

Definition at line 47 of file OptimalTransportPlan.cc.

Here is the caller graph for this function:

◆ compute_map()

template<int spacedim>
void OptimalTransportPlanSpace::OptimalTransportPlan< spacedim >::compute_map ( )

Compute the optimal transport map approximation using the current strategy.

Definition at line 53 of file OptimalTransportPlan.cc.

Here is the caller graph for this function:

◆ save_map()

template<int spacedim>
void OptimalTransportPlanSpace::OptimalTransportPlan< spacedim >::save_map ( const std::string &  output_dir) const

Save the computed transport map to files.

Parameters
output_dirDirectory where to save the results

Definition at line 67 of file OptimalTransportPlan.cc.

Here is the caller graph for this function:

◆ set_strategy()

template<int spacedim>
void OptimalTransportPlanSpace::OptimalTransportPlan< spacedim >::set_strategy ( const std::string &  strategy_name)

Change the approximation strategy.

Parameters
strategy_nameName of the strategy to use

Definition at line 75 of file OptimalTransportPlan.cc.

Here is the caller graph for this function:

◆ get_available_strategies()

template<int spacedim>
std::vector< std::string > OptimalTransportPlanSpace::OptimalTransportPlan< spacedim >::get_available_strategies ( )
static

Get available strategy names.

Returns
A vector of strings containing the names of the available strategies.

Definition at line 81 of file OptimalTransportPlan.cc.

Here is the caller graph for this function:

◆ create_strategy()

template<int spacedim>
std::unique_ptr< MapApproximationStrategy< spacedim > > OptimalTransportPlanSpace::OptimalTransportPlan< spacedim >::create_strategy ( const std::string &  name)
staticprivate

Definition at line 88 of file OptimalTransportPlan.cc.

Here is the caller graph for this function:

Member Data Documentation

◆ source_points

template<int spacedim>
std::vector<Point<spacedim> > OptimalTransportPlanSpace::OptimalTransportPlan< spacedim >::source_points
private

Definition at line 123 of file OptimalTransportPlan.h.

◆ source_density

template<int spacedim>
std::vector<double> OptimalTransportPlanSpace::OptimalTransportPlan< spacedim >::source_density
private

Definition at line 124 of file OptimalTransportPlan.h.

◆ target_points

template<int spacedim>
std::vector<Point<spacedim> > OptimalTransportPlanSpace::OptimalTransportPlan< spacedim >::target_points
private

Definition at line 125 of file OptimalTransportPlan.h.

◆ target_density

template<int spacedim>
std::vector<double> OptimalTransportPlanSpace::OptimalTransportPlan< spacedim >::target_density
private

Definition at line 126 of file OptimalTransportPlan.h.

◆ transport_potential

template<int spacedim>
Vector<double> OptimalTransportPlanSpace::OptimalTransportPlan< spacedim >::transport_potential
private

Definition at line 127 of file OptimalTransportPlan.h.

◆ epsilon

template<int spacedim>
double OptimalTransportPlanSpace::OptimalTransportPlan< spacedim >::epsilon
private

Definition at line 128 of file OptimalTransportPlan.h.

◆ truncation_radius

template<int spacedim>
double OptimalTransportPlanSpace::OptimalTransportPlan< spacedim >::truncation_radius = -1.0
private

Definition at line 129 of file OptimalTransportPlan.h.

◆ distance_function

template<int spacedim>
std::function<double(const Point<spacedim>&, const Point<spacedim>&)> OptimalTransportPlanSpace::OptimalTransportPlan< spacedim >::distance_function
private

Definition at line 132 of file OptimalTransportPlan.h.

◆ strategy

template<int spacedim>
std::unique_ptr<MapApproximationStrategy<spacedim> > OptimalTransportPlanSpace::OptimalTransportPlan< spacedim >::strategy
private

Definition at line 135 of file OptimalTransportPlan.h.


The documentation for this class was generated from the following files: