18 #include "absl/flags/flag.h"
19 #include "gtest/gtest.h"
25 #define ROOT_DIR "../../../../../../../"
30 ABSL_FLAG(std::string, test_srcdir,
"",
"REQUIRED: src dir");
35 TEST(TspTWParserTest, LoadDataSet) {
36 const int sizes[] = {26, 21, 21};
37 const double distances[] = {25166.316, 9538, 9006};
38 const double times[] = {25166.316, 9538, 9006};
39 const double starts[] = {9362, 2388, 2392};
40 const double ends[] = {13322, 3131, 3146};
41 const double service_times[] = {250, 0, 0};
42 const bool has_coordinates[] = {
false,
false,
true};
44 for (
const std::string& data :
45 {
ROOT_DIR "ortools/routing/testdata/rc201.0",
46 ROOT_DIR "ortools/routing/testdata/n20w20.001.txt",
47 ROOT_DIR "ortools/routing/testdata/n20w20.002.txt"}) {
49 EXPECT_TRUE(parser.LoadFile(
51 EXPECT_EQ(0, parser.depot());
52 const int size = sizes[count];
53 EXPECT_EQ(size, parser.size());
54 double total_distances = 0;
55 double total_times = 0;
56 for (
int i = 0; i < size; ++i) {
57 for (
int j = 0; j < size; ++j) {
58 total_distances += parser.distance_function()(i, j);
59 total_times += parser.time_function()(i, j);
62 EXPECT_NEAR(distances[count], total_distances, 1e-6);
63 EXPECT_NEAR(times[count], total_times, 1e-6);
64 EXPECT_EQ(service_times[count], parser.total_service_time());
65 EXPECT_EQ(has_coordinates[count], !parser.coordinates().empty());
66 double total_starts = 0;
67 double total_ends = 0;
68 for (
int i = 0; i < size; ++i) {
69 EXPECT_EQ(0, parser.service_times()[i]);
70 total_starts += parser.time_windows()[i].start;
71 total_ends += parser.time_windows()[i].end;
73 EXPECT_EQ(starts[count], total_starts);
74 EXPECT_EQ(ends[count], total_ends);
std::string JoinPath(absl::string_view path1, absl::string_view path2)
Collection of objects used to extend the Constraint Solver library.
TEST(LinearAssignmentTest, NullMatrix)
ABSL_FLAG(std::string, test_srcdir, "", "REQUIRED: src dir")