Beispiel #1
0
 public TransportUnit(Destination origin, Destination destination, DateTime minPickupTime, DateTime maxDeliveryTime, CargoDefinition cargo, Route selectedRoute)
 {
     this.Init(origin, destination, minPickupTime, maxDeliveryTime, cargo);
     this.selectedRoute = selectedRoute;
 }
        private void FetchResults(IEnumerable<TransportUnit> transportUnits)
        {
            IEnumerable<OutFileRow> results = ParseResultFile();
            IEnumerable<ShortageRow> shortages = ParseShortageFile();

            foreach (var unit in transportUnits)
            {
                TransportUnit transportUnit = unit;

                var rows = results.Where(row => row.Origin == transportUnit.Origin.Id && row.Destination == transportUnit.Destination.Id);
                var usedLegs = rows.Select(row => _legs.Where(l => l.Id == row.LegId).Single()).ToList();

                if (usedLegs.Count == 0)
                    return;

                double shortage = 0;

                foreach (ShortageRow row in shortages.Where(row => row.Origin == transportUnit.Origin.Id && row.Destination == transportUnit.Destination.Id))
                {
                    shortage = row.Shortage;
                }

                var route = new Route(unit, shortage, usedLegs);

                unit.ProposedRoutes.Add(route);
            }
        }
Beispiel #3
0
        public virtual void SelectRoute(int routeIndex)
        {
            if (routeIndex >= this.ProposedRoutes.Count)
            {
                throw new IndexOutOfRangeException();
            }

            this.selectedRoute = this.ProposedRoutes[routeIndex];
        }