update C# routing examples

This commit is contained in:
Laurent Perron
2025-01-29 13:35:56 +01:00
parent f10a432650
commit 77fd88c618
14 changed files with 56 additions and 0 deletions

View File

@@ -62,6 +62,10 @@ public class Vrp
long totalDistance = 0;
for (int i = 0; i < data.VehicleNumber; ++i)
{
if (!routing.IsVehicleUsed(solution, i))
{
continue;
}
Console.WriteLine("Route for Vehicle {0}:", i);
long routeDistance = 0;
var index = routing.Start(i);

View File

@@ -81,6 +81,10 @@ public class VrpBreaks
long totalTime = 0;
for (int i = 0; i < manager.GetNumberOfVehicles(); ++i)
{
if (!routing.IsVehicleUsed(solution, i))
{
continue;
}
Console.WriteLine($"Route for Vehicle {i}:");
var index = routing.Start(i);
while (routing.IsEnd(index) == false)

View File

@@ -69,6 +69,10 @@ public class VrpCapacity
long totalLoad = 0;
for (int i = 0; i < data.VehicleNumber; ++i)
{
if (!routing.IsVehicleUsed(solution, i))
{
continue;
}
Console.WriteLine("Route for Vehicle {0}:", i);
long routeDistance = 0;
long routeLoad = 0;

View File

@@ -84,6 +84,10 @@ public class VrpDropNodes
long totalLoad = 0;
for (int i = 0; i < data.VehicleNumber; ++i)
{
if (!routing.IsVehicleUsed(solution, i))
{
continue;
}
Console.WriteLine("Route for Vehicle {0}:", i);
long routeDistance = 0;
long routeLoad = 0;

View File

@@ -63,6 +63,10 @@ public class VrpGlobalSpan
long maxRouteDistance = 0;
for (int i = 0; i < data.VehicleNumber; ++i)
{
if (!routing.IsVehicleUsed(solution, i))
{
continue;
}
Console.WriteLine("Route for Vehicle {0}:", i);
long routeDistance = 0;
var index = routing.Start(i);

View File

@@ -71,6 +71,10 @@ public class InitialRoutes
long maxRouteDistance = 0;
for (int i = 0; i < data.VehicleNumber; ++i)
{
if (!routing.IsVehicleUsed(solution, i))
{
continue;
}
Console.WriteLine("Route for Vehicle {0}:", i);
long routeDistance = 0;
var index = routing.Start(i);

View File

@@ -69,6 +69,10 @@ public class VrpPickupDelivery
long totalDistance = 0;
for (int i = 0; i < data.VehicleNumber; ++i)
{
if (!routing.IsVehicleUsed(solution, i))
{
continue;
}
Console.WriteLine("Route for Vehicle {0}:", i);
long routeDistance = 0;
var index = routing.Start(i);

View File

@@ -69,6 +69,10 @@ public class VrpPickupDeliveryFifo
long totalDistance = 0;
for (int i = 0; i < data.VehicleNumber; ++i)
{
if (!routing.IsVehicleUsed(solution, i))
{
continue;
}
Console.WriteLine("Route for Vehicle {0}:", i);
long routeDistance = 0;
var index = routing.Start(i);

View File

@@ -69,6 +69,10 @@ public class VrpPickupDeliveryLifo
long totalDistance = 0;
for (int i = 0; i < data.VehicleNumber; ++i)
{
if (!routing.IsVehicleUsed(solution, i))
{
continue;
}
Console.WriteLine("Route for Vehicle {0}:", i);
long routeDistance = 0;
var index = routing.Start(i);

View File

@@ -89,6 +89,10 @@ public class VrpResources
long totalTime = 0;
for (int i = 0; i < data.VehicleNumber; ++i)
{
if (!routing.IsVehicleUsed(solution, i))
{
continue;
}
Console.WriteLine("Route for Vehicle {0}:", i);
var index = routing.Start(i);
while (routing.IsEnd(index) == false)

View File

@@ -67,6 +67,10 @@ public class VrpSolutionCallback
Console.WriteLine($"Route for Vehicle {i}:");
long routeDistance = 0;
long index = routingModel.Start(i);
if (routingModel.IsEnd(routingModel.NextVar(index).Value()))
{
continue;
}
while (routingModel.IsEnd(index) == false)
{
Console.Write($" {routingManager.IndexToNode(index)} ->");

View File

@@ -66,6 +66,10 @@ public class VrpStartsEnds
long maxRouteDistance = 0;
for (int i = 0; i < data.VehicleNumber; ++i)
{
if (!routing.IsVehicleUsed(solution, i))
{
continue;
}
Console.WriteLine("Route for Vehicle {0}:", i);
long routeDistance = 0;
var index = routing.Start(i);

View File

@@ -84,6 +84,10 @@ public class VrpTimeWindows
long totalTime = 0;
for (int i = 0; i < data.VehicleNumber; ++i)
{
if (!routing.IsVehicleUsed(solution, i))
{
continue;
}
Console.WriteLine("Route for Vehicle {0}:", i);
var index = routing.Start(i);
while (routing.IsEnd(index) == false)

View File

@@ -36,6 +36,10 @@ public class Vrp
long maxRouteDistance = 0;
for (int i = 0; i < manager.GetNumberOfVehicles(); ++i)
{
if (!routing.IsVehicleUsed(solution, i))
{
continue;
}
Console.WriteLine("Route for Vehicle {0}:", i);
long routeDistance = 0;
var index = routing.Start(i);