The International Simutrans Forum

 

Author Topic: Spacing and loading [patch]  (Read 2732 times)

0 Members and 1 Guest are viewing this topic.

Offline Carl

  • Devotee
  • *
  • Posts: 1600
    • Website
  • Languages: EN
Spacing and loading [patch]
« on: February 16, 2012, 06:19:15 PM »
What?
When a convoy is waiting for its spacing slot, passengers will not board until 10 minutes before the spacing departure time.


Why?
Convoys may be waiting for spacing for a long time. If passengers board too early, they may miss the opportunity to board a different convoy which leaves sooner. This patch solves that problem by making passengers wait to board until near departure time.

Also, this patch ensures that -- given a choice between two waiting convoys on different lines -- passengers will board the convoy which departs first, and not just the convoy which happened to arrive first.



Note: this patch also includes the other changes to I've made to simhalt.cc regarding when passengers will board slower convoys. (I'm still getting the hang of git patches). It should be obvious which code refers to which function.

Offline Milko

  • Devotee
  • *
  • Posts: 829
Re: Spacing and loading [patch]
« Reply #1 on: February 16, 2012, 08:16:59 PM »
Hello

Very good, this patch emulates the behavior of real passengers waiting!
I was thinking ... if there are enough passengers waiting to meet the parameter "min load" they board immediately the train and the train leave immediatly?
Giuseppe

Offline dannyman

  • *
  • Posts: 182
Re: Spacing and loading [patch]
« Reply #2 on: February 16, 2012, 10:45:34 PM »
I like this idea, but like Milko I am wondering about meeting the minimum load.  (This sounds tricky to work out. :)


I can just imagine this in real life.  "Attention passengers, express train 1234 is scheduled to depart at 14:30 but will leave immediately once 20% of tickets are sold!"


(This sort of thing does happen at the macro level: timetables being jiggered around based on passenger demand, but not quite like it does in the game, where choosing the fastest ride could be really stressful for a human player. ;)



-danny

Offline ӔO

  • Devotees (Inactive)
  • *
  • Posts: 2345
  • Hopefully helpful
  • Languages: en, jp
Re: Spacing and loading [patch]
« Reply #3 on: February 16, 2012, 11:17:05 PM »
I like this idea, but like Milko I am wondering about meeting the minimum load.  (This sounds tricky to work out. :)


I can just imagine this in real life.  "Attention passengers, express train 1234 is scheduled to depart at 14:30 but will leave immediately once 20% of tickets are sold!"


(This sort of thing does happen at the macro level: timetables being jiggered around based on passenger demand, but not quite like it does in the game, where choosing the fastest ride could be really stressful for a human player. ;)



-danny

Actually, what will happen in real life is either one of two things.
a) train leaves empty to go to the rail yard or some other point in the network so that it's out of the way and can be cleaned or serviced
b) train stays at station, but passengers are locked out so the train can be cleaned or serviced.

sometimes refered to as "dead mileage".

Offline omikron

  • *
  • Posts: 110
  • Languages: EN, DE, NO, FR, EE
Re: Spacing and loading [patch]
« Reply #4 on: February 17, 2012, 08:09:21 AM »
So, what Carl's offered us is a patch that says: "Any train with a departure time more than ten minutes away is not for boarding until there are only ten minutes left."?

In that case, I wouldn't worry too much about collusion with the min. load feature. Ten minutes is still a lot of time and if your train would have gotten filled up before, you should consider adding another train....

omikron

Offline Carl

  • Devotee
  • *
  • Posts: 1600
    • Website
  • Languages: EN
Re: Spacing and loading [patch]
« Reply #5 on: February 17, 2012, 08:29:40 AM »
That's what I thought too, omikron. Also, if what you're aiming for is a full vehicle upon departure then it may be better to use minimum load with "max wait for load" instead of with spacing. (This patch doesn't apply to max wait for load).

I think the benefits here definitely outweigh any other consequences. For instance: at the moment, when passengers prematurely board a convoy instead of waiting to see if another one arrives which would leave sooner, this adversely affects waiting times at that station -- because, as I understand it, time sat on a vehicle which is waiting to depart counts towards waiting time rather than journey time. So when a passenger gets on a convoy which has 45 minutes still to wait (for example), this may distort the average waiting times. The patch fixes this.

Offline Milko

  • Devotee
  • *
  • Posts: 829
Re: Spacing and loading [patch]
« Reply #6 on: February 17, 2012, 10:55:21 AM »
Hello

If I understand it ... The patch makes the train "available" to load only 10 minutes before departure. 10 minutes before starting the train is loaded, if the load exceed the "min load" the train is leaving immediatly or waiting for its slot?

My question is about a small detail, the patch is great.

Giuseppe

Offline Carl

  • Devotee
  • *
  • Posts: 1600
    • Website
  • Languages: EN
Re: Spacing and loading [patch]
« Reply #7 on: February 17, 2012, 11:01:11 AM »
Giuseppe -- yes, once passengers begin to board (10 minutes before departure) the familiar behaviour will apply: when the minimum load is reached, the train will depart immediately. :)

Offline dannyman

  • *
  • Posts: 182
Re: Spacing and loading [patch]
« Reply #8 on: February 17, 2012, 04:28:55 PM »
Perhaps one last check in the algorithm.  IF the convoy does not depart within ten minutes, check min load.  If that many people want to board, they board and the convoy departs.  If not, the people do not board.  Everybody wins?  Is this reasonable and doable?

Thanks,
-danny

Offline Carl

  • Devotee
  • *
  • Posts: 1600
    • Website
  • Languages: EN
Re: Spacing and loading [patch]
« Reply #9 on: February 18, 2012, 09:40:26 AM »
Perhaps, although I don't think I'd know how to code it without some further study.


I tend to agree with omikron that:

Ten minutes is still a lot of time and if your train would have gotten filled up before, you should consider adding another train....
...or (I would add) using only minimum load and not convoy spacing on that line.

On a different note: I'm hoping to figure out a way to remove the essential connection between the spacing and minimum load settings (i.e. to make it possible to use one without the other at any stage on a route) -- which would, I think, make this worry a very rare occurrence.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18745
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Spacing and loading [patch]
« Reply #10 on: April 06, 2012, 04:35:26 PM »
I have now integrated this into my -devel branch, but have not had time to test it - any testing would be much appreciated! Apologies for not having done this sooner.

Offline Carl

  • Devotee
  • *
  • Posts: 1600
    • Website
  • Languages: EN
Re: Spacing and loading [patch]
« Reply #11 on: April 06, 2012, 04:49:02 PM »
Great, James, thanks! I look forward to testing this further!

It looks like the patch on this topic (which has been integrated into -devel) had the older version of the "when should passengers take slower convoys" patch -- the version with floating point numbers. This was replaced in the other topic with a non-floating version. Line 1583 onwards should read like this, from the newer patch:

Code: [Select]
New formula: Carl Baker, Feb 2012
                 
                        bool much_faster = true;
                        bool waiting_too_long = false;
                        int how_much_slower = (((journey_time) * 100) / preferred_travelling_minutes);
                     
                     // Passengers will always board slower convoy if its journey time is within an acceptable
                     // tolerance of the fastest journey time.
                     // The acceptable tolerance is scaled depending on journey time of faster convoy.
                     if (preferred_travelling_minutes <= 100 && how_much_slower < 160)
                  {much_faster = false;}
                     else if ((preferred_travelling_minutes > 100 && preferred_travelling_minutes <= 300) && (how_much_slower < 150))
                     {much_faster = false;}
                     else if ((preferred_travelling_minutes > 300 && preferred_travelling_minutes <= 600) && (how_much_slower < 140))
                     {much_faster = false;}
                     else if ((preferred_travelling_minutes > 600 && preferred_travelling_minutes <= 900) && (how_much_slower < 133))
                     {much_faster = false;}
                     else if ((preferred_travelling_minutes > 900 && preferred_travelling_minutes <= 1200) && (how_much_slower < 125))
                     {much_faster = false;}
                     else if ((preferred_travelling_minutes > 1200 && preferred_travelling_minutes <= 1800) && (how_much_slower < 122))
                     {much_faster = false;}
                     else if ((preferred_travelling_minutes > 1800) && (how_much_slower < 118))
                     {much_faster = false;}
                     
                     // If passengers have been waiting a long time, they are more likely to board a slower convoy.
                     // But this is scaled so that a much slower convoy requires a much longer-than-expected wait.
                     if (much_faster == true)
                     {if ((how_much_slower <= 125) && ( waiting_minutes >= (average_waiting_minutes * 3)))
                     {waiting_too_long = true;}
                     else if ((how_much_slower > 125 && how_much_slower <= 150) && ( waiting_minutes >= (average_waiting_minutes * 4)))
                     {waiting_too_long = true;}
                     else if ((how_much_slower > 150 && how_much_slower <= 200) && ( waiting_minutes >= (average_waiting_minutes * 5)))
                     {waiting_too_long = true;}
                     else if (how_much_slower > 200 && ( waiting_minutes >= (average_waiting_minutes * 6)))
                     {waiting_too_long = true;}
                     else {waiting_too_long = false;}}
                     
                     // Passengers continue to wait for faster convoy if...
                     if ((much_faster == true) && (waiting_too_long == false))
                     {continue;}

Edit: I notice also that the maximum "minimum load" has been set at 150 in fahrplan_gui.cc -- I think the upshot of the discussion here was that it should be set at more like 400.

Many thanks for all your work, James!
« Last Edit: April 06, 2012, 04:55:12 PM by carlbaker »

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18745
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Spacing and loading [patch]
« Reply #12 on: April 06, 2012, 05:25:11 PM »
Carl,

thank you for that - updated version (reformatted now to use the standard formatting) now in -devel. I have also increased the maximum load to 400%.

Offline Carl

  • Devotee
  • *
  • Posts: 1600
    • Website
  • Languages: EN
Re: Spacing and loading [patch]
« Reply #13 on: April 06, 2012, 05:33:02 PM »
Thanks James. Apologies for the formatting, and for the different versions of the patches being all over the place!

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18745
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Spacing and loading [patch]
« Reply #14 on: April 06, 2012, 10:22:14 PM »
Don't worry - better by far than no patches at all! If anyone has had a chance to test, I should be most grateful