本文整理汇总了C#中TheAirline.Model.AirportModel.Airport.getDestinationPassengersRate方法的典型用法代码示例。如果您正苦于以下问题:C# Airport.getDestinationPassengersRate方法的具体用法?C# Airport.getDestinationPassengersRate怎么用?C# Airport.getDestinationPassengersRate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TheAirline.Model.AirportModel.Airport
的用法示例。
在下文中一共展示了Airport.getDestinationPassengersRate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFlightPassengers
//returns the number of passengers between two destinations
public static int GetFlightPassengers(Airport airportCurrent, Airport airportDestination, FleetAirliner airliner, AirlinerClass.ClassType type)
{
double distance = MathHelpers.GetDistance(airportCurrent, airportDestination);
var currentRoute = airliner.Routes.Find(r => r.Stopovers.SelectMany(s => s.Legs).ToList().Exists(l => (l.Destination1 == airportCurrent || l.Destination1 == airportDestination) && (l.Destination2 == airportDestination || l.Destination2 == airportCurrent)) || (r.Destination1 == airportCurrent || r.Destination1 == airportDestination) && (r.Destination2 == airportDestination || r.Destination2 == airportCurrent));
if (currentRoute == null)
return 0;
double basicPrice = GetPassengerPrice(currentRoute.Destination1, currentRoute.Destination2, type);
double routePrice = ((PassengerRoute)currentRoute).getFarePrice(type);
double priceDiff = basicPrice / routePrice;
double demand = (double)airportCurrent.getDestinationPassengersRate(airportDestination, type);
double passengerDemand = (demand + GetFlightConnectionPassengers(airportCurrent, airportDestination, airliner, type) + GetNearbyPassengerDemand(airportCurrent, airportDestination, airliner, type)) * GetSeasonFactor(airportDestination) * GetHolidayFactor(airportDestination) * GetHolidayFactor(airportCurrent);
passengerDemand *= GameObject.GetInstance().Difficulty.PassengersLevel;
if (airliner.Airliner.Airline.MarketFocus == Airline.AirlineFocus.Global && distance > 3000 && airportCurrent.Profile.Country != airportDestination.Profile.Country)
passengerDemand = passengerDemand * (115 / 100);
if (airliner.Airliner.Airline.MarketFocus == Airline.AirlineFocus.Regional && distance < 1500)
passengerDemand = passengerDemand * (115 / 100);
if (airliner.Airliner.Airline.MarketFocus == Airline.AirlineFocus.Domestic && distance < 1500 && airportDestination.Profile.Country == airportCurrent.Profile.Country)
passengerDemand = passengerDemand * (115 / 100);
if (airliner.Airliner.Airline.MarketFocus == Airline.AirlineFocus.Local && distance < 1000)
passengerDemand = passengerDemand * (115 / 100);
var hub = airportDestination.getHubs().Find(h => h.Airline == airliner.Airliner.Airline);
if (hub != null)
{
switch (hub.Type.Type)
{
case HubType.TypeOfHub.Focus_city:
if (airportDestination.Profile.Country == airportCurrent.Profile.Country)
passengerDemand = passengerDemand * 1.15;
break;
case HubType.TypeOfHub.Regional_hub:
if (airportDestination.Profile.Country.Region == airportCurrent.Profile.Country.Region)
passengerDemand = passengerDemand * 1.20;
break;
case HubType.TypeOfHub.Hub:
passengerDemand = passengerDemand * 1.20;
break;
case HubType.TypeOfHub.Fortress_hub:
passengerDemand = passengerDemand * 1.30;
break;
}
}
List<Route> routes = new List<Route>();
foreach (Airline airline in Airlines.GetAllAirlines())
{
var aRoutes = new List<Route>(airline.Routes);
routes.AddRange(aRoutes.Where(r => r.Type == Route.RouteType.Passenger || r.Type == Route.RouteType.Mixed).Where(r => (r.HasAirliner) && (r.Destination1 == airportCurrent || r.Destination1 == airportDestination) && (r.Destination2 == airportDestination || r.Destination2 == airportCurrent)));
routes.AddRange(aRoutes.Where(r => r.Type == Route.RouteType.Mixed || r.Type == Route.RouteType.Passenger).Where(r => r.Stopovers.SelectMany(s => s.Legs.Where(l => r.HasAirliner && (l.Destination1 == airportCurrent || l.Destination1 == airportDestination) && (l.Destination2 == airportDestination || l.Destination2 == airportCurrent))).Count() > 0));
}
double flightsPerDay = Convert.ToDouble(routes.Sum(r => r.TimeTable.Entries.Count)) / 7;
passengerDemand = passengerDemand / flightsPerDay;
double totalCapacity = 0;
if (routes.Count > 0 && routes.Count(r => r.HasAirliner) > 0)
totalCapacity = routes.Where(r => r.HasAirliner).Sum(r => r.getAirliners().Max(a => a.Airliner.getTotalSeatCapacity()));//SelectMany(r => r.Stopovers.Where(s=>s.Legs.Count >0))).Sum(s=>s.;//a => a.Routes.SelectMany(r=>r.Stopovers.SelectMany(s=>s.Legs.Where(l=>r.HasAirliner && (l.Destination1 == airportCurrent || l.Destination1 == airportDestination) && (l.Destination2 == airportDestination || l.Destination2 == airportCurrent))).Sum(r=>r.getAirliners().Max(a=>a.Airliner.getTotalSeatCapacity()));
else
totalCapacity = 0;// routes.Where(r => r.HasAirliner).Sum(r => r.getAirliners().Max(a => a.Airliner.getTotalSeatCapacity()));
double capacityPercent = passengerDemand > totalCapacity ? 1 : passengerDemand / totalCapacity;
Dictionary<Route, double> rations = new Dictionary<Route, double>();
foreach (Route route in routes)
{
double level = ((PassengerRoute)route).getServiceLevel(type) / ((PassengerRoute)route).getFarePrice(type);
rations.Add(route, level);
}
double totalRatio = rations.Values.Sum();
double routeRatioPercent = 1;
if (rations.ContainsKey(currentRoute))
routeRatioPercent = Math.Max(1, rations[currentRoute] / Math.Max(1, totalRatio));
IDictionary<Airline, double> airlineScores = new Dictionary<Airline, double>();
foreach (Airline airline in Airlines.GetAllAirlines())
//.........这里部分代码省略.........
示例2: GetFlightConnectionPassengers
//returns the passenger demand for routes with airportdestination as connection point
private static double GetFlightConnectionPassengers(Airport airportCurrent, Airport airportDestination, FleetAirliner airliner, AirlinerClass.ClassType type)
{
double legDistance = MathHelpers.GetDistance(airportCurrent, airportDestination);
double demandOrigin = 0;
double demandDestination = 0;
var routesFromDestination = airliner.Airliner.Airline.Routes.FindAll(r => ((r.Destination2 == airportDestination || r.Destination1 == airportDestination) && (r.Destination1 != airportCurrent && r.Destination2 != airportCurrent)));
var routesToOrigin = airliner.Airliner.Airline.Routes.FindAll(r => ((r.Destination1 == airportCurrent || r.Destination2 == airportCurrent) && (r.Destination2 != airportDestination && r.Destination1 != airportDestination)));
foreach (PassengerRoute route in routesFromDestination)
{
Airport tDest = route.Destination1 == airportDestination ? route.Destination2 : route.Destination1;
double totalDistance = airportCurrent.Profile.Coordinates.convertToGeoCoordinate().GetDistanceTo(tDest.Profile.Coordinates.convertToGeoCoordinate()) / 1000;
int directRoutes = AirportHelpers.GetNumberOfAirportsRoutes(airportCurrent, tDest);
if (route.getDistance() + legDistance < totalDistance * 3 && directRoutes < 2)
{
double demand = (double)airportCurrent.getDestinationPassengersRate(tDest, type);
demandDestination += (demand * 0.25);
}
}
foreach (PassengerRoute route in routesToOrigin)
{
Airport tDest = route.Destination1 == airportCurrent ? route.Destination2 : route.Destination1;
double totalDistance = tDest.Profile.Coordinates.convertToGeoCoordinate().GetDistanceTo(airportDestination.Profile.Coordinates.convertToGeoCoordinate()) / 1000;
int directRoutes = AirportHelpers.GetNumberOfAirportsRoutes(tDest, airportDestination);
if (route.getDistance() + legDistance < totalDistance * 3 && directRoutes < 2)
{
double demand = (double)tDest.getDestinationPassengersRate(airportDestination, type);
demandOrigin += (demand * 0.25);
}
}
//alliances & codesharings
if (airliner.Airliner.Airline.Alliances.Count > 0 || airliner.Airliner.Airline.Codeshares.Count > 0)
{
var allianceRoutesFromDestination = airliner.Airliner.Airline.Alliances.SelectMany(a => a.Members.Where(m => m.Airline != airliner.Airliner.Airline).SelectMany(m => m.Airline.Routes.FindAll(r => ((r.Destination2 == airportDestination || r.Destination1 == airportDestination) && (r.Destination1 != airportCurrent && r.Destination2 != airportCurrent)))));
var allianceRoutesToOrigin = airliner.Airliner.Airline.Alliances.SelectMany(a => a.Members.Where(m => m.Airline != airliner.Airliner.Airline).SelectMany(m => m.Airline.Routes.FindAll(r => ((r.Destination1 == airportCurrent || r.Destination2 == airportCurrent) && (r.Destination2 != airportDestination && r.Destination1 != airportDestination)))));
var codeshares = airliner.Airliner.Airline.Codeshares.Where(a => (a.Airline2 == airliner.Airliner.Airline && a.Type == CodeshareAgreement.CodeshareType.One_Way) || a.Type == CodeshareAgreement.CodeshareType.Both_Ways);
var codesharingRoutesFromDestination = codeshares.Select(a=>a.Airline1 == airliner.Airliner.Airline ? a.Airline2 : a.Airline1).SelectMany(a => a.Routes.FindAll(r => ((r.Destination2 == airportDestination || r.Destination1 == airportDestination) && (r.Destination1 != airportCurrent && r.Destination2 != airportCurrent))));
var codesharingRoutesToOrigin= codeshares.Select(a=>a.Airline1 == airliner.Airliner.Airline ? a.Airline2 : a.Airline1).SelectMany(a => a.Routes.FindAll(r => ((r.Destination1 == airportCurrent || r.Destination2 == airportCurrent) && (r.Destination2 != airportDestination && r.Destination1 != airportDestination))));
allianceRoutesFromDestination = allianceRoutesFromDestination.Union(codesharingRoutesFromDestination);
allianceRoutesToOrigin = allianceRoutesToOrigin.Union(codesharingRoutesToOrigin);
foreach (PassengerRoute route in allianceRoutesFromDestination)
{
Airport tDest = route.Destination1 == airportDestination ? route.Destination2 : route.Destination1;
double totalDistance = airportCurrent.Profile.Coordinates.convertToGeoCoordinate().GetDistanceTo(tDest.Profile.Coordinates.convertToGeoCoordinate()) / 1000;
int directRoutes = AirportHelpers.GetNumberOfAirportsRoutes(airportCurrent, tDest);
if (route.getDistance() + legDistance < totalDistance * 3 && directRoutes < 2)
{
double demand = (double)airportCurrent.getDestinationPassengersRate(tDest, type);
demandDestination += demand;
}
}
foreach (PassengerRoute route in allianceRoutesToOrigin)
{
Airport tDest = route.Destination1 == airportCurrent ? route.Destination2 : route.Destination1;
double totalDistance = tDest.Profile.Coordinates.convertToGeoCoordinate().GetDistanceTo(airportDestination.Profile.Coordinates.convertToGeoCoordinate()) / 1000;
int directRoutes = AirportHelpers.GetNumberOfAirportsRoutes(tDest, airportDestination);
if (route.getDistance() + legDistance < totalDistance * 3 && directRoutes < 2)
{
double demand = (double)tDest.getDestinationPassengersRate(airportDestination, type);
demandOrigin += demand;
}
}
}
return demandOrigin + demandDestination;
}
示例3: GetFlightConnectionPassengers
//returns the passenger demand for routes with airportdestination as connection point
private static double GetFlightConnectionPassengers(Airport airportCurrent, Airport airportDestination, FleetAirliner airliner, AirlinerClass.ClassType type)
{
double legDistance = MathHelpers.GetDistance(airportCurrent, airportDestination);
double demandOrigin = 0;
double demandDestination = 0;
var routesFromDestination = airliner.Airliner.Airline.Routes.FindAll(r => ((r.Destination2 == airportDestination || r.Destination1 == airportDestination) && (r.Destination1 != airportCurrent && r.Destination2 != airportCurrent)));
var routesToOrigin = airliner.Airliner.Airline.Routes.FindAll(r => ((r.Destination1 == airportCurrent || r.Destination2 == airportCurrent) && (r.Destination2 != airportDestination && r.Destination1 != airportDestination)));
foreach (PassengerRoute route in routesFromDestination)
{
Airport tDest = route.Destination1 == airportDestination ? route.Destination2 : route.Destination1;
double totalDistance = MathHelpers.GetDistance(airportCurrent, tDest);
int directRoutes = AirportHelpers.GetNumberOfAirportsRoutes(airportCurrent, tDest);
if (route.getDistance() + legDistance < totalDistance * 3 && directRoutes < 2)
{
double demand = (double)airportCurrent.getDestinationPassengersRate(tDest, type);
demandDestination += (demand * 0.25);
}
}
foreach (PassengerRoute route in routesToOrigin)
{
Airport tDest = route.Destination1 == airportCurrent ? route.Destination2 : route.Destination1;
double totalDistance = MathHelpers.GetDistance(tDest, airportDestination);
int directRoutes = AirportHelpers.GetNumberOfAirportsRoutes(tDest, airportDestination);
if (route.getDistance() + legDistance < totalDistance * 3 && directRoutes < 2)
{
double demand = (double)tDest.getDestinationPassengersRate(airportDestination, type);
demandOrigin += (demand * 0.25);
}
}
//alliances
if (airliner.Airliner.Airline.Alliances.Count > 0)
{
var allianceRoutesFromDestination = airliner.Airliner.Airline.Alliances.SelectMany(a => a.Members.Where(m => m.Airline != airliner.Airliner.Airline).SelectMany(m => m.Airline.Routes.FindAll(r => ((r.Destination2 == airportDestination || r.Destination1 == airportDestination) && (r.Destination1 != airportCurrent && r.Destination2 != airportCurrent)))));
var allianceRoutesToOrigin = airliner.Airliner.Airline.Alliances.SelectMany(a => a.Members.Where(m => m.Airline != airliner.Airliner.Airline).SelectMany(m => m.Airline.Routes.FindAll(r => ((r.Destination1 == airportCurrent || r.Destination2 == airportCurrent) && (r.Destination2 != airportDestination && r.Destination1 != airportDestination)))));
foreach (PassengerRoute route in allianceRoutesFromDestination)
{
Airport tDest = route.Destination1 == airportDestination ? route.Destination2 : route.Destination1;
double totalDistance = MathHelpers.GetDistance(airportCurrent, tDest);
int directRoutes = AirportHelpers.GetNumberOfAirportsRoutes(airportCurrent, tDest);
if (route.getDistance() + legDistance < totalDistance * 3 && directRoutes < 2)
{
double demand = (double)airportCurrent.getDestinationPassengersRate(tDest, type);
demandDestination += demand;
}
}
foreach (PassengerRoute route in allianceRoutesToOrigin)
{
Airport tDest = route.Destination1 == airportCurrent ? route.Destination2 : route.Destination1;
double totalDistance = MathHelpers.GetDistance(tDest, airportDestination);
int directRoutes = AirportHelpers.GetNumberOfAirportsRoutes(tDest, airportDestination);
if (route.getDistance() + legDistance < totalDistance * 3 && directRoutes < 2)
{
double demand = (double)tDest.getDestinationPassengersRate(airportDestination, type);
demandOrigin += demand;
}
}
}
return demandOrigin + demandDestination;
}