The International Simutrans Forum

Community => Simutrans Gaming Discussion => Topic started by: aran on August 12, 2022, 09:45:56 AM

Title: Detailed explanation of passenger routing mechanics?
Post by: aran on August 12, 2022, 09:45:56 AM
I feel like I'm getting a better handle on how passenger transport works (I used to ignore that game aspect for years, because freight was much easier to understand), but I'm still occasionally confused by the mechanics.

One example: Between cities A and B lies a factory with workers in both towns. I set up two shuttle buses, one from each city. Next thing I know, the buses and the tiny bus stop are massively overcrowded by inter-city passengers; meanwhile the high-speed train between those cities is half empty.

A workaround for this was making separate bus stops at the factory, to avoid creating a connection. But I'm still wondering why the passengers picked this route. Is it random? Do they prefer fewer stops, less overall distance traveled, or less expense?

I'm also wondering how passengers pick their destinations in the first place, and if there's some way for me to see where the "no route" passengers wanted to go. I'm not sure if they randomly pick another passenger-generating building anywhere on the map, or only factories/tourist destinations/existing stations?

Is there a more detailed explanation of how this works?
Title: Re: Detailed explanation of passenger routing mechanics?
Post by: jimishol on August 13, 2022, 05:02:16 PM
I share your concerns. I can not tell you for sure what might be wrong. The game have included so many ideas and tries, to simulate reality, that anyone could pick a different reason for that behavior.  Considering that randomness is used as a panacea to give life to any idea, the causality of any phenomenon may remain well hidden from any attempts to reveal it. Probably I am newer player than you are, however, I am tempted to share what I understood so far from forum readings. I am not a mathematician nor a programmer. In this respect I am 'nobody' but I dare to share my thoughts in the hope that somebody, as specialist, will correct me.

The motto on playing, is generally "make natural decisions". Your fault seems to be that you overestimated that motto and forgot that it is actually a game. You think as if routes, that passengers take, are random. If they are random why half of them not to be by your fast train and half through industry. Not to think that faster train should be preferred in that randomness.
Well take N nodes and connect them with every possible way. These count as N*(N-1)/2 ways, that with large N approximates to N^2/2 (or just N^2 if we consider every direction of a route different things). If picking routes were random one should choose  some route among those. But picking routes is not a random process in game. They are chosen by a deterministic process. Give me a random number and I will report the double of it. Your number is random but the report of its double is deterministic. N^2 of possible routes might make the game unnecessary slow and unplayable without good reason. Divide nodes on mostly origins and a small portion "a" of destinations (as industries or attractions) and routes to choose among them will count as "a*N^2". A  smaller number than N^2. So,
the game does not randomize routes. It randomize destinations. Citizens are antisocial. They do not visit each other. I personally believe they do exist either. They are just numbers, as your credits in your bank. These numbers determines what can happen or not, but it is very difficult to actually see their implementation as a whole.
Every building is an origin and every attraction or industry is a possible destination. Game chooses random destinations. Determined in configuration, a small portion of them are industries. Once a destination is picked, what will be the route, is not random. It is chosen in a deterministic manner, as I would chose the double of your random number. That deterministic route is checked for if it is in duration tolerance, comfort, price etc If it is not, then the game does few more attempts, the number of them is determined in configuration too, trying again the random choice of destination. If none of the attempts find a destination connected by existed network and in duration tolerance, comfort, price etc then it announce that no route has found. Many players and developers of paksets, in attempts to control the behavior of the alleged passengers, are fun to play with the above parameters of tolerance, comport etc or invent new ones. By hardening those parameters they make difficult for the game to find acceptable routes. So, an increase on the number of attempts, to find acceptable routes too, is a necessity. This way they keep the number of generated trips and restrict the randomness of the accepted destinations, or the variance of its distribution if you like, and settle in what could be a golden mean. The process of finding routes, I believe, is done every 24 hours. That means every 24/6.4= 3.75 months. (A day is larger than a month, yes?). If you see 10 workers to arrive in your industry, in next generation of routes they will pick 10 random destinations to depart. They have no home to return back. I can hardly believe that the game keeps track of origins of passengers or workers. That is why I said they might not even exist. And there is no real need to exist either. If in each region or section of the map the ratio between origins and destinations, that is the ratio of buildings, industries and attraction between them, remains the same, then it is mathematically expected that for every average ratio of trips from A to B will correspond an equal average ratio of trips from B to A. That effectively gives the false impression of returning.
Back to your case. We do not know the origins and destinations of your passengers but the fact is that there exist passengers that travel from your city A to your city B. I consider they want to travel from a main Stop from city A to a main Stop to city B. I suspect there exist a route by your light speed fast train. That means main StopA - train platformA – train platform B – main Stop B. I suspect also that there exist a second route between cities. Main Stop A – Industry -  main Stop B. Your train travels in light speed so the trip from main Stop A to main Stop B lasts few seconds. 2nd route uses buses so the trip through industry last some hours. The problem is that both trips are in the accepted game tolerance, comfort, price etc. and can equally be taken. If the choise of route was random, half would take train, half would take buses. But, the choice of route is deterministic. Whoever wants to go from main stop A to main Stop B, will pick the route with less stops between them. In my suggestion the train route uses 4 stops. The through industry route uses 3 stops. So,  whoever wants to go from main stop A to main Stop B will always use buses. No passenger disembarking at the main Stop B had ever used main Stop A. If that is the case, build two unnecessary stops between industry and cities. Thus stops by buses will become 5 that is greater than the number 3 of the trip stops through train and train will be preferred.

In order to understand what happens generally with pax trips, ignore the industries as they participate in similar matter, and lets focus on buildings (origins) and attractions (destinations). Imagine a map with two large, separated and same in every aspect main continents. Imagine and a small separated continent as a small ratio "r" of the map. Large continents have "b" buildings and "a" attractions. Small continent would have "2*r/(1-r)*b" buildings and "2*r/(1-r)*a" attractions. All attractions on the map are "2*a+ 2*r/(1-r)*a". Assume you developed full network, where every possible route from origins to destinations exist. So, from a large continent will be created "b" trips. The portion of attraction that exist in this area will determine how many of these trips will be in the same continent. That is "(1-r)/2" portion of "b" trips will be in same continent. The same portion of trips will be toward the other big continent as it was assumed equal to first one. The portion of trips towards the small continent will be "r", that is that the trips from any of large continents to the small one will be "r*b". If you do the maths, "r*b" will be also the trips from small continent toward any of the large ones. The trips inside the small continent will be "2*r^2/(1-r)*b". Since only destinations are random choices, it is wrong, when we consider randomness, to include routes in our thinking. All we did was to compare the ration of attractions in a continent against the total number of them.
If all continents were covered by our network, all the trips would be "2*b/(1-r)". Let assume we do not care and not include the small continent in our network.  In this case the trips will be "2*b*(1-r)". We see that if our small continent was "r=10%" of the map, then we would get the "(1-r)^2=) 81% of the maximum trips. Its up to the player to decide at what extend he will develop his network. Generally, a brave extension might be need. Pax transportation is not expected to work efficiently when it is developed only locally. When I do, I try to connect major cities, as high density areas, to large attractions and major cities between them, so as to catch large portion of the possible randomly picked destinations.

This is what I irresponsibly wanted to share until you receive a responsible response to your appeal for help.
Do not forget to search forum as much as you can. There are lot of unexpectedly useful discussions and informations.
Happy passenger networks.
Title: Re: Detailed explanation of passenger routing mechanics?
Post by: Combuijs on August 14, 2022, 03:52:30 PM
I don't know if you are playing Simutrans (standard) or Simutrans extended. That makes a big difference where passengers are concerned.
Title: Re: Detailed explanation of passenger routing mechanics?
Post by: jimishol on August 14, 2022, 07:45:47 PM
I play Simutrans extended because i like its goals and i consider it more of a challenge. I wrote what i understood from forum readings and from comments in simuconf.tab. In standard and extended or even in pakset, the generated trips might be longer or shorter but i believe that the basic algorithm of random destination choice and the subsequent acceptance or rejection of it, using the same game engine, should be the same.
Title: Re: Detailed explanation of passenger routing mechanics?
Post by: Combuijs on August 15, 2022, 01:36:09 PM
Random destination choice surely is the same. In standard Simutrans acceptance is easier than in extended: as long as there is a route the voyage is accepted. I don't know about routing in Extended but in Standard the number of transfers is key when choosing a route: the less transfers the better. When the target of the first transfer is known (ideally this is the final destination), then the first available way of transport that leads directly to that target is taken.
Title: Re: Detailed explanation of passenger routing mechanics?
Post by: prissi on August 15, 2022, 08:57:20 PM
At least in Standard, house are origin and destinations. Factories and attarctions only generate return passengers, if a passenger wants to go there (no matter of he succeded).
Title: Re: Detailed explanation of passenger routing mechanics?
Post by: jimishol on August 16, 2022, 07:36:42 PM
As simutrans extended player i have to note that reading of Overview of Simutrans-Extended features (https://forum.simutrans.com/index.php/topic,1959.msg20214.html#msg20214) is a must. Though i still miss information i would like to know about time tolerance.

* What is the descriptive value of skew in random_mode_visiting = 6?
Even if i accept the skewness of the normal distribution, as the last varies from minus infinity to positive infinity, and accept as accepted values only those from
min_visiting_tolerance = 12
range_visiting_tolerance = 12000
I cannot guess the final skewed distribution. Let assume as mean the 6000minutes and guess the skewed average to 3840 minutes or 64hours. It seems too large for normal tolerance of a trip to last 10 game months.
* What are the above minutes?
I connected two cities that are 14.5km away. Things looked normal. I connected a third city another 14.5 km away. The end edges of the 3 cities chain showed a lot "too long to travel" passengers. The 3nd city is too away from the 1st one. That means that time tolerance should be about 3/2*14.5km away that with 10km/h could be crossed in about 2 hours. I can not find it now but in some wiki i had read that, in extended, duration tolerance is 90 minutes. That make sense compared to my cities.
* What exactly is visiting trips in the chart of a stop? I ask because by passenger line is designed to carry 40pax/month and even if my convoys carry less i was almost sure that it was much more than 16passengers per month. Do "visiting trips" exclude commuters and/or something else? 
Title: Re: Detailed explanation of passenger routing mechanics?
Post by: Spenk009 on August 24, 2022, 08:11:30 AM
A ten game month journey is possible in the era of sailing boats and horse carriages, because ten game months are ten consecutive days. Many games do exactly this too, because their time progresses quicker than real-life speed animations.

Visiting trips are leisure trips iirc.