20#include "absl/strings/str_split.h"
21#include "absl/strings/string_view.h"
34File* OpenReadOnly(absl::string_view file_name) {
47 for (
const std::string&
line :
55 std::function<int64_t(
int,
int)> distances = [
this](
int from,
int to) {
56 const double xd = x_[from] - x_[
to];
57 const double yd = y_[from] - y_[
to];
58 const double d = sqrt(xd * xd + yd * yd);
64void PdTspParser::ProcessNewLine(
const std::string&
line) {
65 const std::vector<std::string> words =
66 absl::StrSplit(
line, ByAnyChar(
" :\t"), absl::SkipEmpty());
73 deliveries_.resize(
size, -1);
74 section_ = DEPOT_SECTION;
78 depot_ =
atoi64(words[0]) - 1;
79 x_[depot_] =
atoi64(words[1]);
80 y_[depot_] =
atoi64(words[2]);
81 deliveries_[depot_] = -1;
82 section_ = NODE_SECTION;
85 const int kEof = -999;
86 const int id =
atoi64(words[0]) - 1;
88 section_ = EOF_SECTION;
92 const bool is_pickup =
atoi64(words[3]) == 0;
94 deliveries_[id] =
atoi64(words[4]) - 1;
static int64_t FastInt64Round(double x)
std::function< int64_t(int, int)> Distances() const
Returns a function returning distances between nodes.
bool LoadFile(const std::string &file_name)
Loads and parse a PDTSP from a given file.
File * GZipFileReader(const absl::string_view name, File *file, Ownership ownership, AppendedStreams appended_streams)
public entry points
absl::string_view Extension(absl::string_view path)
absl::Status Open(absl::string_view filename, absl::string_view mode, File **f, Options options)
As of 2016-01, these methods can only be used with flags = file::Defaults().
In SWIG mode, we don't want anything besides these top-level includes.
int64_t atoi64(absl::string_view word)
trees with all degrees equal to