The International Simutrans Forum

 

Author Topic: Pull Request: Private Car Routing Adjustment  (Read 460 times)

0 Members and 1 Guest are viewing this topic.

Offline PJMack

  • *
  • Posts: 6
Pull Request: Private Car Routing Adjustment
« on: April 30, 2021, 12:49:24 AM »
This pull request, already on GitHub (https://github.com/jamespetts/simutrans-extended/pull/374), adjusts the car routing to give preference to one way roads, and avoid cities, crossing, and intersections.  This would hypothetically reduce private car driving calculations by steering private cars away from situations where more calculations are needed, however there would be a slight increase in private car routing calculations, which do not need to be done in real-time. The positive side effects of this is the reduction of in-city congestion, as well as encouraging the placement of "ring-roads" or "beltways" around cities.

Offline Freahk

  • Devotee
  • *
  • Posts: 1470
  • Languages: DE, EN
Re: Pull Request: Private Car Routing Adjustment
« Reply #1 on: April 30, 2021, 10:32:39 AM »
First, I'd like to welcome you to Simutrans (extended)

Improving this situation had been considered but coding ressoources in simutrans are quite limited, thus any work on this is appreciated.
Your approach seems quite simple and I like the idea of attracting more cars to use two-lane roads and to get cars out of town as we all know towns are usually rather congested due to many cars moving around in heuristics mode and two-lane roads can carry more cars in the same time than normal roads can do.

However, I see a big issue in here: The journey time of cars is quite important to decide if a passenger will take the car or public transport, so we should never advert a speed that in practice cannot be reached!
Otherwise, this false promise will move even more passengers on the road causing even more jams although the road capacities might be used more optimally.

So my personal conclusion:
I like the idea of a (simple) road capacity estimation, but we have to ensure that we never promise speeds that cannot be reached, not even in theory.

One solution might be to split route costs from journey times, where costs are used to calculate the "best" (not anymore the fastest) route and the (expected) journey time of that calculated route is then used to decide if a passenger will go by car or public transport.
The same might be used to at least reduce the flip-flop effect of congested roads by considering congestion only by a small factor when calculating routes, but using the full recored congestion when calculating the expected journey times.
Both are just estimations, so we'll have to test in practice if this works well or not.
« Last Edit: April 30, 2021, 01:11:18 PM by Freahk »

Offline PJMack

  • *
  • Posts: 6
Re: Pull Request: Private Car Routing Adjustment
« Reply #2 on: May 01, 2021, 01:05:22 AM »
Thank You.  I did not realize the potential effects on the transit vs private car decision.  Such effect may not be unrealistic as the Eisenhower highway system did have an effect on rail in the United States, however it may not be desirable to have in simutrans-extended.  My original intent was model the (not un-)common overestimate of the speed boost provided by divided highways. 

In the meantime, I did do some benchmarks with a mature single player game with a 1280x1280 map, 45 cities totaling to 1.3 Million inhabitants, timeline year 2003.  After 3 in-game months of with vs without the pull request (loading from the same savegame, which is too large to post), there was a negligible increase (1.99M vs 1.93M) in global private car usage, negligible effect on my largest hub station, but a 30% decrease (42 vs 63) in congestion in the largest central city, as well as a ~20-30% increase in overall performance (based on simloops during fast-forward).

In any case, the constants in the pull request could be adjusted.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20720
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Pull Request: Private Car Routing Adjustment
« Reply #3 on: May 01, 2021, 12:41:42 PM »
Thank you very much for your work on this: this is much appreciated. This will need, I think, some careful thought before it can be integrated. One of the important principles in Simutrans-Extended is that passengers route by journey time. Thus, if there is a situation in which the fastest journey by car is faster than the fastest journey by public transport, players will take the car; whereas, if the fastest journey by public transport is faster, passengers will take public transport (unless they have been randomised always to prefer to travel by car when the journey time is within their tolerance). Likewise, passengers will not travel at all if the journey time is outside their tolerance.

Therefore, any system that does not choose the fastest journey time for private cars risks distorting economics in the game. I note that the overall assessment on a larger map is that private car usage was reduced by circa 4% when implementing this feature; but that might mask very large reductions in some localised areas where a non-time-based routing system might create perverse incentives.

Given that the game mechanics already do encourage the use of ring roads (on the basis that these should be less congested, and therefore the travel time lower, than city roads), it would helpful to have a little more detail on why it is that you think that the current mechanics (a purely time based routing) do not allow for this?

Thank you again for your work on this.

Offline PJMack

  • *
  • Posts: 6
Re: Pull Request: Private Car Routing Adjustment
« Reply #4 on: May 01, 2021, 11:15:08 PM »
My original intent was to decrease traffic in a manner that does not make it too unrealistic.  I noticed that a side effect of the caching of the cost in the private_car_destination_finder_t::get_cost() function, is that intersection congestion was not being taking into account.  The simplest solution to that was to simply add a general speed penalty to intersections.  (Looking at the code again now, it appears that the caching may cause the routing to only takes into account the congestion of the first tile in the city, and it looks like it may use the congestion of the previous city if the entrance is a diagonal?)  Additionally, I wanted to compensate for the speed lost by railroad crossings.  For the other two adjustments, I wanted to model the assumptions that cities tend to be congested, and divided highways fast, even though such assumptions tend to be false, however I may have overdone it with the constants.

At this point, would it be more appropriate to move this into a feature request, rather than a pull request?  Either way, hopefully this helps with the discussion.  Thanks.

Offline freddyhayward

  • Devotee
  • *
  • Posts: 649
  • Languages: EN
Re: Pull Request: Private Car Routing Adjustment
« Reply #5 on: May 02, 2021, 01:59:04 AM »
Are you familiar with the existing congestion system? Though it is certainly flawed, it still accounts for everything you have mentioned here.

Offline Freahk

  • Devotee
  • *
  • Posts: 1470
  • Languages: DE, EN
Re: Pull Request: Private Car Routing Adjustment
« Reply #6 on: May 02, 2021, 08:02:18 AM »
I guess I get the point of the adjustment.

The congestion stats are quite preciese data, but that data is from the past, given a specific private car route network and the route calculation does not take any care of "how many cars a road can hold" before it will be seriously congested.
In different words, the route calculation assumes that changing routes does not have an effect on congestion.
This assumption is fine if there are rather continous recalculations, but it causes the flip-flop effect when recalculations are rather rare and the whole route network is flipped at once.

The above adjustment seems to aim at guessing where it's rather likely to support huge traffic flows and where it's not.
A simple guess might work, but in any case it should not adjust the jorney time expectation in a way that is not at all represented by the infrastructures.

In the very first place, we should attempt to reduce the flip-flop effect by itself, instead of placing guesses on which routes might work best.

« Last Edit: May 02, 2021, 08:12:28 AM by Freahk »

Offline freddyhayward

  • Devotee
  • *
  • Posts: 649
  • Languages: EN
Re: Pull Request: Private Car Routing Adjustment
« Reply #7 on: May 02, 2021, 08:29:13 AM »
What I'm trying to ask is whether the adjustments are made with improving the existing congestion system in mind, or whether it was made without knowing about it at all.

Offline PJMack

  • *
  • Posts: 6
Re: Pull Request: Private Car Routing Adjustment
« Reply #8 on: May 03, 2021, 12:51:54 AM »
Yes, I was aware of the existing route-around-congestion code, and was attempting to supplement it.

To start from the beginning, about a month ago, when I was playing simutrans-extended on a map with some large cities, I found the congestion in the cities made the game nearly unplayable.  I had placed divided beltways (ring-roads) around cities, however, in a cyclic pattern, the beltways would become overcrowded, and traffic would divert to the cities, making traffic even worst.  I had also noticed that given equal choice in route between a crossing and a bridge over it, the cars were choosing the crossing.  At that point I started looking at the existing code (starting with the diff for the private_car_memory_saving pull request, good job by the way) and noticed that, as Freahk noted, it only takes into account the traffic of the previous month, and due to the caching of the get_cost function, did not appear to me to be handling intersections properly.  About three weeks ago, I added code into the get_cost function to increase the cost of crossings and cities, and reduce the cost of freeways.  (It was upon implementing the latter that I realized that I could speed up ribi_t a bit, hence the other pull request) About a week ago, I had considered making this a feature request with an attached patch file, however I had, at that point already planned the other pull request while I still had some free time; and the code was already tested.

One option I did consider, but thought may decrease routing performance too much, was to have the city avoidance be based on the congestion, population, and/or area of the city in question.  Another would be having the constants set-able in the simuconf.tab file, but again, may cause a larger impact on routing performance.