News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

Bug: Double scheduled wait times

Started by DrSuperGood, December 21, 2017, 01:08:51 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DrSuperGood

It seems the waits for schedules are being doubled. On the server game line 275 is set to wait 10:06 but the convoys are actually waiting nearly 20:00, as shown by the hover over UI.

jamespetts

Quote from: DrSuperGood on December 21, 2017, 01:08:51 AM
It seems the waits for schedules are being doubled. On the server game line 275 is set to wait 10:06 but the convoys are actually waiting nearly 20:00, as shown by the hover over UI.

Thank you for the report. I am now away for Christmas, meaning that I do not have access to my computer with the graphical debugger, so it may be a while before I can look into this. Can you confirm whether this is universal (i.e. occurring for all schedules), or specific to some schedules?
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.

DrSuperGood

Seems to effect a couple of lines, mostly road lines. Although I will check later if it is all of them.

jamespetts

Splendid, thank you: that is helpful.
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.

TurfIt

Horses reversing and allowing another convoi into the stop when they do so?
That would be unfixed from here: https://forum.simutrans.com/index.php?topic=17265.0

DrSuperGood

QuoteHorses reversing and allowing another convoi into the stop when they do so?
Yup, terminal stops for coach line.

jamespetts

One of the fixes that I have made to the code to-day might well relate to this - I should be grateful if anyone could confirm whether this can be reproduced with to-morrow's nightly build or later. If it can be reproduced, I will need a saved game and/or the exact steps necessary to reproduce this issue reliably in order to try to fix it.

Thank you for the report.
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.

DrSuperGood

The lines appear to be waiting the scheduled time. As such it is probably fixed.

DrSuperGood

BUMP

Problem seems to be occurring again on server. Small wait time scheduled, but convoy waits twice that.

Seems to only occur if another convoy is busy reversing at the same time the next one enters a terminal. Seems to only happen with terminals facing certain orientations and if the convoy is going down a hill into it.

My theory is that it always happens if a convoy enters to queue while the previous is still reversing, just that with the slow 12 km/h coaches this is only possible if the terminal is orientated in certain directions and if the entering convoy is accelerated by going down a hill.

jamespetts

#9
Can you let me know precisely where and when this can reliably be reproduced on the server?
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.

DrSuperGood

Server game, reliably observable @5706,2819. Involves line "BUG: Doubled wait times" of company "Far East Company".

The coaches are scheduled to wait 24:00 but every time they enter they get tol to wait at least 47:20 (~ double).

Like before, my theory is that it always happens if a convoy arrives at a terminal to wait for schedule while another convoy from the same line has just departed and is still reversing. With the slow 12 km/h coaches this might only be possible if the terminal is orientated in certain directions and if the entering convoy is accelerated by going down a hill. It might think the departed convoy that is reversing has the next time slot so allocates the arriving convoy the one after that skipping the next time slot entirely.

DrSuperGood

Still a problem. 44 minute waiting for departure instead of 24.

This is a pretty high priority problem seeing how regular services are important.

jamespetts

This is actually an extremely difficult conceptual problem to deal with. It is intended that reversing convoys are taken into account in determining the queue position (and thus whether an arriving convoy is assigned the next slot rather than the next slot but one), as reversing can take a substantial amount of time. Thus, suppose that convoys on a given line take 5 minutes to reverse and are scheduled to depart from the stop on the hour. Convoy A arrives at the stop and is timed to depart at 1:00 - but because reversing takes 5 minutes, it is actually timed to depart at 0:55, at which point it will start reversing (loading all the while), and actually leave at the appointed 1:00.  Now suppose that convoy B arrives at 0:56, while convoy A is still reversing. Convoy B needs to leave at 1:55 (or 2:00 including reversing). If we do not take into account reversing convoys at a stop, however, convoy B will see that no other convoys are at the stop, and then take the next departure slot of 1:00 and promptly leave at the earliest possible time.

The difficulty seems to come in situations where convoy B arrives at exactly 1:00 - now, it should be assigned to the very next slot, but convoy A might be, during that second, still reversing, just about to change to finding a route. It is difficult to calculate any straightforward solution to this issue. The relevant code, incidentally, is in void convoi_t::hat_gehalten(halthandle_t halt).
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.

Jando

I have always wondered why convoys don't reverse before they wait for schedule. :)

As in arrive, off-load passengers/freight, reverse, load passengers/freight, wait for schedule or full-load.

jamespetts

Quote from: Jando on January 15, 2018, 11:42:08 PM
I have always wondered why convoys don't reverse before they wait for schedule. :)

As in arrive, off-load passengers/freight, reverse, load passengers/freight, wait for schedule or full-load.

That would not look right with trains, and might well be incompatible with future plans for convoy re-combination.
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.

DrSuperGood

#15
QuoteThat would not look right with trains, and might well be incompatible with future plans for convoy re-combination.
Trains usually reverse before waiting I thought... That way the engine is ready to depart in case of delays (not an outstanding task). Otherwise they will be reversing to a tight schedule which could delay departure times (on critical path).

I would much rather have the convoys start reversing on departure than trying to reverse before hand and messing up the scheduling of all other convoys by skipping a slot and assigning them a slot far in the future.

To be honest I am not even sure why it considers a reversing convoy when determining schedule slot. It should assign the entering convoy the next available schedule slot which is either {the last queued convoy slot + 1} or {slot after load time rounded up}. The convoy reverse time is then applied as an adjustment to that convoy departure time, and not the scheduled time slots. A button should be available to reset all scheduling in case a convoy is aborted from a slot due to line management reasons (only important with low frequency lines).

Edit:
Still broken... Tested on 16/01/2018.

jamespetts

Quote from: DrSuperGood on January 16, 2018, 12:31:56 AM
Trains usually reverse before waiting I thought... That way the engine is ready to depart in case of delays (not an outstanding task). Otherwise they will be reversing to a tight schedule which could delay departure times (on critical path).

This is not how things actually worked, as, very often, much shunting was needed; either the locomotive would have to move from one end of the train to another, or an entirely new locomotive would have to be put on the front of the train, and the one at the rear would have to wait until the train departed before going to the depot. Either way, whilst there was usually an allowance made to prevent this from being too tight for time, this was not generally done as the first thing after a train arrived at a station at the end of its journey before waiting a long time (possibly hours) before being dispatched for its next journey; rather, this was done shortly before the train was due to depart.

QuoteI would much rather have the convoys start reversing on departure than trying to reverse before hand and messing up the scheduling of all other convoys by skipping a slot and assigning them a slot far in the future.

This would be unworkable, as players would not be able to see when the convoys will depart (as it would be fundamentally unclear that reversing time would need to be added, making scheduling very difficult), and, in any event, differnet convoys have different reversing times.

QuoteTo be honest I am not even sure why it considers a reversing convoy when determining schedule slot. It should assign the entering convoy the next available schedule slot which is either {the last queued convoy slot + 1} or {slot after load time rounded up}. The convoy reverse time is then applied as an adjustment to that convoy departure time, and not the scheduled time slots. A button should be available to reset all scheduling in case a convoy is aborted from a slot due to line management reasons (only important with low frequency lines).

This was explained in detail in the above post. Was there anything that you did not understand from that explanation?

Quote
Edit:
Still broken... Tested on 16/01/2018.

I do not understand - I have not purported to change anything relating to this for the reasons already given (i.e, that I can see no reasonable solution). Can you elaborate?
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.

DrSuperGood

QuoteThis would be unworkable, as players would not be able to see when the convoys will depart (as it would be fundamentally unclear that reversing time would need to be added, making scheduling very difficult), and, in any event, differnet convoys have different reversing times.
It currently is unworkable. At least it would be more workable then...
QuoteThis was explained in detail in the above post. Was there anything that you did not understand from that explanation?
That this problem even exists in the first place. Why is reversing even coupled to the schedule period, it should be applied as an adjustment to the convoys not the departure slots.
QuoteI do not understand - I have not purported to change anything relating to this for the reasons already given (i.e, that I can see no reasonable solution). Can you elaborate?
But the thing is horribly broken... At least 7 lines of mine on the server suffer this problem, and as time progresses it seems to effect more and more.

jamespetts

Quote from: DrSuperGood on January 16, 2018, 09:41:06 PM
It currently is unworkable. At least it would be more workable then...

I do not think that this is correct; as far as I can tell (and it is very difficult to test because the only reproducable version is from the huge server game, which is so large that it can barely be speeded up using fast forward with debug mode; when I saved the game very shortly before the convoy waiting was due to depart, it ceased to be possible to reproduce this with it), the situation occurs in very marginal circumstances, viz. when another convoy arrives when there is a reversing convoy on the same schedule and it is exactly the right time for departure for that reversing convoy.

QuoteThat this problem even exists in the first place. Why is reversing even coupled to the schedule period, it should be applied as an adjustment to the convoys not the departure slots

I do not understand what you mean by "as an adjustment to the convoys". How precisely would this be distinct from the current arrangement?

QuoteBut the thing is horribly broken... At least 7 lines of mine on the server suffer this problem, and as time progresses it seems to effect more and more.

It is interesting that something that occurs in such marginal circumstances appears nonetheless to be frequent. It is not immediately clear why that should be. Perhaps these conditions are somehow created precisely when a road convoy is waiting to enter a stop occupied by another road convoy about to depart on the same schedule?

However, it is never the right approach to fix one thing by knowingly breaking another.
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.

jamespetts

I have been working on an interim fix for this until somebody can come up with a better algorithm that does not break anything else, which I have now pushed to the Github repository. In essence, if the convoy is a road vehicle, reversing convoys are ignored in setting the departure slot. This is because it is very unlikely that there would be any circumstances at a road stop at which one convoy would arrive while another is reversing where the arriving convoy should not be taking the next departure slot.

I should be very grateful for any feedback on whether this does work correctly without causing any other errors - if it does cause other errors and a suitable algorithm cannot be found, I may have to revert this.
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.

DrSuperGood

Seems to be working. Convoys no longer skip time slots as far as I can tell. However convoys still have the double booked time slot bug (different).