Do you need help?
Simutrans Wiki Manual can help you to play and extend Simutrans. In 9 languages.

RRC - Selective Loading by class-of-service of convoys (prefer less-stop convoy)

Started by wackdone, July 06, 2012, 01:23:32 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


I wrote the patch for Simutrans r5788 to make passengers/goods to prefer faster (less-stop) convoy at halt.
Original concepts and implementations were proposed in Japanese Community over 2 years ago.
The former patch cannot be applied for newer Simutrans source code.
So, I re-implemented the function and added some extensions.

Please read README_RRC.txt in attached zip archive.
Following texts are copied from introduction part of the doc.

This patch-set extends Simutrans to provide "Selective Loading" function
at loading goods (including passengers) onto convoys at halts.

With this patch, goods/passengers will ride only faster convoys
(faster convoys is serving less time to trip).

For example:

       Station A  --->  Station B  --->  Station C  ---> Station D  ...

Express    stops          (passes)          stops           (passes)
Local      stops           stops            stops           stops

Passengers in Station A: [Original Simutrans]
  for Station B:  ride only Local.
  for Station C:  ride either Express or Local.
  for Station D:  ride only Local

Passenters in Station A: [by this patch (without any relaxation)]
  for Station B:  ride only Local.
  for Station C:  ride only Express.
  for Station D:  ride Express and transfer at Station C for Local.

(CAUTION: Behavier of passengers for station D depends on parameters
of route calculation.
If cost of transfer is so high, passengers will not choose transfer at
Station C. They simply ride Local at Station A for Station D.)

Selection logic is based on generic 'fastness' of the arriving convoy,
for each destination (next-transfer) halt.
If the arrived convoy is enough faster than other convoys servicing
same halt-connection, goods for the next-hop halt are loaded onto
this 'fastest' convoy.

Currently, 'number of stops' until reaching to target halt are used
as (inverse of) 'fastness'.
It is a same value with 'weight' value cached in halt.connections[]
which is used in route calculation of goods (finding halt-by-halt path of goods).
But the concept of the selection can be expandable for generic 'cost'.
It is now under development as one of example use of this selection.
to use best 'real-trip-time' (measured by convoys self)

Essence of this algorithm (in abbreviated form):

   cost = COST_BASE;

   for (dest_halt; each halt in fahrplan of the convoi (sorted)) {
      cost += COST_FOR_ONE_STOP;
      if (cost > connections[dest_halt].cost)) { // compare with best
         continue;  // ignore this convoy to use in trip for the dest_halt.

      load goods for the dest_halt...

The algorithm is implemented to be:
  * simpler
  * less calculation cost, less memory usage
  * less parameters, user settings
  * parameters only for the world, no indivisual parameter for each convoy, halt.
  * better differentiation between convoys running for same set of halts
    (but, not 'best' in some circumstances)
  * (optional) adoptive determination logic for difference of
    each balance of fast-slow mixation.

It was tested with some simple 'Express and Local' serviced lines in game.
But it's not tested under complex network / complex classification.
Please evaluate it with your map, and give me suggestion for futer imporovement.


Interesting patch!

Just a few notes:


Quote from: wackdone on July 06, 2012, 01:23:32 PM
For example:

       Station A  --->  Station B  --->  Station C  ---> Station D  ...

Express    stops          (passes)          stops           (passes)
Local      stops           stops            stops           stops

Passengers in Station A:
  for Station B:  ride either Express or Local.
  for Station C:  ride only Express.
  for Station D:  ride only Express and transfer at Station C for Local.

For Station B it must only ride Local (maybe it's a typo).


'fastness' might also be function of the real speed (e.g. using speedbonus data on average for the given line), especially for Station D, where Express + Transfer + Local would be equivalent to Local only, unless Express speed is (considerably) higher than local.


Fabio wrote:

1) Station B can be reached by only Local train
Oh, excuse me, I've had mistake.
swap Station B and Station C and swap Express and Local.
I've fixed above. (text in the zip archive is still wrong.)
Thank you for correcting.

2) source of "fastness"
Using convoys' real speed is considerable. but it may not be used in Route Calculation easily, I think.
(Route Calculation requires any deterministic 'cost' between halts by line)

and, also, 'fastness' can be 'time' calculated by distance / speed.
(but it's little bit heavy process to calculate right 'distance')
using Manhattan Distance? Resulted 'time' may not be precise...


111.3 an onwards actually save the achievable max speed of a convoi at the last leg for the revenue calculation. Thus some information is there.

As fas as I understand it, the main difference is, that probably an intermediate trasnfer is considered, when
a) still place in the convoi
b) not too big penalty for transfer

In the routing there is already a cost per stop. SO some of this is aparently already in standard.

Could you tell please the meaning of the six parameters?


>> Prissi
I've written tiny description about each parameters in the document the latter part of README.
(not in topic heading text above)
Is it not enough?

It's not a trial to change "Route calculation".
Also it's not trying to enhance revenue calculation.

This patch tries to make load balancing on differentiated service.
I'll explain more detail of our requests, later.
(I've modified description in above figure.
Difference of original and this patch is written there.)

Sorry my poor English.


Quote from: wackdone on July 06, 2012, 02:08:38 PM
Sorry my poor English.
Please, don't worry so much. We know you are doing your best. :)

If something is not clear, people will just ask for more information. Feel free to write with no fear.


Thank you for encouragement, Igor.

Example figure had some mistakes in the first document.
I've corrected it and added another example.
Full text file is attached in this post.

Extracting the new example from doc:

Another example when routecost_transfer is varied:
in this example, fix routecost_initial == 0, routecost_stops == 1

          A - B - C - D - E - F - G
Express  *       *       *       *
Local    *   *   *   *   *   *   *
          A - B - C - D - E - F - G

(1)fastest cost from A: at transfer >= 2
              1   1   3   2   5   3
              L   E   L   E   L   E
(2)fastest cost from A: at transfer == 1
              1   1   3   2   4   3
              L   E   B   E   T   E
(3)fastest cost from A: at transfer == 0
              1   1   2   2   3   3
              L   E   T   E   T   E

L: ride Local
E: ride Express
B: ride Local or Express
T: ride Express and transfer Local before destination

In case (2), there are 2 choices to travell from A to D in same cost:
  a. ride Express for C (cost == 1), transfer (cost==1), and use Local from C to D (cost == 1)
  b. ride Local for D (cost == 3)

And, another merit of Selective Loading exists,
Although a station is crowded by passengers for Express serviced stations,
Local trains can preserve space for loading of latter (Local only) halts.
In the figure shown above, Local train doesn't load passengers for halts C, E, and G.
So, the Local train can depart A having space to load passengers at B.


Opening hours 20:00 - 23:00
(In Night from friday on saturday and saturday on sunday it possibly that i be keep longer in Forum.)
I am The Assistant from Pakfilearcheologist!
Working on a big Problem!