namespace OpenTraffic.Model.Simulator.RouteAssigner { using System; using System.Collections.Generic; using System.Text; using OpenTraffic.Model.Route; [Serializable] public class ShortestPath : Logit { public ShortestPath() : base(-1, true) { } public override Object Clone() { return new ShortestPath(); } protected override void FillInRoute(Vehicle v) { if (v != null) { if (v.trafficRoute == null) { base.FillInRoute(v); return; } List routes = RoutesLookup[v.Origin][v.Destination]; double costMin = double.PositiveInfinity; TrafficRoute route = null; foreach (RouteContainer rc in routes) { TrafficRoute r = rc.GetShortestRoute(v.StartTime, v.routeClass, inResult); // xxx can be removed if (r.Allowed(v.routeClass)) { double cost = v.routeClass.CalculateCost(r, inResult, v.StartTime); if (cost < costMin) { route = r; costMin = cost; } } } v.trafficRoute = route; } } public override string ToString() { return "Shortest"; } } }