Welcome to the Forum for The Airline Project

Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Demand Calculation
do you mean by need the amount of offered seats per day?

How does this work if I have 1 flight per week? does the demand from the other days flow into this one flight? (as it should be)
I feel like, to solve this we need to threat demand as weekly, and compare it to weekly flights, no? (even though my demand figures are daily, so just *7)

How does the pricing influence the filling degree? I was the only airline with the route and I increased the price from 20 to 2500 and the filling degree only dropped 10% (the filling degree didn't start as 100%,but something like 90%->80%, I feel like it should drop to zero% at that price Big Grin )

How do passengers prefer flights at their convinient departure time? (Post #37)
How does frequency affect filling degree/airline choice? (Post #79
I'm assuming those are calculated in score? Can I see the code behind score as well? Smile (I'm actually thinking about implementing part of connecting flights into the score part, where the longer flight times drop the score a little, however not enough to justify super sonic flight costs ^^)

Are different classes filling degrees calculated independently?



And then let's go over the code line by line Big Grin


[line 3]The very first thing, you see which is smallest: the demand or the capacity on the route (yours + the opponents'?)
But for the price, do we compare somewhere the demand vs given capacity?

[line 5] I don't understand this line.. Shy

[line 7] dailyRoutes checks how many routes you have per day (should this be per week?) (so the amount of destinations you have?)

[line 9] dailyFlights, I don't really understand. I assume it checks the amount of flights you have per day (should this be per week?) (is this on said route or all routes?) (what does it use dailyRoutes for?)

[line 11] checks the demand for each class?

[line 5, new insight] does this line return all flights from airport 1 & 2, to count them in [line 7]?

[line 13] returns the demand per passengertype? where is this used in this peace of code?

[line 15] Welp, I'm stuck again. Is daily need the capacity on the route (player + AI?) If so, why is it split into smaller than and bigger than?

[line 17] returns the score compared to the price? Is it per class, or all together?

[line 19] checks whether the price/score is greater than 0.8. What does rnd.Next do? what does minPassengers do/mean?

[line 21] this returns the amount of passengers that would want to fly, regardless of capacity

[line 23] returns the amount of passengers that would want to fly, using the capacity. then proceeds to return something using minpassengers

[line 25 & 26] returns the amount of tourists/business passengers. What does eclass mean/do? can I see the code? Smile Do the passengertypes have different preferences at the moment? (business more likely to prefer service, tourist more likely to prefer cheap flight)

[line 28] What is this? Big Grin



Now daily need is smaller than demand.

Can you give a short explanation why this is calculated differently?
So I'm still assuming this has to do with there being more demand than capacity.



At first sight it's possible that there are some features missing, but those features might very well be behind the score-code. Blush
Thank you very much for taking the time! Smile
Reply
Short question. Does the transfer time also affect the demand for the connecting flight?

Frankfurt is a hub for example. Pax travel from Hamburg to Chicago via Frankfurt

1. Departure HAM 06:20 - Arrival FRA 07:30 ---- (3 hours waiting time)
2. Departure HAM 07:30 - Arrival FRA 08:40 ---- (2 hours waiting time)
3. Departure HAM 08:20 - Arrival FRA 09:30 ---- (1 hour waiting time)

Connecting Flight : Departure FRA 10:45 to ORD (Chicago)

How long do you want to wait for the connecting flight? Is the distance crucial?

Angel
Reply
Yes, I have this included in my calculation. Smile

In the future we will have different minimum times between connecting flights depending on what pier/terminal the other flight is in. Is it in the same security zone and stuff like that. Big Grin

How long a passenger wants to wait depends on other possibilities. How long does the direct flight take? How much less does this connecting flight cost?

Also, I feel like you should be able to lengthen the time a passenger wants to wait. Like a lounge makes it a bit longer, a cooperation with a hotel a hole lot more. Smile
Reply
Nice to read that news.

What if when a second flight comes to it to feed the connecting flight from Frankfurt to Chicago at 10:45?  Big Grin

For example a flight from München (MUC) with arrival at 09:00 or 10:00 at Frankfurt to reach the flight to Chicago.

When both flights are connecting flights (from Hamburg and Munich) to Chicago, how is this considered?

10% from Hamburg only and 20% from Munich? Or equal?
Reply
[line 3]The very first thing, you see which is smallest: the demand or the capacity on the route (yours + the opponents'?)
But for the price, do we compare somewhere the demand vs given capacity?
The demand is the daily demand between the airports and the capacity is the maximum seats on the aircraft

[line 5] I don't understand this line.. Shy
It finds all the routes for all airlines between the two airports

[line 7] dailyRoutes checks how many routes you have per day (should this be per week?) (so the amount of destinations you have?)
Correct :-)

[line 9] dailyFlights, I don't really understand. I assume it checks the amount of flights you have per day (should this be per week?) (is this on said route or all routes?) (what does it use dailyRoutes for?)
It takes the sum of flights for the specific day

[line 11] checks the demand for each class?
It gets the total number of passengers for the class throughout all the flights operating this flight

[line 5, new insight] does this line return all flights from airport 1 & 2, to count them in [line 7]?
Correct

[line 13] returns the demand per passengertype? where is this used in this peace of code?
This was a part of the original Excel sheet you send (and I really can't find it right now :-))

[line 15] Welp, I'm stuck again. Is daily need the capacity on the route (player + AI?) If so, why is it split into smaller than and bigger than?
My thought was that if the need is higher than the demand then we would have to compare all the prices for the flights operating the route to get which flights should get the most demand. If not there is enough demand for all flights so there we just compare the single flight to the "score"

[line 17] returns the score compared to the price? Is it per class, or all together?
It is based on the single class where it is a mix of the price against the base price together with the reputation of the airline

[line 19] checks whether the price/score is greater than 0.8. What does rnd.Next do? what does minPassengers do/mean?
If the score is lower than 0.8 the minimum of passengers of that flight is 0 and if higher than 0.8 it is a random number between 0 and 5.

[line 21] this returns the amount of passengers that would want to fly, regardless of capacity
This is the number of passengers who can be on the flight. Capacity (on the specific class for the specific class) * score (between 0 and 1) * a random number between 0.9 and 1

[line 23] returns the amount of passengers that would want to fly, using the capacity. then proceeds to return something using minpassengers
Gets the actually number of pax on the flight for the class.

[line 25 & 26] returns the amount of tourists/business passengers. What does eclass mean/do? can I see the code? Smile Do the passengertypes have different preferences at the moment? (business more likely to prefer service, tourist more likely to prefer cheap flight)
The factors are:
Dictionary<ClassTypeEnum, KeyValuePair<double, double>> factors = new Dictionary<ClassTypeEnum, KeyValuePair<double, double>>();
factors.Add(ClassTypeEnum.Economy_Class, new KeyValuePair<double, double>(0.12, 0.88));
factors.Add(ClassTypeEnum.Premium_Economy_Class, new KeyValuePair<double, double>(0.25, 0.75));
factors.Add(ClassTypeEnum.Business_Class, new KeyValuePair<double, double>(0.98, 0.02));
factors.Add(ClassTypeEnum.First_Class, new KeyValuePair<double, double>(1, 0));
I think you have provided those values

It is used to say ex. how many tourist passengers are using first class. It should be read as Economy Class: 12% is business passengers and 88% is tourist and for Business Class it is 98% business passengers and 12% tourists

[line 28] What is this? Big Grin
It returns the number of Business passengers and tourist passengers on the specific class

And thank you very much for helping optimizing this :-) And as usual please just let me know what to change :-)
Reply
In the system I'm writing it depends on how many passengers want to fly MUC-ORD and HAM-ORD.

I'm still finetuning it, since we don't want MUC->ORD + HAM->ORD + FRA->ORD all on the FRA->ORD flight :p
That would easily break the demand system.

I'm not so sure how we're going to do this yet. I first have to understand how the filling degree works for O&D flights. Smile



@Pjank, can you share the code behind 'score' and 'PriceScore' as well?
I feel like those are essential in the code you shared. ^^


edit: This is going to take longer than I thought.
I'll write it all out after my exams. Smile

I'll prioritize the filling degree and connecting flight over countries, so the countries might be for the next release (2.14).
I'll make some adjustments to the roadmap. Smile
Reply
Please take your time :-)

Code:
       private static double GetRoutePriceScore(Route route, ClassTypeEnum eclass,PoolFlight flight)
       {
           double reputationFactor = (route.Airline.Reputation.Overall / 1000);

           if (reputationFactor > 50)
               reputationFactor = 1 + ((reputationFactor - 50) / 100);
           else
               reputationFactor = 1 - ((50 - reputationFactor) / 100);

           var basePrice = RouteHelpers.GetStandardPassengerPrice(route.Airport1, route.Airport2, eclass, route.Airline);
           int price;

           if (route is PassengerRoute)
           {
               if (flight==null)
                   price = ((PassengerRoute)route).Classes.First(c => c.Type == eclass).Price;
               else
               {
                   var tteClass = RouteHelpers.GetTimeTableEntryClassFromFlight(flight, eclass);

                   price = tteClass == null ? ((PassengerRoute)route).Classes.First(c => c.Type == eclass).Price : (int)tteClass.Price;

               }
           }
           else if (route is StopOverRoute)
           {
               if (flight == null)
                   price = ((StopOverRoute)route).Leg1.Classes.First(c => c.Type == eclass).Price;
               else
               {
                   var tteClass = RouteHelpers.GetTimeTableEntryClassFromFlight(flight, eclass);

                   if (((StopOverRoute)route).TypeOfStop == StopOverRoute.StopType.Full)
                   {
                       var leg = flight.DepartureAirport == ((StopOverRoute)route).Leg1.Airport1 || flight.Destination == ((StopOverRoute)route).Leg1.Airport1 ? ((StopOverRoute)route).Leg1 : ((StopOverRoute)route).Leg2;

                       price = tteClass == null ? leg.Classes.First(c => c.Type == eclass).Price : (int)tteClass.Price;
                   }
                   else
                   {
                       price = tteClass == null ? ((StopOverRoute)route).Leg1.Classes.First(c => c.Type == eclass).Price : (int)tteClass.Price;
                   }
               }
           }
           else
           {
               if (flight == null)
                   price = ((MixedRoute)route).Classes.First(c => c.Type == eclass).Price;
               else
               {
                   var tteClass = RouteHelpers.GetTimeTableEntryClassFromFlight(flight,eclass);

                   price = tteClass == null ? ((MixedRoute)route).Classes.First(c => c.Type == eclass).Price : (int)tteClass.Price;

               }
           }

           var diff = Convert.ToDouble(basePrice) / Convert.ToDouble(price) * reputationFactor;

           return diff;
       }
That is the only score we are using in the code for the load
Reply
[line 17] the score of a single class defines the filling degree of all classes? I think I misunderstand something. Big Grin
Does it start over the code for each class? or do you have different files for each class?
[The calculation is done for each class]

[line 19] what's the philosophy behind this? why do we have a random number if the score is higher than 0.8? Smile
What do you do with the number?
[So it isn't  a 100% static value :-)]

[line 21 & 23] what's the difference?
[That could be cleaned up since you are right that we have no need for both lines]

[line 25 & 26]
Quote:The factors are:
Dictionary<ClassTypeEnum, KeyValuePair<double, double>> factors = new Dictionary<ClassTypeEnum, KeyValuePair<double, double>>();
factors.Add(ClassTypeEnum.Economy_Class, new KeyValuePair<double, double>(0.12, 0.88));
factors.Add(ClassTypeEnum.Premium_Economy_Class, new KeyValuePair<double, double>(0.25, 0.75));
factors.Add(ClassTypeEnum.Business_Class, new KeyValuePair<double, double>(0.98, 0.02));
factors.Add(ClassTypeEnum.First_Class, new KeyValuePair<double, double>(1, 0));
I think you have provided those values

Are thos these values you implemented or something else?: [That should be the values, and I think the first example you sent contained those values]
[Image: yZBSosk.png]

What do those 0.12, 0.88 do then?



I think I'm starting to see where this goes, and how I'd improve it.
But I'm not sure whether my version would be as resource friendly..  Undecided


edit:

the score calculation

uhm, this is only the part where we calculate the actual score? (duh, is what I asked for isn't it? :p )
[It is :-)]
Can I have a look at where the in flight services and departure/arrival time have an influence on the score?
[As I wrote earlier then at the moment that isn't implemented, since you wanted to provide "something". I guess it was a couple of months ago we talked about that :-)]
And how the baseprice is calculated?
Code:
{
           int factor = 1;

           if (type == ClassTypeEnum.Business_Class)
               factor = 3;
           if (type == ClassTypeEnum.Premium_Economy_Class)
               factor = 2;
           if (type == ClassTypeEnum.First_Class)
               factor = 6;

           var model = airline.Profile.Model;

           int year = GameTimeObject.GetInstance().GameTime.Year;

           if (model == AirlineProfile.BusinessModel.FSNC)
           {
               double dist = MathHelpers.GetDistance(airport1, airport2);

               double ticketPrice = dist * MathHelpers.GetInflationPrice(0.0084, year);

               double minimumTicketPrice = MathHelpers.GetInflationPrice(18, year);

               if (ticketPrice < minimumTicketPrice)
               {
                   ticketPrice = minimumTicketPrice + (ticketPrice / 4);
               }

               return (int)ticketPrice * factor;
           }
           if (model == AirlineProfile.BusinessModel.LCC)
           {
               double dist = MathHelpers.GetDistance(airport1, airport2);

               double ticketPrice = dist * MathHelpers.GetInflationPrice(0.0077, year);

               double minimumTicketPrice = MathHelpers.GetInflationPrice(16.75);

               if (ticketPrice < minimumTicketPrice)
               {
                   ticketPrice = minimumTicketPrice + (ticketPrice / 4);
               }

               return (int)ticketPrice * factor;
           }


What's behind the RouteHelpers and tteClass?
[It is just a way to find the correct class type on the specific flight]
Reply
I have added some comments to your questions :-) And let us see if it is possible to optimize your version when you send it :-)
Reply
I have an updated version for the pax types for the new release.

Download

I noticed you have included this file twice:
once under data/airports named europe.xml (with europe (2).xml being the airports itself), and once under data/airports/demandfactors.

I think the one under demandfactors is the one actually used in the game. Smile


Good luck with the process and the release, have a nice holiday and see you in a couple of weeks. Smile
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)