Skip to content

Commit

Permalink
update or-tools, add fmt dependency for glog
Browse files Browse the repository at this point in the history
  • Loading branch information
shineyruan committed Apr 11, 2024
1 parent bf2c165 commit 9ec4ddb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ortools_ros/ortools
Submodule ortools updated 2616 files
1 change: 1 addition & 0 deletions ortools_ros_examples/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<buildtool_depend>ament_cmake_auto</buildtool_depend>

<depend>ortools_ros</depend>
<depend>fmt</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
Expand Down
13 changes: 9 additions & 4 deletions ortools_ros_examples/src/vrp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
* https://developers.google.com/optimization/routing/vrp#entire_program1
*/

#define FMT_HEADER_ONLY
#include <fmt/format.h>

#include <algorithm>
#include <cstdint>
#include <sstream>
Expand Down Expand Up @@ -67,7 +70,7 @@ void PrintSolution(const DataModel &data, const RoutingIndexManager &manager,
int64_t max_route_distance{0};
for (int vehicle_id = 0; vehicle_id < data.num_vehicles; ++vehicle_id) {
int64_t index = routing.Start(vehicle_id);
LOG(INFO) << "Route for Vehicle " << vehicle_id << ":";
LOG(INFO) << fmt::format("Route for Vehicle {}:", vehicle_id);
int64_t route_distance{0};
std::stringstream route;
while (routing.IsEnd(index) == false) {
Expand All @@ -78,12 +81,14 @@ void PrintSolution(const DataModel &data, const RoutingIndexManager &manager,
int64_t{vehicle_id});
}
LOG(INFO) << route.str() << manager.IndexToNode(index).value();
LOG(INFO) << "Distance of the route: " << route_distance << "m";
LOG(INFO) << fmt::format("Distance of the route: {}m", route_distance);
max_route_distance = std::max(route_distance, max_route_distance);
}
LOG(INFO) << "Maximum of the route distances: " << max_route_distance << "m";
LOG(INFO) << fmt::format("Maximum of the route distances: {}m",
max_route_distance);
LOG(INFO) << "";
LOG(INFO) << "Problem solved in " << routing.solver()->wall_time() << "ms";
LOG(INFO) << fmt::format("Problem solved in {}ms",
routing.solver()->wall_time());
}

void VrpGlobalSpan() {
Expand Down

0 comments on commit 9ec4ddb

Please sign in to comment.