Пример #1
0
 //changes the demand for an airport with a factor
 public static void ChangePaxDemand(Airport airport, double factor)
 {
     double value = (100 + factor) / 100;
     //factor 0.5 - 2;
     foreach (DestinationDemand destPax in airport.getDestinationsPassengers())
     {
         if (destPax.Rate > 0)
         {
             ushort oRate = destPax.Rate;
             if (oRate * value == destPax.Rate)
                 destPax.Rate = Convert.ToUInt16(destPax.Rate + Convert.ToUInt16(rnd.Next(0, Math.Max(1, (int)factor))));
             else
                 destPax.Rate = (ushort)(destPax.Rate * value);
         }
         else
             destPax.Rate = (ushort)rnd.Next(1, Math.Max(1, (int)factor));
     }
 }
Пример #2
0
 //reallocate the pax demand from one airport to another
 public static void ReallocateAirport(Airport airportOld, Airport airportNew)
 {
     if (airportNew.getMajorDestinations().Count == 0)
     {
         foreach (DestinationDemand paxDemand in airportOld.getDestinationsPassengers())
             airportNew.addDestinationPassengersRate(paxDemand);
     }
 }
Пример #3
0
 //creates the airport destination passengers a destination
 public static void CreateDestinationPassengers(Airport airport)
 {
     var airports = Airports.GetAirports(a => a != airport && a.Profile.Town != airport.Profile.Town && MathHelpers.GetDistance(a.Profile.Coordinates.convertToGeoCoordinate(), airport.Profile.Coordinates.convertToGeoCoordinate()) > 50);
     //Parallel.ForEach(airports, dAirport =>
     foreach (Airport dAirport in airports)
     {
         CreateDestinationPassengers(airport, dAirport);
     }//);
     if (airport.getDestinationsPassengers().Sum(d => d.Rate) == 0)
     {
         var subAirports = airports.FindAll(a => a.Profile.Country == airport.Profile.Country).DefaultIfEmpty().ToList();
         subAirports.RemoveAll(a => a == null);
         if (subAirports != null && subAirports.Count() > 0)
         {
             CreateDestinationPassengers(airport, subAirports);
         }
         else
         {
             subAirports = airports.FindAll(a => a.Profile.Country.Region == airport.Profile.Country.Region).ToList();
             CreateDestinationPassengers(airport, subAirports);
         }
     }
 }