55#ifndef OR_TOOLS_ROUTING_PARSERS_CARP_PARSER_H_
56#define OR_TOOLS_ROUTING_PARSERS_CARP_PARSER_H_
63#include "absl/strings/string_view.h"
64#include "absl/types/span.h"
80 bool LoadFile(absl::string_view file_name);
83 const std::string&
name()
const {
return name_; }
85 const std::string&
comment()
const {
return comment_; }
87 int64_t
depot()
const {
return depot_; }
98 return number_of_edges_with_servicing_;
103 return number_of_edges_without_servicing_;
109 return servicing_demands_;
113 return traversing_costs_;
123 CHECK(traversing_costs_.contains(edge))
124 <<
"Unknown edge: " << edge.
tail() <<
" - " << edge.
head();
125 return traversing_costs_.at(edge);
133 return servicing_demands_.contains(edge);
143 <<
"Unknown edge: " << edge.
tail() <<
" - " << edge.
head();
144 return servicing_demands_.at(edge);
155 ARCS_WITHOUT_SERVICING,
160 bool ParseFile(absl::string_view file_name);
161 bool ParseMetadataLine(absl::Span<const std::string> words);
162 bool ParseEdge(std::string_view line,
bool with_servicing);
170 std::string comment_;
171 int64_t number_of_nodes_;
172 int64_t number_of_edges_with_servicing_;
173 int64_t number_of_edges_without_servicing_;
174 int64_t total_servicing_cost_;
int64_t NumberOfVehicles() const
Returns the maximum number of vehicles to use.
const gtl::linked_hash_map< Edge, int64_t > & traversing_costs() const
Returns the traversing costs of the edges in the current routing problem.
int64_t GetServicing(Edge edge) const
int64_t depot() const
Returns the index of the depot.
CarpParser(const CarpParser &)=delete
const std::string & name() const
Returns the name of the instance being solved.
const std::string & comment() const
Returns the comment of the instance being solved, typically an upper bound.
const gtl::linked_hash_map< Edge, int64_t > & servicing_demands() const
Returns the servicing of the edges in the current routing problem.
int64_t NumberOfEdgesWithServicing() const
int64_t NumberOfEdges() const
int64_t TotalServicingCost() const
Returns the total servicing cost for all arcs.
bool LoadFile(absl::string_view file_name)
Loads instance from a file into this parser object.
int64_t HasServicingNeed(Edge edge) const
Checks whether this edge requires servicing.
int64_t NumberOfEdgesWithoutServicing() const
int64_t HasServicingNeed(int64_t tail, int64_t head) const
const CarpParser & operator=(const CarpParser &)=delete
int64_t GetServicing(int64_t tail, int64_t head) const
int64_t GetTraversingCost(Edge edge) const
int64_t GetTraversingCost(int64_t tail, int64_t head) const
int64_t capacity() const
Returns the capacity of the vehicles.
int64_t NumberOfNodes() const
Returns the number of nodes in the current routing problem.
Common utilities for parsing routing instances.