Skip to content

Commit

Permalink
update java routing samples
Browse files Browse the repository at this point in the history
  • Loading branch information
lperron committed Jan 29, 2025
1 parent 77fd88c commit 578961e
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ortools/constraint_solver/samples/Vrp.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ static void printSolution(
// Inspect solution.
long totalDistance = 0;
for (int i = 0; i < manager.getNumberOfVehicles(); ++i) {
if (!routing.isVehicleUsed(solution, i)) {
continue;
}
logger.info("Route for Vehicle " + i + ":");
long routeDistance = 0;
String route = "";
Expand Down
3 changes: 3 additions & 0 deletions ortools/constraint_solver/samples/VrpBreaks.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ static void printSolution(
long totalTime = 0;
RoutingDimension timeDimension = routing.getMutableDimension("Time");
for (int i = 0; i < manager.getNumberOfVehicles(); ++i) {
if (!routing.isVehicleUsed(solution, i)) {
continue;
}
logger.info("Route for Vehicle " + i + ":");
long index = routing.start(i);
String route = "";
Expand Down
3 changes: 3 additions & 0 deletions ortools/constraint_solver/samples/VrpCapacity.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ static void printSolution(
long totalDistance = 0;
long totalLoad = 0;
for (int i = 0; i < data.vehicleNumber; ++i) {
if (!routing.isVehicleUsed(solution, i)) {
continue;
}
long index = routing.start(i);
logger.info("Route for Vehicle " + i + ":");
long routeDistance = 0;
Expand Down
3 changes: 3 additions & 0 deletions ortools/constraint_solver/samples/VrpDropNodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ static void printSolution(
long totalDistance = 0;
long totalLoad = 0;
for (int i = 0; i < data.vehicleNumber; ++i) {
if (!routing.isVehicleUsed(solution, i)) {
continue;
}
long index = routing.start(i);
logger.info("Route for Vehicle " + i + ":");
long routeDistance = 0;
Expand Down
3 changes: 3 additions & 0 deletions ortools/constraint_solver/samples/VrpGlobalSpan.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ static void printSolution(
// Inspect solution.
long maxRouteDistance = 0;
for (int i = 0; i < data.vehicleNumber; ++i) {
if (!routing.isVehicleUsed(solution, i)) {
continue;
}
long index = routing.start(i);
logger.info("Route for Vehicle " + i + ":");
long routeDistance = 0;
Expand Down
3 changes: 3 additions & 0 deletions ortools/constraint_solver/samples/VrpInitialRoutes.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ static void printSolution(
// Inspect solution.
long maxRouteDistance = 0;
for (int i = 0; i < data.vehicleNumber; ++i) {
if (!routing.isVehicleUsed(solution, i)) {
continue;
}
long index = routing.start(i);
logger.info("Route for Vehicle " + i + ":");
long routeDistance = 0;
Expand Down
3 changes: 3 additions & 0 deletions ortools/constraint_solver/samples/VrpPickupDelivery.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ static void printSolution(
// Inspect solution.
long totalDistance = 0;
for (int i = 0; i < data.vehicleNumber; ++i) {
if (!routing.isVehicleUsed(solution, i)) {
continue;
}
long index = routing.start(i);
logger.info("Route for Vehicle " + i + ":");
long routeDistance = 0;
Expand Down
3 changes: 3 additions & 0 deletions ortools/constraint_solver/samples/VrpPickupDeliveryFifo.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ static void printSolution(
// Inspect solution.
long totalDistance = 0;
for (int i = 0; i < data.vehicleNumber; ++i) {
if (!routing.isVehicleUsed(solution, i)) {
continue;
}
long index = routing.start(i);
logger.info("Route for Vehicle " + i + ":");
long routeDistance = 0;
Expand Down
3 changes: 3 additions & 0 deletions ortools/constraint_solver/samples/VrpPickupDeliveryLifo.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ static void printSolution(
// Inspect solution.
long totalDistance = 0;
for (int i = 0; i < data.vehicleNumber; ++i) {
if (!routing.isVehicleUsed(solution, i)) {
continue;
}
long index = routing.start(i);
logger.info("Route for Vehicle " + i + ":");
long routeDistance = 0;
Expand Down
3 changes: 3 additions & 0 deletions ortools/constraint_solver/samples/VrpResources.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ static void printSolution(
RoutingDimension timeDimension = routing.getMutableDimension("Time");
long totalTime = 0;
for (int i = 0; i < data.vehicleNumber; ++i) {
if (!routing.isVehicleUsed(solution, i)) {
continue;
}
long index = routing.start(i);
logger.info("Route for Vehicle " + i + ":");
String route = "";
Expand Down
3 changes: 3 additions & 0 deletions ortools/constraint_solver/samples/VrpSolutionCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ static void printSolution(RoutingIndexManager routingManager, RoutingModel routi
// Inspect solution.
long totalDistance = 0;
for (int i = 0; i < routingManager.getNumberOfVehicles(); ++i) {
if (routingModel.activeVehicleVar(i).value() == 0) {
continue;
}
logger.info("Route for Vehicle " + i + ":");
long routeDistance = 0;
long index = routingModel.start(i);
Expand Down
3 changes: 3 additions & 0 deletions ortools/constraint_solver/samples/VrpStartsEnds.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ static void printSolution(
// Inspect solution.
long maxRouteDistance = 0;
for (int i = 0; i < data.vehicleNumber; ++i) {
if (!routing.isVehicleUsed(solution, i)) {
continue;
}
long index = routing.start(i);
logger.info("Route for Vehicle " + i + ":");
long routeDistance = 0;
Expand Down
3 changes: 3 additions & 0 deletions ortools/constraint_solver/samples/VrpTimeWindows.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ static void printSolution(
RoutingDimension timeDimension = routing.getMutableDimension("Time");
long totalTime = 0;
for (int i = 0; i < data.vehicleNumber; ++i) {
if (!routing.isVehicleUsed(solution, i)) {
continue;
}
long index = routing.start(i);
logger.info("Route for Vehicle " + i + ":");
String route = "";
Expand Down
3 changes: 3 additions & 0 deletions ortools/constraint_solver/samples/VrpWithTimeLimit.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ static void printSolution(
// Inspect solution.
long maxRouteDistance = 0;
for (int i = 0; i < manager.getNumberOfVehicles(); ++i) {
if (!routing.isVehicleUsed(solution, i)) {
continue;
}
long index = routing.start(i);
logger.info("Route for Vehicle " + i + ":");
long routeDistance = 0;
Expand Down

0 comments on commit 578961e

Please sign in to comment.