Automated timetables and separation

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

Gathers
Engineer
Engineer
Posts: 44
Joined: 25 Nov 2007 13:26

Re: Automated timetables and separation

Post by Gathers »

Thank you Yuri! :D
Please accept this complimentary biscuit as a token of appreciation for your detailed bug report. ;)

First post has been updated with a new version.

Please let me know if you have any other bugs or crashes happen!
(The save "game will crash.sav" will still crash, but should trigger an assertion now to make things like this easier to track down in the future.)
User avatar
ColdIce
Transport Coordinator
Transport Coordinator
Posts: 306
Joined: 25 Apr 2006 10:22
Location: Bucharest

Re: Automated timetables and separation

Post by ColdIce »

can you update it, please? thank you
The rest is confetti!
User avatar
wouter2512
Engineer
Engineer
Posts: 6
Joined: 08 Feb 2010 20:27
Location: Delft, The Netherlands

Re: Automated timetables and separation

Post by wouter2512 »

Updated binary
automated-timetables-and-separation-v0.71 against r19318
openttd-trunk-r19318-win32-automated-timetables-and-separation-v0.71.rar
automated-timetables-and-separation-v0.71 against r19318
(3.07 MiB) Downloaded 278 times
Gathers
Engineer
Engineer
Posts: 44
Joined: 25 Nov 2007 13:26

Re: Automated timetables and separation

Post by Gathers »

Patch updated with some minor fixes and one crash-fix. (turning off automation when order-list was empty caused a crash)
No change to separation logic.
Also bumped past trunk change that broke compilation: (svn r19405) -Codechange: CheckOwnership() returns a CommandCost.

Only hastily tested I'm afraid. I hope no new bugs were introduced.

Enjoy! :)
User avatar
ostlandr
Chairman
Chairman
Posts: 882
Joined: 12 May 2007 01:09
Location: Northeastern USA

Re: Automated timetables and separation

Post by ostlandr »

Just wanted to chime in and say how much I enjoy this patch. Currently playing it in the "cargodist with sprinkles" pack. So far I'm just using it to keep buses from bunching up. This is a problem IRL also- I wonder if your code could be used to calculate better schedules for real-world buses?
It not only works for congested city routes, but when I have express buses connecting a small town to the rest of the network, it keeps them separated nicely. Next step: test with trains to see if I can max out station ratings at primary industries without using "full load".
Who is John Galt?
User avatar
michielh
Engineer
Engineer
Posts: 22
Joined: 29 Apr 2009 13:17
Location: NL

Re: Automated timetables and separation

Post by michielh »

Great patch, works great for busses and trams!

It's also working for trains, but not completly without problems, 2 things I discovered:

- Autosep can't handle 'via-orders', the trains won't seperate even if you've got one via order in the order list.
- Something minor: you cannot use autosep when you've got different types of trains (different Vmax) in the shared order list, because te slower trians won't keep up with the faster ones -> bigger gap.

It would be great if those things could be solved, but as for the rest; keep up te good work! :wink:
Zero
Engineer
Engineer
Posts: 23
Joined: 10 Mar 2006 17:33
Location: Kassel, Germany

Re: Automated timetables and separation

Post by Zero »

I use the version from the "Daylength, Cargodist with sprinkles" pack version posted in this post.
Seperation for trains and busses worked fine but with ships it did not work and they crowded up like in the screenshot below:
Attachments
ships.png
Tvel
Engineer
Engineer
Posts: 77
Joined: 29 Mar 2008 22:42
Skype: tvel___
Location: Bulgaria

Re: Automated timetables and separation

Post by Tvel »

As michielh said, right now the patch can't handle "via-orders".
Ships with buoys in their order list won't separate.

I hope this is an easy thing to fix. I love the patch :).
Gathers
Engineer
Engineer
Posts: 44
Joined: 25 Nov 2007 13:26

Re: Automated timetables and separation

Post by Gathers »

Thanks for the feedback and reports! I'm always very happy to hear people are playing with and enjoying this. :D
michielh wrote:- Autosep can't handle 'via-orders', the trains won't seperate even if you've got one via order in the order list.
- Something minor: you cannot use autosep when you've got different types of trains (different Vmax) in the shared order list, because te slower trians won't keep up with the faster ones -> bigger gap.
Ah, I didn't know via-orders didn't work anymore. I'll try to fix that as soon as I have some free time.

That vehicles with different max speed won't separate evenly, well I'm not sure if anything should be done about that. I doubt there is a single solution which could please a majority of the users.
Cadde
Transport Coordinator
Transport Coordinator
Posts: 290
Joined: 07 Oct 2004 12:51

Re: Automated timetables and separation

Post by Cadde »

EDIT:

Well, i forgot to also mention i haven't tried this patch yet in my original post...
I like how this patch works. It maintains the flow of the vehicles while keeping them spaced evenly but the one issue i have with it is that whenever a vehicle breaks down it re-arranges the actual schedule of the vehicles so that any other lines that would rely on the schedule of this one would come out of sync. See my original post below for an example of what i am after.

With that said, maybe if i turn off automatic vehicle spacing the orders will stay on one schedule. Let me test that later, right now i am running a new game from 1900 with daylength patch. It's moving quite slow. :D

--- Original Post ---

So i just skimmed the thread and found no mention of my take on how to make "proper" spacing between your vehicles, especially when it comes to trains.

The most basic way to create spacing is to launch your train manually when the other train(s) are at the desired spacing and by doing so the timetable should (if buffered properly) maintain that spacing quite well.
The other option is to set the start dates of each of your trains and launch them at the time most suitable, preferably making the start dates a division of timetable completion time / number of trains.
If you want to get really advanced... as in making sure trains come and go in a specific order possibly sharing tracks while doing so and then branching off it gets quite complicated. Imagine this situation for example:

Train 1 is departing from Big City Central on June 11th.
Train 2 is departing from Big City Transfer on July 2nd.

Train 1 is set to arrive at Big City Suburbs on September 29th.
Train 2 is set to arrive at Big City Suburbs on September 24th.

Train 2 is set to leave Big City Suburbs AFTER train 1 has unloaded it's passengers on October 8th.

This is quite simple on paper until you have to make sure both lines are keeping this synchronization AND that when you add a second or third train on their respective routes they should also maintain spacing.
It takes quite a lot of calculation work just to make such synchronizations happen and converting days to calendar dates is only adding to the frustration.

...

So here are my suggestion for this or any patch like it:
  • Add a text field where we can set start date in days/ticks from now or days/ticks from the selected date in the dropdown. (Both positive and negative values)
  • Add some sort of functionality where you can either drag-drop or select an expected arrival date from the schedule of one train to a schedule of another and it tries to match the arrival date on the second train by modifying the time spent at stations. Optionally also setting the start date of the timetable of the second train.
  • Re-introduce the virtual clock in 12/24 hour format to make it easier (once again?) to manage timetables. Of course while changing the start date drop-downs into a HH:MM:SS text field and keeping the above mentioned offset field but this time the offset is in HH:MM:SS format as well instead of days/ticks.
Any autospacing functionality could then exploit this new functionality by setting the start dates on trains.

If the timetable would take 10,000 ticks to complete and you have 5 trains to space it would set the start date (in ticks) as train 1 + 0 ticks, train 2 + 2,000 ticks, train 3 + 4,000 ticks and so on.
Where we go from there i leave up to you. :wink:

I just wish i could easily set up a schedule where (in theory) i wouldn't even need signals because all my trains would be scheduled to never try to occupy the same piece of track. Even though signals wouldn't hurt for when the unexpected happens.

Thanks for listening!
//Cadde
Last edited by Cadde on 12 Apr 2010 01:19, edited 1 time in total.
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: Automated timetables and separation

Post by Kogut »

It works great, thanks! //comment from user of cargodist with sprinkles pathpack
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
dbkblk
Traffic Manager
Traffic Manager
Posts: 154
Joined: 29 Mar 2008 18:38

Re: Automated timetables and separation

Post by dbkblk »

Hey, you've made a wonderful patch there !

I've noticed that the patch doesn't support for "servicing" orders yet. I use to make bus / tram lines that end with an "unload" order followed by a servicing order. This patch cannot separate bus / tram with that kind of orders.

EDIT: F.e. A bus line with "A > B > C > B > A(unload) > Depot".

Do you plan to work on it ?

Thanks you,
Gathers
Engineer
Engineer
Posts: 44
Joined: 25 Nov 2007 13:26

Re: Automated timetables and separation

Post by Gathers »

Thanks for your thoughts Cadde! :)
I'm afraid that not only does my patch rearrange the schedule when vehicles break down but it slowly does so continuously for a variety of reasons. ;) One vehicle might wait at a signal while the other doesn't, a station might have many passengers/goods at one time but be empty the next.. Also, if you tell a vehicle to skip to another order, that will change things as it tries to slot into the new position. All of this does, by design, change the timetable and thus also it's relative "sync" compared to other lines/timetables.

And for any "click-and-forget" approach to separation I don't see a simple solution but to constantly adjust/rearrange. Example: If a line is built in a town when it is small then that timetable will have to change continuously as the town grows or it's vehicles will never be able to keep time because the time vehicles spend loading/unloading are longer in a town with many passengers than in one with few.

Regarding this idea:
If the timetable would take 10,000 ticks to complete and you have 5 trains to space it would set the start date (in ticks) as train 1 + 0 ticks, train 2 + 2,000 ticks, train 3 + 4,000 ticks and so on.
This is indeed exactly how the patch started out, and as you might see from the first posts, there were some problems with this approach that led me to abandoning it. (though I still keep a branch around..)

Blocking stations: If a bunch of trains arrive almost at the same time to a station with 1 lane, having each of them wait until it's their "time to depart" can keep the station blocked for a long time. With my current patch, only the last one will wait for any significant time.

Conditional orders: What if the length of the timetable is not deterministic? Even if my patch doesn't really handle this at the moment, it still has the potential to try to enforce separation between vehicles only on parts of the timetable that are deterministic, while ignoring parts that are not.

Some way to synchronize different lines at certain station might still be interesting, though. But personally I'd rather see it done in a "click-and-forget" kind of way that is flexible enough to cope with changing conditions like upgrading or adding more vehicles. Also.. I don't really like having to make manual timetable changes, and coding a gui to enable even more of something I don't really enjoy does not sound very appealing to me. ;)
Gathers
Engineer
Engineer
Posts: 44
Joined: 25 Nov 2007 13:26

Re: Automated timetables and separation

Post by Gathers »

dbkblk wrote:Hey, you've made a wonderful patch there !

I've noticed that the patch doesn't support for "servicing" orders yet. I use to make bus / tram lines that end with an "unload" order followed by a servicing order. This patch cannot separate bus / tram with that kind of orders.

EDIT: F.e. A bus line with "A > B > C > B > A(unload) > Depot".

Do you plan to work on it ?

Thanks you,
Hi and thanks for the new bug! :D I don't play with breakdowns myself so I hadn't tested servicing orders. With my last fix for via-orders (so far unreleased) this does seem to work better but it is still sort of buggy. (triggers my jam-detection code because the service order suddenly takes 10 times longer than usual to "complete".. which is nothing serious but it stops separation for a little while to avoid having a very long jam mess up the timetable)

Yes, I'll work on fixing this, and hopefully "support" all conditional orders at least to the extent that they don't explode the timetable or break all traces of separation ... ;)


A request to those interested in helping me with this patch: I don't get to play a lot of long games and when I do I tend to build in a similar way, using only a subset of the options available.. So it would help a lot if I had a better savegame to use while testing. :)
Preferable it would contain different kinds of vehicles and lines with all kinds of orders.. Waypoints, service orders, different conditional order configurations.. Ideally both as normal lines with towns/industries and as test lines with just unserviced stations in the middle of nowhere, so that there are never any actual loading/unloading.. (makes it much easier to see what is actually happening)

Preferable it'd be with no grfs and only this patch, but if anyone has a save of a suitable largeish game from playing with a patch-pack then that might be of use as well. :)
dbkblk
Traffic Manager
Traffic Manager
Posts: 154
Joined: 29 Mar 2008 18:38

Re: Automated timetables and separation

Post by dbkblk »

Ok thanks you, i'll wait for that fix : )

Note that it does the same thing with train "bypasses" (and train depots, of course).
Logital82
Engineer
Engineer
Posts: 58
Joined: 15 Feb 2010 12:03
Location: Germany, Berlin

Re: Automated timetables and separation

Post by Logital82 »

I want to have an extra long time in an endstaio and the timetabel must be fix that means it should not change its times by himself. Is this possible with your patch?
Gathers
Engineer
Engineer
Posts: 44
Joined: 25 Nov 2007 13:26

Re: Automated timetables and separation

Post by Gathers »

Logital82 wrote:I want to have an extra long time in an endstaio and the timetabel must be fix that means it should not change its times by himself. Is this possible with your patch?
As it is written now, no. If the setting for separation is enabled then it is used for all timetables, not only those that are automated.
Perhaps this is a bad default, since it makes using both automated and fixed timetables harder.. I'll have to think more about this. Perhaps if the setting for separation is enabled, but a timetable is not automated it should use the old separation method that didn't "loose sync"?
Bøtteknott
Engineer
Engineer
Posts: 35
Joined: 08 Jul 2008 18:43

Re: Automated timetables and separation

Post by Bøtteknott »

This is a GREAT patch! Been looking for this for a long time!

But I have a slight problem. I can't patch it myself... :/
User avatar
SpComb
Tycoon
Tycoon
Posts: 1109
Joined: 13 Nov 2003 20:26
Location: Finland
Contact:

Re: Automated timetables and separation

Post by SpComb »

Maintenance note: needs updating for the changes in src/command.cpp @ r19602
jungle
Engineer
Engineer
Posts: 76
Joined: 17 Dec 2004 23:40
Location: UK

Re: Automated timetables and separation

Post by jungle »

This is a really useful patch - :D

I just have one issue with it - where two fairly busy routes join and then share a station (train or tram), you often end up with horrible feedback effects. The best way to explain the problem is probably to give an example:

We have two lines - the main line, and the branch line. The branch line joins the main line, shares a junction station (including shared platforms), and then splits again to go elsewhere.

A) For some reason - perhaps the adding of additional new trains to the route - the trains on the main line get out of sync, and start waiting at stations to maintain equal spacing
B) This causes a branch line train to end up waiting for a moment to get into the junction station. This wouldn't be a problem except for...
C) ...this causes the timetable on the branch line to be extended. This causes the next train on the branch line to sit in the junction station for a few moments.
D) This blocks the junction station, holding up a main line train. This makes the main line timetable longer...
E) ...and so another branch line train is delayed, extending the branch line timetable still further. And so on.

And surprisingly quickly, you have a huge queue of trains waiting to get into the junction station, piled up behind a train which believes that it is many years early.

I should be able to provide a savegame later on today to demonstrate...

My suggestion would be to make it possible for the player to give a train (or tram, bus etc) a 'Go to Junction Station (no waiting)' order.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 40 guests