operations_research::ChristofidesPathSolver< CostType, ArcIndex, NodeIndex, CostFunction > Class Template Reference

Detailed Description

template<typename CostType, typename ArcIndex = int64, typename NodeIndex = int32, typename CostFunction = std::function<CostType(NodeIndex, NodeIndex)>>
class operations_research::ChristofidesPathSolver< CostType, ArcIndex, NodeIndex, CostFunction >

Definition at line 40 of file christofides.h.

Public Types

enum  MatchingAlgorithm { MatchingAlgorithm::MINIMUM_WEIGHT_MATCHING, MatchingAlgorithm::MINIMAL_WEIGHT_MATCHING }
 

Public Member Functions

 ChristofidesPathSolver (NodeIndex num_nodes, CostFunction costs)
 
void SetMatchingAlgorithm (MatchingAlgorithm matching)
 Sets the matching algorith to use. More...
 
CostType TravelingSalesmanCost ()
 Returns the cost of the approximate TSP tour. More...
 
std::vector< NodeIndexTravelingSalesmanPath ()
 Returns the approximate TSP tour. More...
 

Member Enumeration Documentation

◆ MatchingAlgorithm

template<typename CostType , typename ArcIndex = int64, typename NodeIndex = int32, typename CostFunction = std::function<CostType(NodeIndex, NodeIndex)>>
enum operations_research::ChristofidesPathSolver::MatchingAlgorithm
strong
Enumerator
MINIMUM_WEIGHT_MATCHING 
MINIMAL_WEIGHT_MATCHING 

Definition at line 42 of file christofides.h.

Constructor & Destructor Documentation

◆ ChristofidesPathSolver()

template<typename CostType , typename ArcIndex , typename NodeIndex , typename CostFunction >
operations_research::ChristofidesPathSolver< CostType, ArcIndex, NodeIndex, CostFunction >::ChristofidesPathSolver ( NodeIndex  num_nodes,
CostFunction  costs 
)

Definition at line 177 of file christofides.h.

Member Function Documentation

◆ SetMatchingAlgorithm()

template<typename CostType , typename ArcIndex = int64, typename NodeIndex = int32, typename CostFunction = std::function<CostType(NodeIndex, NodeIndex)>>
void operations_research::ChristofidesPathSolver< CostType, ArcIndex, NodeIndex, CostFunction >::SetMatchingAlgorithm ( MatchingAlgorithm  matching)
inline

Sets the matching algorith to use.

A minimum weight perfect matching (MINIMUM_WEIGHT_MATCHING) guarantees the 3/2 upper bound to the optimal solution. A minimal weight perfect matching (MINIMAL_WEIGHT_MATCHING) finds a locally minimal weight matching which does not offer any bound guarantee but, as of 1/2017, is orders of magnitude faster than the minimum matching. By default, MINIMAL_WEIGHT_MATCHING is selected.

Todo:
(user): Change the default when minimum matching gets faster.

Definition at line 58 of file christofides.h.

◆ TravelingSalesmanCost()

template<typename CostType , typename ArcIndex , typename NodeIndex , typename CostFunction >
CostType operations_research::ChristofidesPathSolver< CostType, ArcIndex, NodeIndex, CostFunction >::TravelingSalesmanCost ( )

Returns the cost of the approximate TSP tour.

Definition at line 187 of file christofides.h.

◆ TravelingSalesmanPath()

template<typename CostType , typename ArcIndex , typename NodeIndex , typename CostFunction >
std::vector< NodeIndex > operations_research::ChristofidesPathSolver< CostType, ArcIndex, NodeIndex, CostFunction >::TravelingSalesmanPath ( )

Returns the approximate TSP tour.

Definition at line 197 of file christofides.h.


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