20 #include "absl/strings/str_split.h"
31 using absl::ByAnyChar;
33 File* OpenReadOnly(
const std::string& file_name) {
46 for (
const std::string&
line :
54 std::function<int64_t(
int,
int)> distances = [
this](
int from,
int to) {
55 const double xd = x_[from] - x_[to];
56 const double yd = y_[from] - y_[to];
57 const double d = sqrt(xd * xd + yd * yd);
63 void PdTspParser::ProcessNewLine(
const std::string&
line) {
64 const std::vector<std::string> words =
65 absl::StrSplit(
line, ByAnyChar(
" :\t"), absl::SkipEmpty());
69 const int size =
atoi64(words[0]);
72 deliveries_.resize(size, -1);
73 section_ = DEPOT_SECTION;
77 depot_ =
atoi64(words[0]) - 1;
78 x_[depot_] =
atoi64(words[1]);
79 y_[depot_] =
atoi64(words[2]);
80 deliveries_[depot_] = -1;
81 section_ = NODE_SECTION;
84 const int kEof = -999;
85 const int id =
atoi64(words[0]) - 1;
87 section_ = EOF_SECTION;
91 const bool is_pickup =
atoi64(words[3]) == 0;
93 deliveries_[id] =
atoi64(words[4]) - 1;
static int64_t FastInt64Round(double x)
bool LoadFile(const std::string &file_name)
std::function< int64_t(int, int)> Distances() const
File * GZipFileReader(const absl::string_view name, File *file, Ownership ownership, AppendedStreams appended_streams)
absl::Status Open(const absl::string_view &filename, const absl::string_view &mode, File **f, int flags)
absl::string_view Extension(absl::string_view path)
Collection of objects used to extend the Constraint Solver library.
int64_t atoi64(const std::string &word)