[Patch] Slim Timetable Separation (new V60 out)

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

AndiK
Engineer
Engineer
Posts: 53
Joined: 07 Dec 2004 18:34
Location: Grafing bei München (Munich)
Contact:

Re: [Patch] Slim Timetable Separation (new V50 out)

Post by AndiK »

Chill:
Okay, how should I explain it? It works like this: In manual number mode, you can tell STS how many vehicles should be running the timetable. Let's say you've got a nice little tram line. You first buy one tram and let it run for one cycle without a timetable to get the stations started. Then you push Autofill and wait until it has done its job. When the timetable is complete you do a rough estimate and decide to buy 4 other trams sharing this timetable. You buy and start them. Separation mode is "Auto". In this case, the algorithm notices when the number of running vehicles changes and reinitializes. Initialization means that the distance between vehicles has changed. As soon as any of the vehicles arrives at the first station, separation is started. The current date (internally saved in ticks) is saved (:= t0). The algorithm knows how many ticks need to be between vehicles. The first vehicle starts at time 0. When the next vehicle (this can be any of them, be it the tram you originally bought or the same that has just left) arrives, STS sets its timetable start date to t0+1*separation. The vehicle after that gets t0+2*separation and so forth.
One side effect of this is that vehicles can be assigned start dates that lie in the past. In that case the vehicle is delayed and rushes around trying to catch up. Add to that other sources for delays such as growing towns and traffic jams and your nice little timetable may be complete waste within a short time.
One solution to this is manually adapting stop times (e.g. at the line ends) so vehicles can catch up. This can be quite a bit of work to get right.

Instead, I do something else:
If I need 5 vehicles running I actually buy 6 of them. I then set the separation to manual with a number of 5. The algorithm then completely ignores how many vehicles are actually running and just tries to keep 5 running. This means that there is always one surplus vehicle waiting at the first stop to catch the next departure slot. If your timetable is not particularly dense, this leaves plenty of time for the next vehicle to arrive (which happens at the same time as the other one leaves if it is on time).
The idea that I had while writing my last post was to introduce a second automatic mode that works like the first one only that it always keeps one vehicle waiting at the first station. And I need a name for this. :-)

I hope I could clear things up a bit.

Regards
Andi

Edit: Added w32 binary due to popular request by a single person. See below. :-)
Attachments
ottd_sts_V51_r23785_win32.zip
(5.56 MiB) Downloaded 174 times
Creat
Traffic Manager
Traffic Manager
Posts: 141
Joined: 26 Oct 2009 16:33

Re: [Patch] Slim Timetable Separation (new V50 out)

Post by Creat »

AndiK wrote:Hi Creat,

first of all, thanks for reporting your issue. Unfortunately, your savegame is missing a lot of Newgrfs not on BaNaNas, so I can't open it.

Just speculating:
Have you set some kind of time buffer anywhere in the timetable (i.e. set a longer stop time than Autofill does)? If not, delays will accumulate over time and break separation as vehicles try to catch up with their scheduled times. In that case, STS is working fine, only your timetable isn't. Have a look at my explanation of the manual number mode in the first post. This is my preferred solution to this problem.

.oO( ToDo for next version: Add Auto-One-Less-Mode* that does the manual number thing automatically )

Regards
Andi

* Does anyone know a better name for this?
I actually haven't modified any timetable, ever. I let it autofill and then let it run. If the timetable is filled in such a way that it isn't even capable of working correctly after an autofill, then there is a fundamental flaw in the timetable-generation and/or usage. What is the point of the thing if I have to edit every entry afterwards? (And yes, I know that isn't your fault but a problem of trunk, if it is one)

Your explanation also just confused me a bit, as I apparently misunderstood how the thing works. I thought it was basically just interested in the total time T from the timetable and the vehicle count N. If a vehicle (sharing the orders the timetable belongs to) stops at any stop after another vehicle (from that group) has left there less than T/N time ago, it is delayed until this time is reached.
EDIT: just noticed your explanation above, nevermind the question :)

I noticed that vehicles, which are stopped in a depot, seem to still be counted as part of the "vehicle count" for a route. At least the info-dialog in the timetable-window counts them (vehicle count and distance both remain unchanged when returning vehicles to a depot or starting them from one), the distance of the currently running vehicles seems to be correct though. Soo I assume this is just a display issue? Can I suggest displaying "3 (+2)" as an example, when there are 5 vehicles assigned to a route, but 2 are stopped in a depot (and therefore don't matter in any way)?

In case you would be so generous to take the time to get the missing GRFs by hand, I've compiled all the download locations for you below (most missing GRFs are from the single ECS link anyway). I'm not sure about weather I'm allowed to compile them into a .zip or something and either upload them somewhere or send them to you, so I opted for this variant instead.
One more comment on that save: I can't see any of the (misbehaving) vehicles ever waiting at a station for a significant amount of time, let alone long enough to be spaced out equally. Also (to take the counter-clockwise route as an example) they are late, but only around 23 days for the first vehicle and about 5 for the second (at least over time those are the averages I'd say). So if the first was able to catch-up it's lateness, the separation would probably be fine. They occasionally switch places by the way, which happens if the first vehicle breaks down on a piece of straight road where the second can overtake it (example of that: june 25th, 1969). The situation remains unchanged by this though...
2cc TrainSet (r756 nightly)
ECS Vectors (1.2 not-released-yet-version)
German Road Vehicles 0.23
Planet Set 1.5.3
Transrapid TrackSet (r29 nightly)
AndiK
Engineer
Engineer
Posts: 53
Joined: 07 Dec 2004 18:34
Location: Grafing bei München (Munich)
Contact:

Re: [Patch] Slim Timetable Separation (new V50 out)

Post by AndiK »

Hi Creat,

a friend has pointed me towards the newgrf_developer_tools cfg setting. With this I could open your savegame albeit with the wrong graphics. Thanks for compiling them for me, anyway. :-) As far as I can tell, it's the issue I had suspected above: Too short stopping times. If you take a look at the timetable all the vehicles are delayed by ~2500 ticks (= ~30 days). All stopping times are set to 72 ticks/1 day which is far too little. Add delays by breakdowns to that. No wonder they don't stop for long...

As it is right now, the Autofill button is only of use for the first run on a completely empty line where passengers are already waiting. As soon as there's traffic, other vehicles may interfere with the autofilling one and sabotage travel time measurements. For the same reason I have shyed back from creating some kind of "continuous autofill" patch where even more interference can be expected.

Regarding the vehicle count: You're probably right about this bug. I'm sure it has worked in the past. I'll take a look at it.

Regards
Andi
Creat
Traffic Manager
Traffic Manager
Posts: 141
Joined: 26 Oct 2009 16:33

Re: [Patch] Slim Timetable Separation (new V50 out)

Post by Creat »

First of let me explain why my timetable looks the way it does. I usually record it with the very first vehicle (of a certain type) when the station aren't initialized yet, so the vehicle runs the first round empty. Of course when I change vehicle types (new bus/train comes out or something) I have to rerecord the timetable. Also the timetable examples from my savegame have surely been rerecorded as they've stopped working at least once before.
For me the whole point of any system trying to keep distance between vehicles should be self-regulating if at all possible. If I have to use the timetable I don't want the waiting times to be longer than the minimum, even though I usually can't be bothered to adjust those by hand, so they are whatever happens to be recorded. There is little point in my eyes in waiting at a certain station for 5 days just because when I had 2 fewer vehicles it was overcrowded and that time was needed, but now another station generates more passengers and dictates the amount of vehicles. So I'd rather have stop times of 1 days for every stop and artificially inflated travel times between stops by the amount that would normally be added to the stops.

So let me suggest something a little more radical, which could make the whole system self-regulating while keeping the current flexibility (if not increasing it). Basically there are two approaches I can offer, one requiring very little coding (more of a quick fix, if you will), the other with most likely more effort would reduce the functionality of (what is currently) timetables to just keeping distance.

"Quick Fix" version: Let me start by saying that the actual timetable function, trying to keep a vehicle to a global schedule is completely useless for keeping a constant distance between vehicles. I honestly don't even know what the original intent for it's use is. But the fact remains that you currently use the mechanics provided through timetables to adjust the separation of vehicles. The simplest solution that can remove the effect from that timetable implementation as a problem and have the thing work at least approximately right over long periods of time would be to just either constantly reset the vehicle lateness (either at every stop or at the first stop, I'm unaware of how such actions would affect your implementation), or stop "keeping score" with a general timetable in the literal sense in the first place (i.e. never change the early/late entry in the first place and/or disregard any value it may contain). Even after changing vehicles the separation would more or less work as intended, just with either too small or too big gaps, but still quite functional.

Tailored Functionality: This would either re-purpose the timetable functionality to (only) do vehicle separation, or provide an additional mode operating independently from timetables. Because what is actually needed to keep vehicles at equal distance is relatively little: The number of vehicles currently running a route (trivial) and time it takes to complete the route has to be known (not as trivial, but not complicated either). To get the second let every vehicle record the time it need to get from every stop on it's order list to the next. Adding this up and averaging over all vehicles on a route gives the travel time. If this value is kept and modified whenever a vehicle completes a leg or it's order list with "val = a*new + (1-a)*old" this avoid any jumpy behavior due to breakdowns. This can either be per leg/section of the route or for the entire route at once (in the end only the total time for the route is relevant, so whichever is easier to implement I guess).
Now that the time required for a route is known (and automatically readjusted for faster and slower vehicles alike) the only thing that is still needed is to actually keep the distance. This can be done quite easily as I mentioned in the previous post: Whenever a vehicle is ready to leave a station (i.e. done loading) there is a check when the last vehicle from the order list left the station. If it is less than (total route time)/(vehicle count) ago, it is held back (still loading, like the timetable does) until this time is reached.
This system should never ever break, as the total time (on which waiting is based upon) is dependent only on the travel times between stops, which is never modified by waiting.
The most complicated thing about this is to figure out the UI, since this can easily coexist with the current timetable implementation (for anyone who wants to still use that). For example anyone can set waiting times at stops if (s)he so desires, the separation timer check would just come after the timetabled waiting is completed. The UI could be sort of merged into the timetable like it is now, but it could also be placed in the order-view in a sub-frame on the right much like it is now on the timetable view. All that is needed is effectively an "on/off" switch, that's all. It could also be a button to the left of the "timetable"-switch at the top, it just says "separation" and when pressed turns it on for that (shared) order list (and it would be disabled for orders which aren't shared). Or that same thing but somewhere between all the buttons at the bottom (between 'delete' and 'go to'?).

So to summarize, the following data would need to be collected/updated for this:
  • For every (shared) order list
    • Total average completion time (averaged over all vehicles, possibly averaged over time)
    • last departure time of a vehicle for every stop
  • For every vehicle on such a list
    • Time taken to get from every stop to the next
Since it's very little effort the tracking can also be active for orders that include just 1 vehicle. If a second one is added the whole system already runs smoothly and no need to wait again for any vehicle to complete the order list. Generally keeping distance can be activated as soon as there is at least 1 value for all of the travel times tracked by vehicles. Precision will increase as more vehicles contribute their values.
Eddi
Tycoon
Tycoon
Posts: 8271
Joined: 17 Jan 2007 00:14

Re: [Patch] Slim Timetable Separation (new V50 out)

Post by Eddi »

just let me voice my concern that tayloring a feature to exactly what you want for yourself may make things worse for people who want a slightly (or radically) different feature.

some people want to use timetables to synchronize larger networks (e.g. at station X, lines A, B and C which don't share orders arrive at the same time, so passengers can switch over. or lines D and E start at Y minutes apart, so they won't block each other at the signals, etc.). this should still be possible with a separation patch (so e.g. you set a timetable length, and a synchronization time/frequence, and it tells you how many vehicles you need to ensure that exactly. it won't auto-adjust afterwards anymore, because that would screw up the synchronization), the previous autoseparation patch was horrible because it had no mode to allow this behaviour. i call that a static mode (you set the timetable once, and it stays the same)

what you seem to want is (imho) leaving the timetable empty (because you don't care how long the round trip is), but only adjust the waiting time if two vehicles are too close together. to achieve that, i propose to record the actual travel times separately from the scheduled timetable, to have an estimate over the round trip time, but not influencing how vehicles travel. i call that a dynamic mode (the timetable adjusts constantly)
Creat
Traffic Manager
Traffic Manager
Posts: 141
Joined: 26 Oct 2009 16:33

Re: [Patch] Slim Timetable Separation (new V50 out)

Post by Creat »

Eddi wrote:just let me voice my concern that tayloring a feature to exactly what you want for yourself may make things worse for people who want a slightly (or radically) different feature.

some people want to use timetables to synchronize larger networks (e.g. at station X, lines A, B and C which don't share orders arrive at the same time, so passengers can switch over. or lines D and E start at Y minutes apart, so they won't block each other at the signals, etc.). this should still be possible with a separation patch (so e.g. you set a timetable length, and a synchronization time/frequence, and it tells you how many vehicles you need to ensure that exactly. it won't auto-adjust afterwards anymore, because that would screw up the synchronization), the previous autoseparation patch was horrible because it had no mode to allow this behaviour. i call that a static mode (you set the timetable once, and it stays the same)

what you seem to want is (imho) leaving the timetable empty (because you don't care how long the round trip is), but only adjust the waiting time if two vehicles are too close together. to achieve that, i propose to record the actual travel times separately from the scheduled timetable, to have an estimate over the round trip time, but not influencing how vehicles travel. i call that a dynamic mode (the timetable adjusts constantly)
First of all: thank you, that was the first explanation I have ever heard which explains what the timetables (as they are implemented in trunk) can achieve and where the "global timing" thing comes in handy. Moreover, it's a pretty neat idea, I might actually use that passengers switching trains thingy!

Now on to the issue at hand: Yes, I agree that a vehicle separation patch should not remove any functionality.
With my first suggestion (basically ignoring/resetting the delay/early property of the timetable) this would be very much possible. Just set the separation mode to "Off" like you can do already (no need to remove that drop-down which allows this). This would turn any separation code off like it does now, so it would work just like vanilla OpenTTD.
For my second suggestion: that wouldn't even touch the timetable code (if the waiting-until-time-reached can be more or less easily be implemented without using the timetable entries like it is now). And it would basically be what you describe (if you read the "Tailored Functionality" part of my last post again, it is more or less the same suggestion as your last paragraph, just written longer :roll:) . It would basically be a separate feature which only requires a simple on/off switch from somewhere in the orders-window. You either turn it on or not. If you turn it on WITH an active timetable you better know what you want to achieve. Essentially it is just that: keep track of how long trips take for each vehicle, so you can figure out how long a round trip is (average). After any vehicle leaves a stop the next one with shared orders has to wait 1/(total time) before it can depart.

I also occasionally use timetables, but mostly for things like passenger ships, and then they are usually incomplete (only dictating waiting time at certain docks f.ex.). I may set the waiting time at a dock to something like 10 days so I can be sure a connecting train comes by (or something similar). This of course requires the trains to maintain separation or they will all be lumped together and probably none will come during that waiting time :?

One additional thing I forgot earlier: When tracking when the last vehicle sharing a specific order list visited a stop on that list, it has to be tracked which entry in the list it was. Obviously routes can visit the same station multiple times (for example when passing through in both directions).
Creat
Traffic Manager
Traffic Manager
Posts: 141
Joined: 26 Oct 2009 16:33

Re: [Patch] Slim Timetable Separation (new V50 out)

Post by Creat »

Just a quick update if anyone wants it: I've added german language support. Apart from that it is pretty much the same patch AndiK posted.

The remaining (minimalistic) changes are adjusting variable names to match changes in trunk and a few style adjustments to match coding style guidelines.
Attachments
slim_timetable_separation_updated_r23754.diff
(33.74 KiB) Downloaded 159 times
Creat
Traffic Manager
Traffic Manager
Posts: 141
Joined: 26 Oct 2009 16:33

Re: [Patch] Slim Timetable Separation (new V50 out)

Post by Creat »

Hello again o/

I'm in another game and have the same problem again: Buses keep clogging together, there are only 2 on the route. This time the timetable is fine, but I've only recently changed it to be fine. It is impossible to reset the lateness, as the separation keeps restoring the (broken) values somehow. It uses pretty much the same NewGRFs as the last game (see links in my previous post for a download of those not on bananas).

There is a bus route connecting Aberside Marsh and St. Carnston. The timetable takes 84 days to complete, while the actual time (with no breakdowns) is about 60-70. So there is plenty of room. Note that when you load the game, the first vehicle is actually on time, the second is 60 days late or so. The moment they enter the stop they are suddenly about 200 days late.

To verify that the timetable timing is fine by itself, set separation to "Off". Then both vehicles keep whatever distance they have and are basically on time. It's also fine to re-enable the automatic mode, then they are also separated nicely. I have noticed, that on changing any of the times/durations in the does not set the separation mode to "initializing". It is basically always "running", even after changes. This also explain the clearly wrong separation time of 20 days (should be 42).
Attachments
Unable to reset lateness.sav
(113.53 KiB) Downloaded 119 times
AndiK
Engineer
Engineer
Posts: 53
Joined: 07 Dec 2004 18:34
Location: Grafing bei München (Munich)
Contact:

Re: [Patch] Slim Timetable Separation (new V50 out)

Post by AndiK »

Hi Creat,

yup, that's a bug you've found there. Separation should automatically reinitialize when the timetable is changed. I'm absolutely sure that this has worked in an old version. It should be fixed in the next version. Until then, I hope you can live with the classic "Windows" approach to problem solving: Turning it off and on again. :-)

Thanks for reporting!

Regards
Andi
AndiK
Engineer
Engineer
Posts: 53
Joined: 07 Dec 2004 18:34
Location: Grafing bei München (Munich)
Contact:

Re: [Patch] Slim Timetable Separation (new V60 out)

Post by AndiK »

*bump* with new version. See first post.
User avatar
ffpp
Engineer
Engineer
Posts: 125
Joined: 29 Jan 2010 12:56

Re: [Patch] Slim Timetable Separation (new V60 out)

Post by ffpp »

Interesting. I integrated it with my installation of the newest CargoDistribution + my own patch. Only two smaller problems on patching, but hoping there will be no problems in the longer run I solved them. Will test it now.
User avatar
FLHerne
Tycoon
Tycoon
Posts: 1543
Joined: 12 Jul 2011 12:09
Location: St Ives, Cambs, UK

Re: [Patch] Slim Timetable Separation (new V60 out)

Post by FLHerne »

I integrated it with my installation of the newest CargoDistribution + my own patch. Only two smaller problems on patching, but hoping there will be no problems in the longer run I solved them.
Would you mind explaining what you changed? I'm trying to do about the same thing. :wink:
I modified the saveload files, but the Advanced Settings still seem to break.
Temporary Permanent signature filling text. Content coming soon delayed indefinitely! Oh, and I have had a screenshot thread.
Linux user (XMonad DWM/KDE, Arch), IRC obsessive and rail enthusiast. No longer building robots; now I ring church bells.
Author of an incredibly boring stickied post about NewGRFs.
handrake
Engineer
Engineer
Posts: 55
Joined: 26 Mar 2012 10:23

Re: [Patch] Slim Timetable Separation (new V60 out)

Post by handrake »

Great patch! works beautifully for road vehicles. Now there is a good reason starting using timetables for the rest of us.
MJS
Director
Director
Posts: 540
Joined: 28 Jul 2005 09:31

Re: [Patch] Slim Timetable Separation (new V60 out)

Post by MJS »

Is anyone playing this in combination with cargo destinations? And if so, is (s)he willing to share a binary, perhaps?
User avatar
Lordmwa
President
President
Posts: 899
Joined: 20 May 2006 19:30
Location: West Sussex, England

Re: [Patch] Slim Timetable Separation (new V60 out)

Post by Lordmwa »

Im in the process of trying to compile a combination of these two patches but if it doesnt go cleanly it may take me a while or never happen......
The TT forums trivia tournament! Come along and join in the fun
http://www.funtrivia.com/private/main.cfm?tid=90722
User avatar
Lordmwa
President
President
Posts: 899
Joined: 20 May 2006 19:30
Location: West Sussex, England

Re: [Patch] Slim Timetable Separation (new V60 out)

Post by Lordmwa »

I cannot get this patch to actually seperate vehicles properly.

I have 6 trains on a route and have tried auto - got 3 running right behind each other, and also manual time with 1500 ticks or 30 minutes.

Is there any chance there can be an acutal auto function that updates the timetable to? When my trains are fairly seperate they still need manual timetable editing
The TT forums trivia tournament! Come along and join in the fun
http://www.funtrivia.com/private/main.cfm?tid=90722
AndiK
Engineer
Engineer
Posts: 53
Joined: 07 Dec 2004 18:34
Location: Grafing bei München (Munich)
Contact:

Re: [Patch] Slim Timetable Separation (new V60 out)

Post by AndiK »

What exactly did you do? Slim Timetable Separation requires a timetable filled with sane times. Having one vehicle autofill at the second round (first one to initialize stations) without others on the line usually does the trick for me. After that it should be fire and forget.

Edit: About that dynamic autofill: Creat and I started collecting some ideas together a few months ago. So far, no actual work on this field has been done, unfortunately.
handrake
Engineer
Engineer
Posts: 55
Joined: 26 Mar 2012 10:23

Re: [Patch] Slim Timetable Separation (new V60 out)

Post by handrake »

AndiK wrote:What exactly did you do? Slim Timetable Separation requires a timetable filled with sane times. Having one vehicle autofill at the second round (first one to initialize stations) without others on the line usually does the trick for me. After that it should be fire and forget.

Edit: About that dynamic autofill: Creat and I started collecting some ideas together a few months ago. So far, no actual work on this field has been done, unfortunately.
I do what you do too, but I run into problems after having them run for awhile. Here's the savefile recorded with r24032 + your patch. Two buses are clogging very badly, one running right after the other even when auto-mode is on.
sts bad2.sav
(338.31 KiB) Downloaded 120 times
AndiK
Engineer
Engineer
Posts: 53
Joined: 07 Dec 2004 18:34
Location: Grafing bei München (Munich)
Contact:

Re: [Patch] Slim Timetable Separation (new V60 out)

Post by AndiK »

Are you sure you're using r24032 with only STS V60 patched in? I can't open your savegame file. :-(
handrake
Engineer
Engineer
Posts: 55
Joined: 26 Mar 2012 10:23

Re: [Patch] Slim Timetable Separation (new V60 out)

Post by handrake »

Hi,

Someone reported enabling separation overrides start date in timetable, so I looked into the code and (I think) I found the reason. Here's the patch. Doesn't apply directly to your original patch since it's somewhat modified to be included for my patch pack, but you get the idea.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 19 guests