42#ifndef OR_TOOLS_ROUTING_PARSERS_SOLOMON_PARSER_H_
43#define OR_TOOLS_ROUTING_PARSERS_SOLOMON_PARSER_H_
52#include "absl/container/flat_hash_map.h"
53#include "absl/strings/string_view.h"
72 bool LoadFile(absl::string_view file_name);
75 bool LoadFile(absl::string_view file_name,
const std::string& archive_name);
78 const std::string&
name()
const {
return name_; }
86 const std::vector<Coordinates2<int64_t>>&
coordinates()
const {
92 const std::vector<int64_t>&
demands()
const {
return demands_; }
94 const std::vector<SimpleTimeWindow<int64_t>>&
time_windows()
const {
98 const std::vector<int64_t>&
service_times()
const {
return service_times_; }
103 const double xd = from_coords.
x - to_coords.
x;
104 const double yd = from_coords.
y - to_coords.
y;
105 return sqrt(xd * xd + yd * yd);
113 enum Section { UNKNOWN, NAME, VEHICLE, CUSTOMER };
117 bool ParseFile(absl::string_view file_name);
120 const std::map<std::string, Section> sections_;
130 std::vector<Coordinates2<int64_t>> coordinates_;
132 std::vector<int64_t> demands_;
133 std::vector<SimpleTimeWindow<int64_t>> time_windows_;
134 std::vector<int64_t> service_times_;
149 bool LoadFile(absl::string_view file_name);
154 const std::vector<int>&
route(
int i)
const {
return routes_[i]; }
159 static const std::string* default_value =
new std::string{};
160 auto it = key_values_.find(key);
161 if (it != key_values_.end())
return it->second;
162 return *default_value;
168 bool ParseFile(absl::string_view file_name);
171 std::vector<std::vector<int>> routes_;
172 absl::flat_hash_map<std::string, std::string> key_values_;
const std::vector< int64_t > & demands() const
Returns the demand of the nodes in the current routing problem.
const std::string & name() const
Returns the name of the instance being solved.
const std::vector< Coordinates2< int64_t > > & coordinates() const
Returns the coordinates of the nodes in the current routing problem.
int Depot() const
Returns the index of the depot.
double GetDistance(int from, int to) const
Returns the distance between two nodes.
const std::vector< SimpleTimeWindow< int64_t > > & time_windows() const
Returns the time windows of the nodes in the current routing problem.
const SolomonParser & operator=(const SolomonParser &)=delete
int64_t capacity() const
Returns the capacity of the vehicles.
SolomonParser(const SolomonParser &)=delete
bool LoadFile(absl::string_view file_name)
Loads instance from a file.
int NumberOfNodes() const
Returns the number of nodes in the current routing problem.
int NumberOfVehicles() const
Returns the maximum number of vehicles to use.
double GetTravelTime(int from, int to) const
Returns the travel time between two nodes.
const std::vector< int64_t > & service_times() const
Returns the service times of the nodes in the current routing problem.
bool LoadFile(absl::string_view file_name)
const std::string & GetValueFromKey(absl::string_view key) const
const SolomonSolutionParser & operator=(const SolomonSolutionParser &)=delete
SolomonSolutionParser(const SolomonSolutionParser &)=delete
const std::vector< int > & route(int i) const
Returns the sequence of the ith route, excluding depot nodes.
int NumberOfRoutes() const
Returns the number of routes used in the solution.
Common utilities for parsing routing instances.
trees with all degrees equal to