News:

Want to praise Simutrans?
Your feedback is important for us ;D.

Convoi auto unbunching on line

Started by Train-catcher, July 23, 2017, 01:22:25 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Train-catcher

Hello all!

I've being played Simutrans for many years. And now I've become to write some improvements for my convenience. But decided to share with other community. Maybe these will be useful for others=)

Seems like similar topic was offered many-many time ago. But I've decided to start a fresh one)

So, unbunching: it's for making convoy intervals more mean on some line.
How it works: a convoy just stays loading on a halt when there is not enough interval between the previous one. But this convoy does not make congestions. if it tends to block some other convoy, it will stop unbunching and proceed.

Other features:
- unbunching for road lines, trains and train-like lines(trams, monorail etc) (but not air and ships);
- GUI toggle in the line management;
- always proceeds when full loaded even if it needs for unbunching;
- With "Unbunching" toggled in, load time and percentage will be ignored.

Was tested by me on pak128; linux64

Here the binary with this feature for linux64:sdl2
This binary was built for the latest 'master' branch merged with this feature.
https://yadi.sk/d/Y47m3V353LK4Sz

If someone interested in, I can build this one for other platforms (e.g. win)

Here the forked Simutrans repo with this feature in the separate branch:
https://github.com/Elektri4ker/simutrans/tree/feature/auto_unbunching

.patch file is in attachments.

Ters

This doesn't help for me. If the vehicles wait at stops, they will block other traffic. Which might be part of the reason why changes like this has been rejected many times before.

Train-catcher

Quote from: Ters on July 23, 2017, 02:17:07 PM
This doesn't help for me. If the vehicles wait at stops, they will block other traffic. Which might be part of the reason why changes like this has been rejected many times before.
No, they don't. They will proceed when they are tend to block other traffic. May tiny delays occur, they're does not matter.

Seems like features like this are much wanted by many players, so feature itself not bad, but implementation should be clear enough.

Ters

Quote from: Train-catcher on July 23, 2017, 02:33:25 PM
Seems like features like this are much wanted by many players, so feature itself not bad, but implementation should be clear enough.

As I wrote, some way to keep the vehicle on a line on regular intervals is often requested. Nobody has come up with a solution that is accepted, although few have provided an actual implementation. My suggestion was to make passengers weightless, since the effect is caused by buses picking up fewer passengers being lighter and therefore faster. They then catch up, making them pick up fewer passengers, which just increases the effect.

Train-catcher

Quotemake passengers weightless
This is a rather weird workaround.

Nevertheless, manual adjusting of intervals is always unstable.

Is there a chance that someone gonna test this solution?=)
For me it works perfect on 3000x2000 map with >300 lines (at the moment).



Ters

Quote from: Train-catcher on July 23, 2017, 08:12:41 PM
This is a rather weird workaround.

Not really, because in real life, there isn't much difference in speed between empty and full buses. The difference in Simutrans is significant, which is mainly why buses bunch together.

(Technically, it has to do with acceleration, not speed. Full and empty buses usually have the same top speed, but buses in Simutrans often spend a lot more time accelerating that their real-life counterparts.)

Now, buses in real life do even out their distances by waiting at one or more key stops for their designated departure time according to some schedule. But time in Simutrans flows differently, and an inner city bus can spend hours completing its round. It is also a question of whether it is the later buses that run too fast, and therefore need to wait, or the earlier buses that are running too slow. If the latter, then having buses wait is also a rather weird workaround.

prissi

In real life buses bunch up as well. Because the lagging bus has to pick up more passengers, which need time to enter and exits, and the catching up bus can sometimes even skip stops, because no one is waiting and no one is exiting. It happens verz often. The Berlin public transport had once even a FAQ on that topic.

EDIT: THer is even a wikipedia side on this https://en.wikipedia.org/wiki/Bus_bunching

Ters

Those buses probably have a shorter interval than those I'm used to. Except when a pair of buses operate on the same "time slot". Those tend to leap-frog. It is hard to tell what the interval is supposed to be in Simutrans, with the strange time. Not that it matters, they bunch up all the same, since there is no quiet period to reset everything.

I have been toying with the idea of scriptable schedules. That way, vehicles could return to the depot at the end, and leave either according to a time schedule, or just that there is goods waiting. It would add massive complexity to an already quite complex game, though.

Train-catcher

Reasons causing the bus bunching in the Game could be even more prosaically. E.g. player is lazy so that he just creates some line and buys some buses/trains for it in one depot. And then he pushes them onto the line in one click. And player will be glad if these vehicles would spread over the line in the mean intervals.
You'd say that he could set up 'wait for load % within some time' at some stops. So that his buses will spread over the line somehow. But this is so inconvenient, especially for new user. So it would be better for him if these vehicles could be smart enough to spread over the line by themselves. So that many modern games of similar genre have this feature enabled (e.g. Transport fever, Cities: Skylines(enabled by the mod))

There's other reasons why vehicles bunching in the Game:
- slower vehicles gain rather a big impact on this;
- traffic jams;
- stalled vehicles waiting load (e.g. on industrial routes) raised on malplanned industrial logistic;
- monotone rising of pax count all over the world;
- etc.

Seems like there be easier to eliminate the effect (actually, vehicle bunching), not the reasons.

Ters

One might say that dealing with those situations is what Simutrans is about. If bunching is because the player did something stupid, the player should have to clean up their own mess, not just wave a magic wand. But as I write again and again: Each player sees the game differently. Those just into world building probably don't want to deal with traffic planning and logistics, they just want it to flow in a visually pleasing manner.

Vehicles getting stuck behind other slower vehicles should in theory affect all vehicles just as much over time, I think, therefore splitting up bunches as much as creating them. Maybe it triggers the initial load imbalance.

Dwachs

That wiki page also has some 'fixes' to the problem, among them minimum waiting time.

Another option would be to send full busses to the next step, where passengers want to leave. So the bus does not need to stop, where it is useless anyway, and might even take a short-cut to next station, where somebody wants to leave.
Parsley, sage, rosemary, and maggikraut.

gauthier

I tested your patch by compiling from your repo but could not figure out how it works then. I have a question: how the minimum distance between two convoys is determined ? Could you give a precise step by step example to build a line that will show your patch in action ?

Train-catcher

This feature bases on whole route length detection. Then minimum interval is calculated by the formula: d = S/n (d - minimum interval, in tiles, S - route length in tiles, n - number of convoys on the line). The minimum interval in ticks is calculated by division of  `d` by maximum line speed (the same value as in the line's stat window)
At now, detection of route length takes place as the following: each convoy remembers it's odometer at the first stop in its schedule. And when this convoy returns at the first stop again, a delta between current and previous odometers is the route length. So it takes some time since line creation to establish unbunching.
This is a rather weird way of route length calculation but it doesnt need e.g. launching `calc_route()` routine at somewhat time moments and thus is being easier to implement.
There is also a disadvantage of current implementation is that if the route length changes (e.g. add or remove some stops to the line), then old route length still presents for some time so wrong intervals can occur.

When the route length was acquired, each entry of line's schedule stores  departure time of the last convoi. So, if you will send some convoy 1 stop back, it could be hold on this stop as the system would think that there's already a convoi just departed from this stop. It is also an issue to work on it later.

Nevertheless, intervals on this line always will reach stable state if user wont intrude into neither line nor schedule within some time. Also all of these issues wont influence on other traffic.

To test:
1)create new line checking 'convoi unbunching' button in the line management window;
2)set up several vehicles on this line, launch them one-by-one;
3)wait while one of the convoys hits the first stop two times, dont change line or convoy schedule;
4)since then unbunching should be invoked.
5)(optional) you can create the second line to make sure that the unbunching mechanism won't lock a road traffic

gauthier

Quote5)(optional) you can create the second line to make sure that the unbunching mechanism won't lock a road traffic
I don't understand this one.

Train-catcher

Quote from: gauthier on July 30, 2017, 08:21:05 PM
I don't understand this one.
I mean that any convoy that stays on the stop waiting for unbunching won't block any other vehicles (if there are vehicle behind, this convoy will proceed its schedule)

DrSuperGood

One can unbunch convoys already by setting them to wait for 100% and specifying a maximum wait time. Sure the unbunching is not perfect, but it is highly flexible and already in the game. I use this all the time for busses to assure regular service (so no stops overcrowd).

gauthier

Quote from: DrSuperGood on July 31, 2017, 07:38:10 AM
One can unbunch convoys already by setting them to wait for 100% and specifying a maximum wait time. Sure the unbunching is not perfect, but it is highly flexible and already in the game. I use this all the time for busses to assure regular service (so no stops overcrowd).
The point is having convoys passing regularly at each stop of the line. Let's say you have a bus line connected to a train station. A train lets some hundreds of passengers here who are going to take your buses, all the busses passing for the next few minutes are not gonna wait and the "unbunching" won't work. Worse happens if your line gets overcrowded, you end up with an overcrowding + a big nice bunching.
Min. load and wait time help, sure, but not always and not as much as we could do. I use them a lot and I'm a little tired of having to micro-manage the month wait time (which, btw, is a hassle to manage in its current form of month fraction doubles) and the min load.

Ters

Quote from: gauthier on August 01, 2017, 05:17:40 PM
A train lets some hundreds of passengers here who are going to take your buses, all the busses passing for the next few minutes are not gonna wait and the "unbunching" won't work.

This patch is not going to do something in that regard. If there are passengers waiting, vehicles will get them out of there as quickly as possible. Only when there are not enough passengers to fill all vehicles will it start unbunching. Gameplaywise, bunching is only bad because it keeps passengers waiting between the last vehicle and the first. Making passengers wait just to keep an even distance between vehicles only introduces waiting, which was the thing to avoid. The difference is that passengers perhaps will wait inside vehicles, rather than at the stops. If the motivation is just the visual aspect of neatly spaced vehicles, things become different. There is perhaps no solution that solves both.

gauthier

According to the patch description in the first post, vehicles wait for enough space after the previous vehicle, even if it's fully loaded. So Yes this patch will do something in that regard.

Bunching is bad because station gets overcrowded periodically although the line serving them has enough capacity to move everyone, if you play a little bit you already saw this a lot: a bus stop gets overcrowded, several buses in a raw pass, the last bus is empty, a lot of frustration.

The point is NOT to make passengers out as fast as possible, the point is to make them out as regularly as possible to avoid periodical overcrowding all along their path. The point of this point is avoiding to make my bus stops all very large when they would not need it if convoyes passed regularly. Station maintenance is expensive in pak128.

Ters

The post does say "always proceeds when full loaded even if it needs for unbunching". And getting passengers away as fast as possible is very important in the way I avoid overcrowding.

I also don't make big bus stops, even though I play pak64. That also means that vehicles will be unable to wait without blocking other vehicles anyway. Which is why I don't want a feature to correct bunching once it has happened, but to not make it happen in the first place. Of course, when a vehicle has to yield to other traffic or gets stuck behind slower traffic, the interval will be disrupted, but it is my belief that this will even out over time.

gauthier

Quote from: Ters on August 02, 2017, 05:34:46 PM
The post does say "always proceeds when full loaded even if it needs for unbunching". And getting passengers away as fast as possible is very important in the way I avoid overcrowding.
Indeed, my bad, sorry. Of course the patch has a limited interest if the unbunching depends on something else than distance between convoys.

I make big bus stops precisely because of bunching, my stops must have high capacity not to be overcrowded.

In my experience, getting passengers out as fast as possible is just good to move overcrowding to the next transfer. I find much more important to keep a passenger flow as regular as possible everywhere, to have a passenger charge on stations as evenly dispatched on time as possible. Currently my bus stops are like a big charge once, then a dozen convoys pass, and nothing until the same dozen convoys pass here again. To say it more graphically:

Bunched:

   /|         <- high capacity necessary
  / |   ...
/  |  /
/   |_/
    ^
   dozen of covoys pass

Unbunched:



/|  /|     <- low capacity necessary
/ |_/ |_...
  ^   ^
one convoy spaced enough from the previous one


You say that you don't want bunching to appear, that's exactly what this patch aims at, so I don't understand waht is your problem with it. You already know that a system, called a line with several convoys, has two balance point: a bunched state which is a stable balance point, and a perfectly regular state which is a highly unstable balance point. This patch aims at making the latter stable.
A line naturally tends to bunch. Even the smallest difference in space between two convoys worsen over time cause the first convoys loads more, is heavier, etc ... Making the passengers weightless has been refused for obvious realism reasons, moreover it would not make lines unbunched but would just give them a random buching state since there would be no reason for convoys to stay regular, even if it there would be no reason either to stay bunched.

Ters

Quote from: gauthier on August 03, 2017, 05:26:59 PM
You say that you don't want bunching to appear, that's exactly what this patch aims at, so I don't understand waht is your problem with it.

It is quite clearly titled "auto unbunching" and also that it does so by making vehicles wait. So the bunching has already happened and needs to be fixed. It also fixes bunching by making the latter vehicles wait, but in my opinion, they are not the ones that have problems. It is the leading vehicles that has fallen behind schedule and therefore the one that needs to speed up. That vehicles that have fallen behind schedule violate the speed limits, at least slightly, it pretty realistic, I think. However, the ultimate problem in Simutrans cities in this regard (at least for pak64), is that the average distance between places where buses need to stop, such as bus stops and busy intersections, seems to be shorter that the distance a fully loaded bus needs to reach 50 km/h. Lesser loaded buses are however more capable of reaching top speed between stops, and therefore catch up.

sebastien

Hello Train-catcher !

I tested your patch on pak128 / Windows. This is great! It works perfectly and the buses are well distributed throughout the line. Exactly what I was looking for.

However, it would be even better if it worked with bus stations (ie several bus stops with a choose signal). Currently the buses arriving at the same time leave at the same time.

prissi

Even weightless passengers would not help, because the loading/unloading also depends on the number of pax (although not strongly). And many bunching just happens because of waiting at traffic light etc.

The Hongkong test game is a nice scenario wher some lines bunch and other not, just depending on the wait and the busstops they had to travel too.

Ters

Quote from: prissi on August 21, 2017, 01:24:48 PM
And many bunching just happens because of waiting at traffic light etc.

Yes, but this also causes unbunching.

gauthier

#25
Quote from: Ters on August 21, 2017, 02:45:50 PM
Yes, but this also causes unbunching.
In fact it just causes randomness, sometimes in bunches, sometimes it unbunches, this is what I tried to explain earlier. There's no reason for convoys to space themselves regularly even if you remove things that make them tend to a bunched state. That's why there must be a timer (or a distance-based mechanism) to space them.

@Train-catcher: I tried again (code from your repo, under linux 64 bits) with no luck. I set up a very simple bus line with four aligned stops, three buses on a line consisting of a run through all the stops and return, waited for all the buses to make several tours but they won't unbunch.

EDIT: Sorry, my bad, I was not experienced enough with git and ... well ... omitted to check out your branch * feeling stupid *. So now I have the tickbox about unbunching on this line, it is ticked, I waited for my buses to make a couple of tours, but still does not work :/

Ters

Quote from: gauthier on August 21, 2017, 05:00:42 PM
There's no reason for convoys to space themselves regularly even if you remove things that make them tend to a bunched state. That's why there must be a timer (or a distance-based mechanism) to space them.

Ideally, the vehicles would leave the depot at set intervals and then maintain that interval throughout one trip with less than 1% deviation without having to wait at stops at all. By trip, I mean either of the two legs on a back-and-forth line. I don't have any experience with an actual circular line. (The closest is a figure eight.) If a vehicle is hindered is some way, the deviation is primarily fixed by that vehicle speeding up, noticeably by more aggressive acceleration, than the other vehicles slowing down.

Realistically, the bus would at the end of a trip wait at a designated holding area for the scheduled time for the next trip to begin. The way I am used to it, this holding area is rarely a stop itself, but rather some kind of depot. The depot is however often part of the same overall structure as the stops, just not where the platforms are.

Being able to use depots as a non-terminal part of a schedule has been on my wish list for years. The unlimited capacity makes it something of a cheat, though. And it steepens an already steep learning curve.

gauthier

Quotethat vehicle speeding up
Vehicles in Simutrans already give all the power they have, being only constrained by the infrastructure. Unless you give some magical horsepower to the vehicles which have to speed up, this is not possible. The other way is making vehicles behind wait a little, and that's what this patch does.

@Train-catcher: With help from Sebastien I finally got your patch to work. I have several comments:
_ Making waitings only at terminus (the first stop of the line), terminus are usually stations with several platforms available or with a waiting loop or any kind of thing to temporarily keep convoys that used to wait because of min.capacity and min.waiting time. At any other station, it may hinder a convoy from another line. I know you made it so, in a such case, the waiting convoy departs regardless of its spacing, but it still hinders the convoy after for a short time, and deteriorates the overall performance of the infrastructure by occupying a passing station longer.
_ The "0.8" ratio of the ideal space between convoys is too little, that's why it was hard for me to see that the patch was working. Why not simply remove it ? In the current situation, the 0.8 causes a very slight bunching, a sort of "hole" in the flow of convoys because they space themselves less than necessary. A ratio of 1 would cause one or two convoys waiting, that would not be a problem with the previous point about terminus stations.
_ Looks like when I open the schedule of a convoy (I do that sometimes to stop a convoy for a short time, for any reason), it messes up everything.
_ Does it work with several convoys waiting at a station equiped with choose signal ? I could not test that because of the previous point.

Ters

Quote from: gauthier on August 22, 2017, 06:41:02 PM
Vehicles in Simutrans already give all the power they have, being only constrained by the infrastructure. Unless you give some magical horsepower to the vehicles which have to speed up, this is not possible. The other way is making vehicles behind wait a little, and that's what this patch does.

In a sense, it is close to have come a full circle. In real life, the other vehicles do not wait, nor does the vehicle that has fallen behind gain magical horsepowers. The vehicles that run on schedule simply do not use all the power they got. To some extent, buses apply the necessary power to achieve the same acceleration regardless of current weight. Acceleration is probably for the most part limited by passenger comfort, not the power of the engine. This might be more true for trams and trains.

gauthier

Nobody wants convoys in Simutrans not to give all the power they have. And vehicles waiting one minute or two for better regulation exist in real life, I saw that many times on busiest commuter lines in Paris.

Ters

Quote from: gauthier on August 23, 2017, 04:40:15 PM
Nobody wants convoys in Simutrans not to give all the power they have. And vehicles waiting one minute or two for better regulation exist in real life, I saw that many times on busiest commuter lines in Paris.

Waiting is technically giving no power at all, so it is basically the same concept.

I have only seen buses hang around at the first stop, which is a relatively large terminal, after leaving the depot. At the other end of the route, I haven't made many observations. The few I have made indicate that the bus heads for a separate parking space, possibly so the driver can get some rest without being bothered by passengers that arrive early. They never hang around in between. It seems the schedule is made so that the buses will always be running slightly late.

School buses function a bit differently, even when they also serve regular passengers, but that is a special case that doesn't fit the mostly meaningless and rapid flow of time in Simutrans.

gauthier

Waiting as I say happens only when a convoy is too near from the previous one. Slowing down a convoy as you say happens all the time so the late one can speed up. These are different concepts. In mine, trains wait only as necessary, in yours they lose a lot of time cause they always go slower than they could and occasionally get some time back when they have to speed up.

prissi

r9997 has a spacing feature that will reduce bunching.