Update routing C++ samples
This commit is contained in:
@@ -88,6 +88,9 @@ void PrintSolution(const RoutingIndexManager& manager,
|
||||
LOG(INFO) << "Objective: " << solution.ObjectiveValue();
|
||||
int64_t total_distance{0};
|
||||
for (int vehicle_id = 0; vehicle_id < manager.num_vehicles(); ++vehicle_id) {
|
||||
if (!routing.IsVehicleUsed(solution, vehicle_id)) {
|
||||
continue;
|
||||
}
|
||||
int64_t index = routing.Start(vehicle_id);
|
||||
LOG(INFO) << "Route for Vehicle " << vehicle_id << ":";
|
||||
int64_t distance{0};
|
||||
|
||||
@@ -89,6 +89,9 @@ void PrintSolution(const RoutingIndexManager& manager,
|
||||
const RoutingDimension& time_dimension = routing.GetDimensionOrDie("Time");
|
||||
int64_t total_time{0};
|
||||
for (int vehicle_id = 0; vehicle_id < manager.num_vehicles(); ++vehicle_id) {
|
||||
if (!routing.IsVehicleUsed(solution, vehicle_id)) {
|
||||
continue;
|
||||
}
|
||||
LOG(INFO) << "Route for Vehicle " << vehicle_id << ":";
|
||||
int64_t index = routing.Start(vehicle_id);
|
||||
std::stringstream route;
|
||||
|
||||
@@ -88,6 +88,9 @@ void PrintSolution(const DataModel& data, const RoutingIndexManager& manager,
|
||||
int64_t total_distance = 0;
|
||||
int64_t total_load = 0;
|
||||
for (int vehicle_id = 0; vehicle_id < data.num_vehicles; ++vehicle_id) {
|
||||
if (!routing.IsVehicleUsed(solution, vehicle_id)) {
|
||||
continue;
|
||||
}
|
||||
int64_t index = routing.Start(vehicle_id);
|
||||
LOG(INFO) << "Route for Vehicle " << vehicle_id << ":";
|
||||
int64_t route_distance = 0;
|
||||
|
||||
@@ -98,6 +98,9 @@ void PrintSolution(const DataModel& data, const RoutingIndexManager& manager,
|
||||
int64_t total_distance{0};
|
||||
int64_t total_load{0};
|
||||
for (int vehicle_id = 0; vehicle_id < data.num_vehicles; ++vehicle_id) {
|
||||
if (!routing.IsVehicleUsed(solution, vehicle_id)) {
|
||||
continue;
|
||||
}
|
||||
int64_t index = routing.Start(vehicle_id);
|
||||
LOG(INFO) << "Route for Vehicle " << vehicle_id << ":";
|
||||
int64_t route_distance{0};
|
||||
|
||||
@@ -81,6 +81,9 @@ void PrintSolution(const DataModel& data, const RoutingIndexManager& manager,
|
||||
const RoutingModel& routing, const Assignment& solution) {
|
||||
int64_t max_route_distance{0};
|
||||
for (int vehicle_id = 0; vehicle_id < data.num_vehicles; ++vehicle_id) {
|
||||
if (!routing.IsVehicleUsed(solution, vehicle_id)) {
|
||||
continue;
|
||||
}
|
||||
int64_t index = routing.Start(vehicle_id);
|
||||
LOG(INFO) << "Route for Vehicle " << vehicle_id << ":";
|
||||
int64_t route_distance{0};
|
||||
|
||||
@@ -91,6 +91,9 @@ void PrintSolution(const DataModel& data, const RoutingIndexManager& manager,
|
||||
LOG(INFO) << "Objective: " << solution.ObjectiveValue();
|
||||
int64_t max_route_distance{0};
|
||||
for (int vehicle_id = 0; vehicle_id < data.num_vehicles; ++vehicle_id) {
|
||||
if (!routing.IsVehicleUsed(solution, vehicle_id)) {
|
||||
continue;
|
||||
}
|
||||
int64_t index = routing.Start(vehicle_id);
|
||||
LOG(INFO) << "Route for Vehicle " << vehicle_id << ":";
|
||||
int64_t route_distance{0};
|
||||
|
||||
@@ -101,6 +101,9 @@ void PrintSolution(const DataModel& data, const RoutingIndexManager& manager,
|
||||
const RoutingModel& routing, const Assignment& solution) {
|
||||
int64_t total_distance{0};
|
||||
for (int vehicle_id = 0; vehicle_id < data.num_vehicles; ++vehicle_id) {
|
||||
if (!routing.IsVehicleUsed(solution, vehicle_id)) {
|
||||
continue;
|
||||
}
|
||||
int64_t index = routing.Start(vehicle_id);
|
||||
LOG(INFO) << "Route for Vehicle " << vehicle_id << ":";
|
||||
int64_t route_distance{0};
|
||||
|
||||
@@ -101,6 +101,9 @@ void PrintSolution(const DataModel& data, const RoutingIndexManager& manager,
|
||||
const RoutingModel& routing, const Assignment& solution) {
|
||||
int64_t total_distance{0};
|
||||
for (int vehicle_id = 0; vehicle_id < data.num_vehicles; ++vehicle_id) {
|
||||
if (!routing.IsVehicleUsed(solution, vehicle_id)) {
|
||||
continue;
|
||||
}
|
||||
int64_t index = routing.Start(vehicle_id);
|
||||
LOG(INFO) << "Route for Vehicle " << vehicle_id << ":";
|
||||
int64_t route_distance = 0;
|
||||
|
||||
@@ -101,6 +101,9 @@ void PrintSolution(const DataModel& data, const RoutingIndexManager& manager,
|
||||
const RoutingModel& routing, const Assignment& solution) {
|
||||
int64_t total_distance{0};
|
||||
for (int vehicle_id = 0; vehicle_id < data.num_vehicles; ++vehicle_id) {
|
||||
if (!routing.IsVehicleUsed(solution, vehicle_id)) {
|
||||
continue;
|
||||
}
|
||||
int64_t index = routing.Start(vehicle_id);
|
||||
LOG(INFO) << "Route for Vehicle " << vehicle_id << ":";
|
||||
int64_t route_distance{0};
|
||||
|
||||
@@ -90,6 +90,9 @@ void PrintSolution(const DataModel& data, const RoutingIndexManager& manager,
|
||||
const RoutingDimension& time_dimension = routing.GetDimensionOrDie("Time");
|
||||
int64_t total_time{0};
|
||||
for (int vehicle_id = 0; vehicle_id < data.num_vehicles; ++vehicle_id) {
|
||||
if (!routing.IsVehicleUsed(solution, vehicle_id)) {
|
||||
continue;
|
||||
}
|
||||
int64_t index = routing.Start(vehicle_id);
|
||||
LOG(INFO) << "Route for vehicle " << vehicle_id << ":";
|
||||
std::ostringstream route;
|
||||
|
||||
@@ -85,6 +85,9 @@ void print_solution(const RoutingIndexManager& routing_manager,
|
||||
for (int vehicle_id = 0; vehicle_id < routing_manager.num_vehicles();
|
||||
++vehicle_id) {
|
||||
int64_t index = routing_model.Start(vehicle_id);
|
||||
if (routing_model.IsEnd(routing_model.NextVar(index)->Value())) {
|
||||
continue;
|
||||
}
|
||||
LOG(INFO) << "Route for Vehicle " << vehicle_id << ":";
|
||||
int64_t route_distance = 0;
|
||||
std::stringstream route;
|
||||
|
||||
@@ -94,6 +94,9 @@ void PrintSolution(const DataModel& data, const RoutingIndexManager& manager,
|
||||
const RoutingModel& routing, const Assignment& solution) {
|
||||
int64_t max_route_distance{0};
|
||||
for (int vehicle_id = 0; vehicle_id < data.num_vehicles; ++vehicle_id) {
|
||||
if (!routing.IsVehicleUsed(solution, vehicle_id)) {
|
||||
continue;
|
||||
}
|
||||
int64_t index = routing.Start(vehicle_id);
|
||||
LOG(INFO) << "Route for Vehicle " << vehicle_id << ":";
|
||||
int64_t route_distance{0};
|
||||
|
||||
@@ -86,6 +86,9 @@ void PrintSolution(const DataModel& data, const RoutingIndexManager& manager,
|
||||
const RoutingDimension& time_dimension = routing.GetDimensionOrDie("Time");
|
||||
int64_t total_time{0};
|
||||
for (int vehicle_id = 0; vehicle_id < data.num_vehicles; ++vehicle_id) {
|
||||
if (!routing.IsVehicleUsed(solution, vehicle_id)) {
|
||||
continue;
|
||||
}
|
||||
int64_t index = routing.Start(vehicle_id);
|
||||
LOG(INFO) << "Route for vehicle " << vehicle_id << ":";
|
||||
std::ostringstream route;
|
||||
|
||||
@@ -37,6 +37,9 @@ void PrintSolution(const RoutingIndexManager& manager,
|
||||
const RoutingModel& routing, const Assignment& solution) {
|
||||
int64_t max_route_distance = 0;
|
||||
for (int vehicle_id = 0; vehicle_id < manager.num_vehicles(); ++vehicle_id) {
|
||||
if (!routing.IsVehicleUsed(solution, vehicle_id)) {
|
||||
continue;
|
||||
}
|
||||
int64_t index = routing.Start(vehicle_id);
|
||||
LOG(INFO) << "Route for Vehicle " << vehicle_id << ":";
|
||||
int64_t route_distance = 0;
|
||||
|
||||
@@ -82,6 +82,9 @@ void PrintSolution(
|
||||
int64_t total_time{0};
|
||||
std::ostringstream route;
|
||||
for (int vehicle_id = 0; vehicle_id < routes.size(); ++vehicle_id) {
|
||||
if (routes[vehicle_id].size() <= 2) {
|
||||
continue;
|
||||
}
|
||||
route << "\nRoute " << vehicle_id << ": \n";
|
||||
|
||||
route << " " << routes[vehicle_id][0] << " Time("
|
||||
|
||||
Reference in New Issue
Block a user