Upcoming Games

No games to display

Full list
Add a game

Upcoming Events

No events to display

Who's Online

flabberdacks, Al McLean, geswedey, Jriver (4 users seen recently)

Problem with Alternatives Rule and non-unique UIDs

You are here: Home > Forum > General > General questions, comments, and issues > Problem with Alternatives Rule and non-unique UIDs

Page 1 of 2

Problem with Alternatives Rule and non-unique UIDs 04/11/2016 at 22:27 #87203
Lyn-Greenwood
Avatar
239 posts
Several WTTs, including some supplied as part of a sim package, have trains that re-enter the simulation following a layover in a Yard. There are normally Rules set up to ensure that the train does not re-enter until a sensible time after the initial train exits the simulation. The 2nd instance of the train is normally allocated the same TD/UID pair as the initial train. This all seems to work OK unless the train is included in an Alternatives list in the WTT Rules. In these cases, if the first instance of the train is selected to run, the 2nd instance never re-enters the sim. Sometimes the 2nd instance of the train is selected to run and it enters the sim even though the first instance didn't run. In this latter case the Rule associating the 2nd train's entry time with the 1st train's exit time is totally ignored, presumably because the 1st train didn't run. As an example, the Leeds East/West 15-Oct-09 WTT has three 6E72 trains that exhibit the above behaviour.

I've found that the only way round the problem is to allocate a suffix to the UID of the 2nd train which makes it truly unique, but this will almost certainly cause problems when sims are chained.

Has anyone come across this problem and found a solution? I've got a proposal to fix the problem which will also allow chaining to work correctly, but will wait to see if anyone comes up with a solution.

Log in to reply
Problem with Alternatives Rule and non-unique UIDs 05/11/2016 at 17:03 #87206
Jan
Avatar
892 posts
There's also a related problem in that there is no guarantee that the trains will enter in the correct order: If the first instance of the timetable is running late and/or the second one early, the second instance can actually enter the sim first, with the "Must appear X minutes after Y leaves the area" rule being applied the wrong way round (see Mantis 14574).
Two million people attempt to use Birmingham's magnificent rail network every year, with just over a million of them managing to get further than Smethwick.
Log in to reply
Problem with Alternatives Rule and non-unique UIDs 05/11/2016 at 18:20 #87207
Lyn-Greenwood
Avatar
239 posts
Jan in post 87206 said:
There's also a related problem in that there is no guarantee that the trains will enter in the correct order: If the first instance of the timetable is running late and/or the second one early, the second instance can actually enter the sim first, with the "Must appear X minutes after Y leaves the area" rule being applied the wrong way round (see Mantis 14574).
I don't have access to Mantis, unfortunately, but I'm not surprised at the behaviour. I've always wondered how the Rules code decides what to do when the two trains in a Rule have the same TD/UID pair. How does it decide which train is which in these circumstances?

One solution might be to allocate an additional unique internal UID to each train in the timetable and use this internal UID for all Rules decisions. This would allow the original (or external) UID to remain unchanged so that chaining will not be affected, but I'm sure the coding gurus will come up with a much simpler solution.

Log in to reply
Problem with Alternatives Rule and non-unique UIDs 05/11/2016 at 23:18 #87214
GeoffM
Avatar
6292 posts
Lyn-Greenwood in post 87207 said:
Jan in post 87206 said:
There's also a related problem in that there is no guarantee that the trains will enter in the correct order: If the first instance of the timetable is running late and/or the second one early, the second instance can actually enter the sim first, with the "Must appear X minutes after Y leaves the area" rule being applied the wrong way round (see Mantis 14574).
I don't have access to Mantis, unfortunately, but I'm not surprised at the behaviour. I've always wondered how the Rules code decides what to do when the two trains in a Rule have the same TD/UID pair. How does it decide which train is which in these circumstances?

One solution might be to allocate an additional unique internal UID to each train in the timetable and use this internal UID for all Rules decisions. This would allow the original (or external) UID to remain unchanged so that chaining will not be affected, but I'm sure the coding gurus will come up with a much simpler solution.
Some kind of suffix that is not transmitted to a chained simulation sounds a good idea. Thanks.

SimSig Boss
Log in to reply
Problem with Alternatives Rule and non-unique UIDs 05/11/2016 at 23:45 #87215
Sacro
Avatar
1171 posts
GeoffM in post 87214 said:
Lyn-Greenwood in post 87207 said:
Jan in post 87206 said:
There's also a related problem in that there is no guarantee that the trains will enter in the correct order: If the first instance of the timetable is running late and/or the second one early, the second instance can actually enter the sim first, with the "Must appear X minutes after Y leaves the area" rule being applied the wrong way round (see Mantis 14574).
I don't have access to Mantis, unfortunately, but I'm not surprised at the behaviour. I've always wondered how the Rules code decides what to do when the two trains in a Rule have the same TD/UID pair. How does it decide which train is which in these circumstances?

One solution might be to allocate an additional unique internal UID to each train in the timetable and use this internal UID for all Rules decisions. This would allow the original (or external) UID to remain unchanged so that chaining will not be affected, but I'm sure the coding gurus will come up with a much simpler solution.
Some kind of suffix that is not transmitted to a chained simulation sounds a good idea. Thanks.
Rather than using a suffix, can't you just use the UID and sort by simulation entry time?

Log in to reply
Problem with Alternatives Rule and non-unique UIDs 06/11/2016 at 04:35 #87221
GeoffM
Avatar
6292 posts
Quote:
Rather than using a suffix, can't you just use the UID and sort by simulation entry time?
Because that only solves one of the 2 (or more?) issues here. On phone so don't have details but look on Mantis for my initial thoughts.

SimSig Boss
Last edited: 06/11/2016 at 04:37 by GeoffM
Reason: Quoting

Log in to reply
Problem with Alternatives Rule and non-unique UIDs 06/11/2016 at 12:04 #87227
Jan
Avatar
892 posts
Sacro in post 87215 said:
Rather than using a suffix, can't you just use the UID and sort by simulation entry time?

I thought about that as well, but in the case where a train leaves and reenters the same sim more than once, this means that you have to have more than one "Must appear X minutes after Y leaves the area" rule, which means there's no way of unambiguously matching the correct rule to the correct instances of the same UID. Even if rules could be directly attached to a train's timetable data (which I seem to remember was the long-term intention at some point), it would still be difficult to work out which of the multiple trains sharing a UID is supposed to be "Train Y" within the context of the rule.

Having said that, I guess that just two trains and one rule is still the most common case and your idea (trains sharing the same UID have to enter in booked order) has the charm of fixing that case without requiring any existing timetables to be modified.

Two million people attempt to use Birmingham's magnificent rail network every year, with just over a million of them managing to get further than Smethwick.
Log in to reply
Problem with Alternatives Rule and non-unique UIDs 07/11/2016 at 12:31 #87241
Lyn-Greenwood
Avatar
239 posts
Jan in post 87227 said:
Sacro in post 87215 said:
Rather than using a suffix, can't you just use the UID and sort by simulation entry time?

I thought about that as well, but in the case where a train leaves and reenters the same sim more than once, this means that you have to have more than one "Must appear X minutes after Y leaves the area" rule, which means there's no way of unambiguously matching the correct rule to the correct instances of the same UID. Even if rules could be directly attached to a train's timetable data (which I seem to remember was the long-term intention at some point), it would still be difficult to work out which of the multiple trains sharing a UID is supposed to be "Train Y" within the context of the rule.

Having said that, I guess that just two trains and one rule is still the most common case and your idea (trains sharing the same UID have to enter in booked order) has the charm of fixing that case without requiring any existing timetables to be modified.
That approach won't fix the problem of the Alternatives Rule choosing the 2nd instance of a train as the one which should run (i.e. the train exits a Yard before it has arrived there, which it never will, of course).

If a secondary UID were to be used for Rules purposes, then this could default to the primary UID with a box being provided in the tt editor to enter an overriding value. Doing it this way would allow existing WTTs to behave exactly as they do now, but would allow users and/or tt writers to provide a secondary UID if they so wished.

By the way, while checking out the Rules behaviour I discovered that if a train is to depart a Yard late owing to a Rule enforcement, then the shunter rings for 'Permission to leave Yard' at the original scheduled departure time, not the modified time. I've even had a shunter ringing for permission before the original train had arrived at the Yard. If this hasn't already been reported, please add the issue to the Mantis system.

Last edited: 07/11/2016 at 12:33 by Lyn-Greenwood
Reason: Typo

Log in to reply
Problem with Alternatives Rule and non-unique UIDs 07/11/2016 at 14:11 #87242
Jan
Avatar
892 posts
No objection there - I was just thinking out loud that additionally implementing sacro's suggestion in addition to any suffixes could fix part of the problem without requiring existing timetables to be rewritten in order to benefit. But obviously a complete solution for all future (and updated) timetables is required, too.

Lyn-Greenwood in post 87241 said:
By the way, while checking out the Rules behaviour I discovered that if a train is to depart a Yard late owing to a Rule enforcement, then the shunter rings for 'Permission to leave Yard' at the original scheduled departure time, not the modified time. I've even had a shunter ringing for permission before the original train had arrived at the Yard. If this hasn't already been reported, please add the issue to the Mantis system.

Somebody's reported it already a while back (#15570) and I've noticed it myself in Tyneside.

Two million people attempt to use Birmingham's magnificent rail network every year, with just over a million of them managing to get further than Smethwick.
Log in to reply
The following user said thank you: Lyn-Greenwood
Problem with Alternatives Rule and non-unique UIDs 10/11/2016 at 21:11 #87272
Guts
Avatar
587 posts
Sorry to jump on this late. This issue with the same UID has a simple but long-winded, albeit short-term, solution.

What I found is how the UID is allocated when the rule is set up.

Basically the 2nd train is being allocated the 1st train's UID code. When you scroll through the listings of a train, BOTH UID are in the list BUT the one assigned to the Rule is taking the wrong UID.
When you click the dropdown, they both show the 1st iteration of the UID in both separate boxes, when the 1st dropdown should be referencing the 2nd UID, as the Rules start with the 2nd train's entry , followed by the train it's entering after (train Y)

I hope this helps all.

Log in to reply
Problem with Alternatives Rule and non-unique UIDs 11/11/2016 at 08:17 #87275
Lyn-Greenwood
Avatar
239 posts
Guts in post 87272 said:
Sorry to jump on this late. This issue with the same UID has a simple but long-winded, albeit short-term, solution.

What I found is how the UID is allocated when the rule is set up.

Basically the 2nd train is being allocated the 1st train's UID code. When you scroll through the listings of a train, BOTH UID are in the list BUT the one assigned to the Rule is taking the wrong UID.
When you click the dropdown, they both show the 1st iteration of the UID in both separate boxes, when the 1st dropdown should be referencing the 2nd UID, as the Rules start with the 2nd train's entry , followed by the train it's entering after (train Y)

I hope this helps all.
I don't really understand what you are getting at here. Will you please explain in more detail? What do you mean by "scroll through the listings of a train" for instance?

Log in to reply
Problem with Alternatives Rule and non-unique UIDs 11/11/2016 at 09:24 #87276
postal
Avatar
5197 posts
When you are setting up the rule, you either manually enter the TD or UID for a train (in which case the first train fitting that description in the TT is selected unless you manually intervene) or you pick from a drop-down list. If there are two (or more) trains with the same TD/UID combination, they will show as 2 separate but adjacent entries in the drop-down.

I think Guts is telling us that you need to take care about which train you select from the drop-down. As far as I am aware, the drop-down sorts things in the same order as the listing by TD in F4. So if you have 1A00/$XXXX going off sim and re-entering giving you two instances of 1A00/$XXXX in the TT you need to be careful which of the two is selected when writing the rule.

If you want a rule that the train must not re-enter until Z minutes after it leaves the sim (Train B must not enter until Z minutes after Train A leaves the area), you need to make sure by reference to the TT which in the list of two entries is Train A and which is Train B. Then you have to pick the correct item from the Rules drop-down for each of Train A and Train B rather than just clicking on the first item in the list each time.

Apologies to Guts and Lyn if I've got that wrong, but it is something I've had to be careful about at some stage in the distant past when the situation arose in a TT with which I was tinkering.

“In life, there is always someone out there, who won’t like you, for whatever reason, don’t let the insecurities in their lives affect yours.” – Rashida Rowe
Last edited: 11/11/2016 at 09:24 by postal
Reason: edit

Log in to reply
The following user said thank you: Lyn-Greenwood
Problem with Alternatives Rule and non-unique UIDs 12/11/2016 at 14:29 #87306
Lyn-Greenwood
Avatar
239 posts
postal in post 87276 said:
When you are setting up the rule, you either manually enter the TD or UID for a train (in which case the first train fitting that description in the TT is selected unless you manually intervene) or you pick from a drop-down list. If there are two (or more) trains with the same TD/UID combination, they will show as 2 separate but adjacent entries in the drop-down.

I think Guts is telling us that you need to take care about which train you select from the drop-down. As far as I am aware, the drop-down sorts things in the same order as the listing by TD in F4. So if you have 1A00/$XXXX going off sim and re-entering giving you two instances of 1A00/$XXXX in the TT you need to be careful which of the two is selected when writing the rule.

If you want a rule that the train must not re-enter until Z minutes after it leaves the sim (Train B must not enter until Z minutes after Train A leaves the area), you need to make sure by reference to the TT which in the list of two entries is Train A and which is Train B. Then you have to pick the correct item from the Rules drop-down for each of Train A and Train B rather than just clicking on the first item in the list each time.

Apologies to Guts and Lyn if I've got that wrong, but it is something I've had to be careful about at some stage in the distant past when the situation arose in a TT with which I was tinkering.
I've thought about this in a little more depth and realised that even if you pick the correct instance of a non-unique TD/UID pair, the wrong train may still get chosen when the Rule is applied as the Rule (when saved in the WTT)refers to trains by their UID only. I assume that when the Rule is applied the list of trains is searched in chronological order and the first train with the correct UID is chosen. This would explain why the 2nd instance of a train can wrongly appear if the 1st instance is running very late.

As I said in my initial post, I believe that using a secondary suffixed UID for Rules decisions would solve the various problems. Maybe Geoff could add his thoughts to this discussion?

Log in to reply
Problem with Alternatives Rule and non-unique UIDs 12/11/2016 at 16:50 #87309
postal
Avatar
5197 posts
As an alternative, could the creation of a new entry in the TT automatically grant a serial number so that no operator input would be required. It would probably need things like the Rules set-up screen to allow for selection by TD, UID or serial and I've no idea how complex that would be. However, you would have to do something similar if using a suffixed UID.

Presumably the generation of a serial number could be coded to happen automatically for a manual TT entry. I've no idea how complex it would be from a CIF download but if it could be done it would de-risk things by removing the opportunity for operator error when inputting a new suffixed UID.

“In life, there is always someone out there, who won’t like you, for whatever reason, don’t let the insecurities in their lives affect yours.” – Rashida Rowe
Last edited: 12/11/2016 at 17:00 by postal
Reason: edit

Log in to reply
Problem with Alternatives Rule and non-unique UIDs 12/11/2016 at 17:13 #87310
Lyn-Greenwood
Avatar
239 posts
postal in post 87309 said:
As an alternative, could the creation of a new entry in the TT automatically grant a serial number so that no operator input would be required. It would probably need things like the Rules set-up screen to allow for selection by TD, UID or serial and I've no idea how complex that would be. However, you would have to do something similar if using a suffixed UID.

Presumably the generation of a serial number could be coded to happen automatically for a manual TT entry. I've no idea how complex it would be from a CIF download but if it could be done it would de-risk things by removing the opportunity for operator error when inputting a new suffixed UID.
My idea was to let the suffixed UID default to the normal UID (as supplied in CIF downloads), but give the user/tt-writer the ability to change it on the tt Edit Screen if this was found to be necessary. The Rules Set-up Screen would just show the TD/Suffixed_UID, so minimal changes needed there. I'd like to hear what Geoff has to say about this approach.

Log in to reply
Problem with Alternatives Rule and non-unique UIDs 12/11/2016 at 18:12 #87313
GeoffM
Avatar
6292 posts
I have some reservations about a suffix or some other way of identifying problem scenarios. I'm not against them but don't want to jump in and implement something that then becomes a problem in itself. FWIW I would not expect to need to alter any existing timetables, only if the author wishes to fix some scenario.

We need a way of both telling the second portion of a train going into a yard and re-appearing some time later to always appear, and having alternates work better. If nobody can foresee issues then we can move ahead and make it a reality in the near future.

One thing this doesn't address is where you have sims A and B feeding into sim C, where a train will only ever run A-C or B-C, but never both on the same day (actual instance dictated by day-to-day demand, such as coal traffic). Sim A doesn't know that sim B is sending its version of the train, and vice versa. Their timings through C are the same, ie they share the same timetable path for part of their journey. There was talk some time ago of a master timetable server that would decide on things like this but it's a big task.

SimSig Boss
Log in to reply
Problem with Alternatives Rule and non-unique UIDs 13/11/2016 at 09:28 #87315
postal
Avatar
5197 posts
Lyn-Greenwood in post 87310 said:
My idea was to let the suffixed UID default to the normal UID (as supplied in CIF downloads), but give the user/tt-writer the ability to change it on the tt Edit Screen if this was found to be necessary.
Would that cause a problem if sims were chained and the TT writers for the two sims had used different suffixes for the same train - or does the chaining allow for a bit of fuzzy logic to pick a best fit?

“In life, there is always someone out there, who won’t like you, for whatever reason, don’t let the insecurities in their lives affect yours.” – Rashida Rowe
Log in to reply
Problem with Alternatives Rule and non-unique UIDs 13/11/2016 at 21:38 #87327
Jan
Avatar
892 posts
GeoffM in post 87313 said:
FWIW I would not expect to need to alter any existing timetables, only if the author wishes to fix some scenario.
Certainly - I didn't mean for any changes that would actually break existing timetables. I was just trying to say that some solutions might become effective immediately after being implemented in the core code, while others would only be effective after the timetable has been updated in order to take advantage of some new feature (and if the timetable isn't updated, it continues to work just as before).

Two million people attempt to use Birmingham's magnificent rail network every year, with just over a million of them managing to get further than Smethwick.
Log in to reply
Problem with Alternatives Rule and non-unique UIDs 14/11/2016 at 04:51 #87338
GeoffM
Avatar
6292 posts
Jan in post 87327 said:
GeoffM in post 87313 said:
FWIW I would not expect to need to alter any existing timetables, only if the author wishes to fix some scenario.
Certainly - I didn't mean for any changes that would actually break existing timetables. I was just trying to say that some solutions might become effective immediately after being implemented in the core code, while others would only be effective after the timetable has been updated in order to take advantage of some new feature (and if the timetable isn't updated, it continues to work just as before).
Sorry - I think I must have either misread something earlier or confused it with another thread.

SimSig Boss
Log in to reply
Problem with Alternatives Rule and non-unique UIDs 14/11/2016 at 11:33 #88341
GeoffM
Avatar
6292 posts
KymriskaDraken in post 88339 said:
GeoffM in post 87313 said:


One thing this doesn't address is where you have sims A and B feeding into sim C, where a train will only ever run A-C or B-C, but never both on the same day (actual instance dictated by day-to-day demand, such as coal traffic). Sim A doesn't know that sim B is sending its version of the train, and vice versa. Their timings through C are the same, ie they share the same timetable path for part of their journey. There was talk some time ago of a master timetable server that would decide on things like this but it's a big task.
That is fairly easy to sort out. Assuming that sims A & B use a decision to decide if they are going to run the train or not then that decision could be forced if A, B and C are chained.
How does A know via C that B has sent its version, or not, and vice versa?

SimSig Boss
Log in to reply
Problem with Alternatives Rule and non-unique UIDs 14/11/2016 at 19:14 #88339
KymriskaDraken
Avatar
963 posts
GeoffM in post 87313 said:


One thing this doesn't address is where you have sims A and B feeding into sim C, where a train will only ever run A-C or B-C, but never both on the same day (actual instance dictated by day-to-day demand, such as coal traffic). Sim A doesn't know that sim B is sending its version of the train, and vice versa. Their timings through C are the same, ie they share the same timetable path for part of their journey. There was talk some time ago of a master timetable server that would decide on things like this but it's a big task.
That is fairly easy to sort out. Assuming that sims A & B use a decision to decide if they are going to run the train or not then that decision could be forced if A, B and C are chained.

Kev

Log in to reply
Problem with Alternatives Rule and non-unique UIDs 14/11/2016 at 22:34 #88346
Lyn-Greenwood
Avatar
239 posts
postal in post 87315 said:
Lyn-Greenwood in post 87310 said:
My idea was to let the suffixed UID default to the normal UID (as supplied in CIF downloads), but give the user/tt-writer the ability to change it on the tt Edit Screen if this was found to be necessary.
Would that cause a problem if sims were chained and the TT writers for the two sims had used different suffixes for the same train - or does the chaining allow for a bit of fuzzy logic to pick a best fit?
The only UID that would be passed to a chained sim is the original (i.e. external) UID. Any suffixed UID used in a particular WTT would only be seen by the sim loading that timetable/saved-session (i.e. an internal UID that is only used for Rules decisions). For all Rules decisions, if a suffixed UID exists in a train's data, then it is used, otherwise the external UID is used. This is why existing timetables/saved-sessions would work as they do now without any changes being required, but any Rules problems caused by trains having duplicate TD/UID pairs could be overcome by assigning an additional unique suffixed UID to the second and subsequent instances of those trains.

I trust all the above makes sense.

Log in to reply
Problem with Alternatives Rule and non-unique UIDs 15/11/2016 at 05:21 #88354
GeoffM
Avatar
6292 posts
Apologies with the apparent misordering of my reply to Kymriska's post. I forgot I was replying on my local machine which is 8 hours behind GMT and... uh, too difficult to explain but not a bug as such.
SimSig Boss
Log in to reply
Problem with Alternatives Rule and non-unique UIDs 15/11/2016 at 18:11 #88364
KymriskaDraken
Avatar
963 posts
GeoffM in post 88341 said:
KymriskaDraken in post 88339 said:
GeoffM in post 87313 said:


One thing this doesn't address is where you have sims A and B feeding into sim C, where a train will only ever run A-C or B-C, but never both on the same day (actual instance dictated by day-to-day demand, such as coal traffic). Sim A doesn't know that sim B is sending its version of the train, and vice versa. Their timings through C are the same, ie they share the same timetable path for part of their journey. There was talk some time ago of a master timetable server that would decide on things like this but it's a big task.
That is fairly easy to sort out. Assuming that sims A & B use a decision to decide if they are going to run the train or not then that decision could be forced if A, B and C are chained.
How does A know via C that B has sent its version, or not, and vice versa?
I would have thought that the hosts of the sims involved would speak to each other about such things.


Kev

Log in to reply
Problem with Alternatives Rule and non-unique UIDs 15/11/2016 at 18:39 #88365
headshot119
Avatar
4869 posts
KymriskaDraken in post 88364 said:
GeoffM in post 88341 said:
KymriskaDraken in post 88339 said:
GeoffM in post 87313 said:


One thing this doesn't address is where you have sims A and B feeding into sim C, where a train will only ever run A-C or B-C, but never both on the same day (actual instance dictated by day-to-day demand, such as coal traffic). Sim A doesn't know that sim B is sending its version of the train, and vice versa. Their timings through C are the same, ie they share the same timetable path for part of their journey. There was talk some time ago of a master timetable server that would decide on things like this but it's a big task.
That is fairly easy to sort out. Assuming that sims A & B use a decision to decide if they are going to run the train or not then that decision could be forced if A, B and C are chained.
How does A know via C that B has sent its version, or not, and vice versa?
I would have thought that the hosts of the sims involved would speak to each other about such things.


Kev
It's nothing to do with the hosts.

Let's assume we have a train that has two different schedules. This train will be 1Z99.

On Saltley it enters at some location (1Z99-Saltley)
On Coventry it enters at some location (1Z99-Coventry)

How does Leamington know which version is coming in, and how does Coventry know not to enter it if Saltley already has.

"Passengers for New Lane, should be seated in the rear coach of the train " - Opinions are my own and not those of my employer
Log in to reply