20 #include "absl/log/check.h"
21 #include "absl/strings/numbers.h"
22 #include "absl/strings/str_split.h"
34 for (
const std::string&
line :
36 const std::vector<std::string> tokens =
37 absl::StrSplit(
line,
' ', absl::SkipEmpty());
38 if (tokens.empty())
continue;
40 CHECK_GE(tokens.size(), 1);
41 CHECK_LE(tokens.size(), 2);
42 CHECK(absl::SimpleAtoi(tokens[0], &n));
45 for (
int j = 0; j < n; ++j) {
49 if (tokens.size() == 2) {
53 }
else if (k <= n * n) {
54 for (
const std::string& token : tokens) {
55 const int i = (k - 1) / n;
56 const int j = (k - 1) % n;
58 CHECK(absl::SimpleAtoi(token, &v)) <<
"'" << token <<
"'";
62 }
else if (k <= 2 * n * n) {
63 for (
const std::string& token : tokens) {
64 const int i = (k - n * n - 1) / n;
65 const int j = (k - n * n - 1) % n;
67 CHECK(absl::SimpleAtoi(token, &v));
72 CHECK(
false) <<
"File contains more than 1 + 2 * N^2 entries.";
Collection of objects used to extend the Constraint Solver library.
QapProblem ReadQapProblemOrDie(const std::string &filepath)
std::vector< std::vector< int64_t > > weights
std::vector< std::vector< int64_t > > distances
int64_t best_known_solution