Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::TspLibParser Class Referencefinal

#include <tsplib_parser.h>

Public Types

enum  Types {
  TSP , ATSP , SOP , HCP ,
  CVRP , TOUR , UNDEFINED_TYPE
}
 Routing model types (cf. the link above for a description). More...
 

Public Member Functions

 TspLibParser ()
 
bool LoadFile (const std::string &file_name)
 Loads and parses a routing problem from a given file.
 
int SizeFromFile (const std::string &file_name) const
 Returns the number of nodes in the routing problem stored in a given file.
 
EdgeWeights GetEdgeWeights () const
 Returns a function returning edge weights between nodes.
 
int depot () const
 Returns the index of the depot.
 
int size () const
 Returns the number of nodes in the current routing problem.
 
Types type () const
 Returns the type of the current routing problem.
 
const std::vector< Coordinates3< double > > & coordinates () const
 
int64_t capacity () const
 Returns the capacity of the vehicles in the current routing problem.
 
int64_t max_distance () const
 Returns the maximal distance vehicles can travel.
 
const std::vector< int64_t > & demands () const
 Returns the demands (or quantities picked up) at each node.
 
std::set< std::pair< int, int > > fixed_edges () const
 
const std::vector< std::vector< int > > & edges () const
 
const std::string & name () const
 Returns the name of the current routing model.
 
const std::string & comments () const
 Returns the comments attached to the data.
 
std::string BuildTourFromRoutes (absl::Span< const std::vector< int > > routes) const
 

Detailed Description

Definition at line 40 of file tsplib_parser.h.

Member Enumeration Documentation

◆ Types

Routing model types (cf. the link above for a description).

Enumerator
TSP 
ATSP 
SOP 
HCP 
CVRP 
TOUR 
UNDEFINED_TYPE 

Definition at line 43 of file tsplib_parser.h.

Constructor & Destructor Documentation

◆ TspLibParser()

operations_research::TspLibParser::TspLibParser ( )

Definition at line 159 of file tsplib_parser.cc.

Member Function Documentation

◆ BuildTourFromRoutes()

std::string operations_research::TspLibParser::BuildTourFromRoutes ( absl::Span< const std::vector< int > > routes) const

Build a tour output in TSPLIB95 format from a vector of routes, a route being a sequence of node indices.

Definition at line 661 of file tsplib_parser.cc.

◆ capacity()

int64_t operations_research::TspLibParser::capacity ( ) const
inline

Returns the capacity of the vehicles in the current routing problem.

Definition at line 64 of file tsplib_parser.h.

◆ comments()

const std::string & operations_research::TspLibParser::comments ( ) const
inline

Returns the comments attached to the data.

Definition at line 78 of file tsplib_parser.h.

◆ coordinates()

const std::vector< Coordinates3< double > > & operations_research::TspLibParser::coordinates ( ) const
inline

Returns the coordinates of the nodes in the current routing problem (if they exist).

Definition at line 60 of file tsplib_parser.h.

◆ demands()

const std::vector< int64_t > & operations_research::TspLibParser::demands ( ) const
inline

Returns the demands (or quantities picked up) at each node.

Definition at line 68 of file tsplib_parser.h.

◆ depot()

int operations_research::TspLibParser::depot ( ) const
inline

Returns the index of the depot.

Definition at line 53 of file tsplib_parser.h.

◆ edges()

const std::vector< std::vector< int > > & operations_research::TspLibParser::edges ( ) const
inline

Returns edges of the graph on which Hamiltonian cycles need to be built. Edges are represented as adjacency lists for each node.

Definition at line 74 of file tsplib_parser.h.

◆ fixed_edges()

std::set< std::pair< int, int > > operations_research::TspLibParser::fixed_edges ( ) const
inline

Returns the pairs of nodes corresponding to forced edges (second node is directly after the first).

Definition at line 71 of file tsplib_parser.h.

◆ GetEdgeWeights()

EdgeWeights operations_research::TspLibParser::GetEdgeWeights ( ) const
inline

Returns a function returning edge weights between nodes.

Definition at line 51 of file tsplib_parser.h.

◆ LoadFile()

bool operations_research::TspLibParser::LoadFile ( const std::string & file_name)

Loads and parses a routing problem from a given file.

Definition at line 174 of file tsplib_parser.cc.

◆ max_distance()

int64_t operations_research::TspLibParser::max_distance ( ) const
inline

Returns the maximal distance vehicles can travel.

Definition at line 66 of file tsplib_parser.h.

◆ name()

const std::string & operations_research::TspLibParser::name ( ) const
inline

Returns the name of the current routing model.

Definition at line 76 of file tsplib_parser.h.

◆ size()

int operations_research::TspLibParser::size ( ) const
inline

Returns the number of nodes in the current routing problem.

Definition at line 55 of file tsplib_parser.h.

◆ SizeFromFile()

int operations_research::TspLibParser::SizeFromFile ( const std::string & file_name) const

Returns the number of nodes in the routing problem stored in a given file.

Definition at line 185 of file tsplib_parser.cc.

◆ type()

Types operations_research::TspLibParser::type ( ) const
inline

Returns the type of the current routing problem.

Definition at line 57 of file tsplib_parser.h.


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