The International Simutrans Forum

 

Author Topic: Bug: Double scheduled wait times  (Read 2187 times)

0 Members and 1 Guest are viewing this topic.

Offline DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 2727
  • Languages: EN
Bug: Double scheduled wait times
« 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.
« Last Edit: January 22, 2018, 01:44:52 AM by DrSuperGood »

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18745
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Bug: Double scheduled wait times
« Reply #1 on: December 21, 2017, 01:14:34 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?

Offline DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 2727
  • Languages: EN
Re: Bug: Double scheduled wait times
« Reply #2 on: December 21, 2017, 01:39:53 AM »
Seems to effect a couple of lines, mostly road lines. Although I will check later if it is all of them.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18745
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Bug: Double scheduled wait times
« Reply #3 on: December 21, 2017, 01:45:11 AM »
Splendid, thank you: that is helpful.

Offline TurfIt

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 1326
Re: Bug: Double scheduled wait times
« Reply #4 on: December 21, 2017, 03:17:29 AM »
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

Offline DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 2727
  • Languages: EN
Re: Bug: Double scheduled wait times
« Reply #5 on: December 21, 2017, 04:10:04 AM »
Quote
Horses reversing and allowing another convoi into the stop when they do so?
Yup, terminal stops for coach line.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18745
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Bug: Double scheduled wait times
« Reply #6 on: January 08, 2018, 10:59:47 PM »
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.

Offline DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 2727
  • Languages: EN
Re: Bug: Double scheduled wait times
« Reply #7 on: January 09, 2018, 08:09:43 AM »
The lines appear to be waiting the scheduled time. As such it is probably fixed.

Offline DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 2727
  • Languages: EN
Re: Bug: Double scheduled wait times
« Reply #8 on: January 12, 2018, 07:25:17 AM »
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.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18745
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Bug: Double scheduled wait times
« Reply #9 on: January 12, 2018, 11:26:55 AM »
Can you let me know precisely where and when this can reliably be reproduced on the server?
« Last Edit: January 12, 2018, 07:59:00 PM by jamespetts »

Offline DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 2727
  • Languages: EN
Re: Bug: Double scheduled wait times
« Reply #10 on: January 13, 2018, 09:00:15 AM »
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.

Offline DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 2727
  • Languages: EN
Re: Bug: Double scheduled wait times
« Reply #11 on: January 15, 2018, 12:47:23 AM »
Still a problem. 44 minute waiting for departure instead of 24.

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

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18745
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Bug: Double scheduled wait times
« Reply #12 on: January 15, 2018, 11:29:31 PM »
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).

Offline Jando

  • *
  • Posts: 503
Re: Bug: Double scheduled wait times
« Reply #13 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.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18745
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Bug: Double scheduled wait times
« Reply #14 on: January 15, 2018, 11:48:31 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.

Offline DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 2727
  • Languages: EN
Re: Bug: Double scheduled wait times
« Reply #15 on: January 16, 2018, 12:31:56 AM »
Quote
That 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.
« Last Edit: January 16, 2018, 04:24:05 PM by DrSuperGood »

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18745
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Bug: Double scheduled wait times
« Reply #16 on: January 16, 2018, 09:33:24 PM »
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.

Quote
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.

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.

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

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?

Offline DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 2727
  • Languages: EN
Re: Bug: Double scheduled wait times
« Reply #17 on: January 16, 2018, 09:41:06 PM »
Quote
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.
It currently is unworkable. At least it would be more workable then...
Quote
This 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.
Quote
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?
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.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18745
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Bug: Double scheduled wait times
« Reply #18 on: January 16, 2018, 10:15:38 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.

Quote
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

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

Quote
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.

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.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18745
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Bug: Double scheduled wait times
« Reply #19 on: January 19, 2018, 01:54:47 AM »
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.

Offline DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 2727
  • Languages: EN
Re: Bug: Double scheduled wait times
« Reply #20 on: January 22, 2018, 01:45:34 AM »
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).