The International Simutrans Forum

 

Author Topic: Changes to distribution of goods from factory to stations  (Read 3091 times)

0 Members and 1 Guest are viewing this topic.

Offline Fifty

  • *
  • Posts: 280
  • Languages: EN, ES
Changes to distribution of goods from factory to stations
« on: November 25, 2012, 04:16:48 PM »
I have two suggestions in order to improve routing in Simutrans. I know these may be rather complex, but they would help gameplay quite a bit.

The first, mentioned here, relates to multiplayer networks. Factories will give their entire output to whatever station has the largest capacity, and not produce for other players serving the factory until the largest station is overcrowded. This leads to players putting huge numbers of station extension buildings everywhere. There seem to be some occasional exceptions to this, but I don't really know why they occur. I would suggest splitting cargo evenly, or, even better, choosing the better route based on transfers/distance if two players offer service to the same destination.

The second has to do with what the "better route" is. Currently, passengers and freight will first look for the route with the smallest number of transfers, and then if two routes have the same number of transfers, for the route with the shortest first leg. This makes non-circular passenger rail lines work rather poorly, as oftentimes passengers will choose a different route to their destination than they do home. Thus trains lines will be more heavily loaded in one direction than the other. I would suggest that if two routes have the same number of transfers, that pax/goods will take the one with a shorter total distance, and thus the same route in both directions.


Edit: changed post title to change thread title -- dwachs
« Last Edit: November 25, 2012, 07:23:32 PM by Dwachs »

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4564
  • Languages: EN, DE, AT
Re: Changes to Routing
« Reply #1 on: November 25, 2012, 04:49:51 PM »
The first, mentioned here, relates to multiplayer networks. Factories will give their entire output to whatever station has the largest capacity, and not produce for other players serving the factory until the largest station is overcrowded. This leads to players putting huge numbers of station extension buildings everywhere. There seem to be some occasional exceptions to this, but I don't really know why they occur. I would suggest splitting cargo evenly, or, even better, choosing the better route based on transfers/distance if two players offer service to the same destination.
I see your point, imho the distribution of goods to factories could be reworked.

If transfers are taken into account, then direct connections will win. Every player will build direct connections. Now, how to distribute between two networks?

Imho, somehow quality of service should be taken into account: that is, how many goods can be delivered by a player's network per time. I do not know, how to implement such a thing.

Quote
The second has to do with what the "better route" is. ... I would suggest that if two routes have the same number of transfers, that pax/goods will take the one with a shorter total distance, and thus the same route in both directions.
What do you mean by total distance?

Routing is now based on two facts:  Routes are chosen to have as less transfers as possible, while counting in-between halts.

Offline Fifty

  • *
  • Posts: 280
  • Languages: EN, ES
Re: Changes to Routing
« Reply #2 on: November 25, 2012, 05:48:03 PM »
Imho, somehow quality of service should be taken into account: that is, how many goods can be delivered by a player's network per time. I do not know, how to implement such a thing.

Perhaps goods could be sent by a ratio based on how many units per month of transport capacity serves that station? Of course that would not work for new stations, however.

Quote
What do you mean by total distance?

Routing is now based on two facts:  Routes are chosen to have as less transfers as possible, while counting in-between halts.

It seems I'm confused about how routing works. Let's use a basic example: You have 2 tracks from A to E, one running A-C-E and the other A-B-D-E. A-B is shorter than A-C, E-C is shorter than E-B.

  /-B---D-\
A<          >E
  \-----C-/


Let's say that trains don't stop at D. How would passengers get from B to C? Would they take the same route back from C to B? Now what if trains do stop at D, how would pax get from B to C and back? How would pax get from A-E? would it matter if one route was shorter (fewer tiles)?

My biggest concern is that pax often do not take the same route to their destination as they do back, so it is difficult to balance flows with some setups.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5454
  • Languages: EN, NO
Re: Changes to Routing
« Reply #3 on: November 25, 2012, 05:53:55 PM »
My solution to the uneven flow problem is to avoid loops of even number of lines, but it becomes difficult once the network becomes complex.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18493
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Changes to Routing
« Reply #4 on: November 25, 2012, 05:58:22 PM »
The first suggestion was implemented by Knightly into Experimental a long time ago; and Experimental already has time based routing to deal with the second issue.

Offline sdog

  • Devotee
  • *
  • Posts: 2039
Re: Changes to Routing
« Reply #5 on: November 25, 2012, 06:04:08 PM »
Imho, somehow quality of service should be taken into account: that is, how many goods can be delivered by a player's network per time. I do not know, how to implement such a thing.

One way would be to check the global rating of a player, compare goods transportet last 3 months and compare it with the total amount of goods at stations of the last three months. In a real setting a customer would also only have an idea of the overal reputation of a company.

It would have the nice sideffect that players need to create efficient networks before expanding, else the competitors will get a larger share of goods.

Offline TurfIt

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 1323
Re: Changes to Routing
« Reply #6 on: November 25, 2012, 06:11:22 PM »
For the first, that shouldn't be happening. I've just recently seem some wrong distributions (yet again!) and planned to look into it today, but that was with only a single player/station. Do you have a small simple savegame demonstrating this?

The size of the stations should only come into play when there's no convoys loading. Before I added size as a factor, larger stations were useless as it would always distribute evenly until the smaller overflowed. Now, it should be distributing in proportion to the sizes. E.g. station A with capacity 100, station B with capacity 200. Distributions should be A, B, B, A, B, B, ...
If any player has a convoy loading, then that empties the station and will result in all distributions to him.
If all players have a convoy loading, then it should distribute A, B, C, A, B, C, ...
So, if you're in a 'war' for cargo, you need to leave a convoy loading at all times. Just like good ole TTD!

Defining 'better' for routing is quite a task. Dwachs had tried a journey time implementation but it suffered from oscillations of the routes. It's certainly worth another try...

I believe a distance based criterion was tried in the past most unsuccessfully. Prissi?

On my todo list is to try a hybrid approach -  number of hops with distance as a tie breaker. That way if there's two routes with the same number of hops, the one with the shortest distance will be prefered, but if there's a route with less hops, it will be taken even if longer. That should even the flows.


Edit:
Note there's a big difference between factory distributions and routing, perhaps this should be two topics?
« Last Edit: November 25, 2012, 06:20:47 PM by TurfIt »

Offline Fifty

  • *
  • Posts: 280
  • Languages: EN, ES
Re: Changes to Routing
« Reply #7 on: November 25, 2012, 06:51:30 PM »
Please take a look at this example savegame I just created. Blue has the larger station. http://simutrans-germany.com/files/upload/multiplayer_routing.sve

If both red and blue trains are at the station, then only the blue train will load. Once the blue train leaves the station, it fills to what seems to be some percentage of its capacity, and then the red train begins to load. If I add enough station extensions, the red train will never leave the station, as all of the coal will go to the blue platform.

If both trains are out of the station, then the station with a greater difference between its capacity and the amount in the station gets the freight. For example, if blue has a 1000 unit platform filled with 600 units of coal and red has a 200 unit platform filled with 50 units of coal, blue will get the freight until it has 850 units, at which point supply will alternate.

On my todo list is to try a hybrid approach -  number of hops with distance as a tie breaker. That way if there's two routes with the same number of hops, the one with the shortest distance will be prefered, but if there's a route with less hops, it will be taken even if longer. That should even the flows.

Edit:
Note there's a big difference between factory distributions and routing, perhaps this should be two topics?

This is what I would very much like to see. Please feel free to split these topics, sorry for creating confusion!

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4564
  • Languages: EN, DE, AT
Re: Changes to Routing
« Reply #8 on: November 25, 2012, 07:19:21 PM »
The size of the stations should only come into play when there's no convoys loading. Before I added size as a factor, larger stations were useless as it would always distribute evenly until the smaller overflowed. Now, it should be distributing in proportion to the sizes. E.g. station A with capacity 100, station B with capacity 200. Distributions should be A, B, B, A, B, B, ...
If any player has a convoy loading, then that empties the station and will result in all distributions to him.
If all players have a convoy loading, then it should distribute A, B, C, A, B, C, ...
Thats not what is happening. It seems that the shift-right >> precision_bits in distribute_ware_t constructor is wrong. results in integer underflow.

The first suggestion was implemented by Knightly into Experimental a long time ago; ...
??? The method in question (fabrik_t::verteile_waren) seems almost identic in standard and experimental (the only differences I could spot where due to the different routing in exp).
« Last Edit: November 25, 2012, 07:50:36 PM by Dwachs »

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4564
  • Languages: EN, DE, AT
Re: Changes to Routing
« Reply #9 on: November 25, 2012, 07:20:31 PM »
Mod Note:

Please continue discussion about passenger routing over there:

http://forum.simutrans.com/index.php?topic=10932

Thank you.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4564
  • Languages: EN, DE, AT
Re: Changes to distribution of goods from factory to stations
« Reply #10 on: November 25, 2012, 07:50:11 PM »
here is a patch for distribute_ware_t, which should be integer overflow and underflow save.

Offline TurfIt

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 1323
Re: Changes to distribution of goods from factory to stations
« Reply #11 on: November 25, 2012, 07:58:48 PM »
Heh, was just going to say time for 64bit! Feels like a cop out to keep changing to 64bit calcs all over the place rather than working within the 32bit bounds...

Go ahead and commit; It fixes things. I also found the source of the distribution problem I mentioned - index_offset needs to be on a per ware basis.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4564
  • Languages: EN, DE, AT
Re: Changes to distribution of goods from factory to stations
« Reply #12 on: November 25, 2012, 08:21:23 PM »
committed with r6095.