22#include "absl/strings/str_split.h"
23#include "absl/strings/string_view.h"
33 for (
const std::string& line :
41 std::function<int64_t(
int,
int)> distances = [
this](
int from,
int to) {
42 const double xd = x_[from] - x_[
to];
43 const double yd = y_[from] - y_[
to];
44 const double d = sqrt(xd * xd + yd * yd);
50void PdTspParser::ProcessNewLine(
const std::string& line) {
51 const std::vector<std::string> words =
52 absl::StrSplit(line, absl::ByAnyChar(
" :\t"), absl::SkipEmpty());
56 const int size =
atoi64(words[0]);
59 deliveries_.resize(size, -1);
60 section_ = DEPOT_SECTION;
64 depot_ =
atoi64(words[0]) - 1;
65 x_[depot_] =
atoi64(words[1]);
66 y_[depot_] =
atoi64(words[2]);
67 deliveries_[depot_] = -1;
68 section_ = NODE_SECTION;
71 const int kEof = -999;
72 const int id =
atoi64(words[0]) - 1;
74 section_ = EOF_SECTION;
78 const bool is_pickup =
atoi64(words[3]) == 0;
80 deliveries_[id] =
atoi64(words[4]) - 1;
static int64_t FastInt64Round(double x)
std::function< int64_t(int, int)> Distances() const
bool LoadFile(absl::string_view file_name)
int64_t atoi64(absl::string_view word)
trees with all degrees equal to