R,
To make sure we are standing on the same line, let me descript my understanding at first:
There are several places needed to visit marked with P(p1, p2 … pn), the corresponding visit time array is T( t1, t2 … tn ) , and the start visiting time is t0, start place is p0. The constraint is the visit time for each client should be earlier than needed visit time (tn). We need to create a route base on the schedule. Right?
I’m sorry but I need to say we can’t solve it based on lasted public release if the description is what you want, which is a Vehicle Routing Problem (VRP). However, we can give you a temporary version by asking for support@thinkgeo.com if you want it, maybe a little slower, but we will solve it as soon as possible if you are urgent.
Here are some tips about how to deal with that based on the temporary version:
1. Build routing index file using driving time (Minutes) as the weight of RouteSegment.
2. Initialize a matrix containing all the RoutingResult between places, and below is the sample code:
List<PointShape> points = new List<PointShape>(P);
points.Add(p0);
// Initialize Route Matrix
RoutingResult[,] routeMatrix = new RoutingResult[points.Count, points.Count];
for (int i = 0; i < points.Count; i++)
{
for (int j = i + 1; j < points.Count; j++)
{
RoutingResult result = GetRoute(points[i], points[j]); // Get the route between two places
if (result.RouteSegments.Count <= 0)
{
result.Distance = double.MaxValue;
}
routeMatrix[i, j] = result;
routeMatrix[j, i] = result;
}
}
3. Use “routingEngine.GetRouteViaVisitStops” to create the route, and attach the “GettingRouteViaVisitStops” event to RoutingEngine. See sample code below:
routingEngine.GettingRouteViaVisitStops += new EventHandler<GettingRouteViaVisitStopsRoutingEngineEventArgs>(routingEngine_GettingRouteViaVisitStops);
routingEngine.GetRouteViaVisitStops(p0, points, 100);
4. Filter the temporary visit route in “routingEngine_GettingRouteViaVisitStops” method.
Collection<int> visitIndexes = e.VisitSequence;
DateTime visitTime = new DateTime();
int startIndex = points.Count;
for (int i = 0; i < visitIndexes.Count; i++)
{
int visitIndex = visitIndexes<i>;
// Get the time between two places
double time = routeMatrix[startIndex, visitIndex].Distance;
visitTime.AddMinutes(time);
double requiredVisitTime = T[visitIndex];
if (visitTime.CompareTo(requiredVisitTime) > 0) // the visit time is later than the required
{
e.TotalDistance = Double.MaxValue;
e.VisitSequence.clear();
break;
}
}
Thanks for your ideas, which did help improving our products a lot. This is a bit more complex, and any question please let me know.
Thanks,
Johnny