News:

Simutrans Sites
Know our official sites. Find tools and resources for Simutrans.

Spacing and loading [patch]

Started by Carl, February 16, 2012, 06:19:15 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Carl

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.

Milko

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

dannyman

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

ӔO

Quote from: dannyman 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

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".
My Sketchup open project sources
various projects rolled up: http://dl.dropbox.com/u/17111233/Roll_up.rar

Colour safe chart:

omikron

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

Carl

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.

Milko

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

Carl

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. :)

dannyman

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

Carl

Perhaps, although I don't think I'd know how to code it without some further study.


I tend to agree with omikron that:

Quote from: omikron on February 17, 2012, 08:09:21 AM
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.

jamespetts

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.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Carl

#11
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:

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!

jamespetts

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%.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Carl

Thanks James. Apologies for the formatting, and for the different versions of the patches being all over the place!

jamespetts

Don't worry - better by far than no patches at all! If anyone has had a chance to test, I should be most grateful
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.