-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Concurrent segment detection #135
Comments
for h in highway_systems:
# h = usai
for r in h.route_list:
# r = pa.i376
for s in r.segment_list:
# s = [69A to 69B via pa.i376]
if s.waypoint1.colocated is not None and s.waypoint2.colocated is not None:
# True
for w1 in s.waypoint1.colocated:
# w1 = pa.us019@I-376(69A)
if w1.route is not r:
# w1.route = pa.us019; True
.-> for w2 in s.waypoint2.colocated:
| # w2 = pa.us019@I-376(69B)
| if w1.route is w2.route:
| # True
| other = w1.route.find_segment_by_waypoints(w1,w2)
| if other is not None:
| # other = [I-376(69A) to I-376(69B) via pa.us019]
| if s.concurrent is None:
| # First pass; True
| s.concurrent = []
| # empty list
| other.concurrent = s.concurrent
| # 2 empty lists, quantum entangled
| s.concurrent.append(s)
| # I-376 & US19 get I-376
| s.concurrent.append(other)
| # I-376 & US19 get US19
|__________________ concurrencyfile.write("New concurrency [" + str(s) + "][" + str(other) + "] (" + str(len(s.concurrent)) + ")\n")
else:
if other not in s.concurrent:
#
s.concurrent.append(other)
#
#concurrencyfile.write("Added concurrency [" + str(s) + "]-[" + str(other) + "] ("+ str(len(s.concurrent)) + ")\n")
concurrencyfile.write("Extended concurrency ")
for x in s.concurrent:
concurrencyfile.write("[" + str(x) + "]")
concurrencyfile.write(" (" + str(len(s.concurrent)) + ")\n")
|
for h in highway_systems:
# h = usai
for r in h.route_list:
# r = pa.i376
for s in r.segment_list:
# s = [69A to 69B via pa.i376]
if s.waypoint1.colocated is not None and s.waypoint2.colocated is not None:
# True
.-> for w1 in s.waypoint1.colocated:
| # w1 = pa.us019@I-376(69A)
| if w1.route is not r:
| # w1.route = pa.us019; True
| for w2 in s.waypoint2.colocated:
| # w2 = pa.us022@I-376(69B), pa.us030@I-376(69B), pa.us019trkpit@I-376(69B)_S, pa.us019trkpit@I-376(69B)_N
| if w1.route is w2.route:
|______________ # False for all remaining
other = w1.route.find_segment_by_waypoints(w1,w2)
if other is not None:
#
if s.concurrent is None:
#
s.concurrent = []
#
other.concurrent = s.concurrent
#
s.concurrent.append(s)
#
s.concurrent.append(other)
#
concurrencyfile.write("New concurrency [" + str(s) + "][" + str(other) + "] (" + str(len(s.concurrent)) + ")\n")
else:
if other not in s.concurrent:
#
s.concurrent.append(other)
#
#concurrencyfile.write("Added concurrency [" + str(s) + "]-[" + str(other) + "] ("+ str(len(s.concurrent)) + ")\n")
concurrencyfile.write("Extended concurrency ")
for x in s.concurrent:
concurrencyfile.write("[" + str(x) + "]")
concurrencyfile.write(" (" + str(len(s.concurrent)) + ")\n")
|
for h in highway_systems:
# h = usai
for r in h.route_list:
# r = pa.i376
for s in r.segment_list:
# s = [69A to 69B via pa.i376]
if s.waypoint1.colocated is not None and s.waypoint2.colocated is not None:
# True
.-> for w1 in s.waypoint1.colocated:
| # w1 = pa.us022@I-376(69A)
| if w1.route is not r:
| # w1.route = pa.us022; True
| .-> for w2 in s.waypoint2.colocated:
| | # w2 = pa.us022@I-376(69B)
| | if w1.route is w2.route:
|_______* # True for US22; false for all remaining
| other = w1.route.find_segment_by_waypoints(w1,w2)
| if other is not None:
| # other = [I-376(69A) to I-376(69B) via pa.us022]
| if s.concurrent is None:
| # False; received items in earlier pass
| s.concurrent = []
| #
| other.concurrent = s.concurrent
| #
| s.concurrent.append(s)
| #
| s.concurrent.append(other)
| #
| concurrencyfile.write("New concurrency [" + str(s) + "][" + str(other) + "] (" + str(len(s.concurrent)) + ")\n")
| else:
| if other not in s.concurrent:
| # True
| s.concurrent.append(other)
| # I-376 & US19 get US22
| #concurrencyfile.write("Added concurrency [" + str(s) + "]-[" + str(other) + "] ("+ str(len(s.concurrent)) + ")\n")
| concurrencyfile.write("Extended concurrency ")
| for x in s.concurrent:
| concurrencyfile.write("[" + str(x) + "]")
|______________________ concurrencyfile.write(" (" + str(len(s.concurrent)) + ")\n")
|
for h in highway_systems:
# h = usai
for r in h.route_list:
# r = pa.i376
for s in r.segment_list:
# s = [69A to 69B via pa.i376]
if s.waypoint1.colocated is not None and s.waypoint2.colocated is not None:
# True
.-> for w1 in s.waypoint1.colocated:
| # w1 = pa.us030@I-376(69A)
| if w1.route is not r:
| # w1.route = pa.us030; True
| .-> for w2 in s.waypoint2.colocated:
| | # w2 = pa.us030@I-376(69B)
| | if w1.route is w2.route:
|_______* # True for US30; false for all remaining
| other = w1.route.find_segment_by_waypoints(w1,w2)
| if other is not None:
| # other = [I-376(69A) to I-376(69B) via pa.us030]
| if s.concurrent is None:
| # False; received items in earlier pass
| s.concurrent = []
| #
| other.concurrent = s.concurrent
| #
| s.concurrent.append(s)
| #
| s.concurrent.append(other)
| #
| concurrencyfile.write("New concurrency [" + str(s) + "][" + str(other) + "] (" + str(len(s.concurrent)) + ")\n")
| else:
| if other not in s.concurrent:
| # True
| s.concurrent.append(other)
| # I-376 & US19 get US30
| #concurrencyfile.write("Added concurrency [" + str(s) + "]-[" + str(other) + "] ("+ str(len(s.concurrent)) + ")\n")
| concurrencyfile.write("Extended concurrency ")
| for x in s.concurrent:
| concurrencyfile.write("[" + str(x) + "]")
|______________________ concurrencyfile.write(" (" + str(len(s.concurrent)) + ")\n")
|
for h in highway_systems:
# h = usai
for r in h.route_list:
# r = pa.i376
for s in r.segment_list:
# s = [69A to 69B via pa.i376]
if s.waypoint1.colocated is not None and s.waypoint2.colocated is not None:
# True
for w1 in s.waypoint1.colocated:
# w1 = pa.us019trk@I-376(69A), and that's the last colocated point
if w1.route is not r:
# w1.route = pa.us019trk; True
.-> for w2 in s.waypoint2.colocated:
| # w2 = yadda, yadda, pa.us019trk@I-376(69B)_S ...
| if w1.route is w2.route:
| # True
| other = w1.route.find_segment_by_waypoints(w1,w2)
| if other is not None:
| # other = [I-376(69B)_S to I-376(69A) via pa.us019trkpit]
| if s.concurrent is None:
| # False; received items in earlier pass
| s.concurrent = []
| #
| other.concurrent = s.concurrent
| #
| s.concurrent.append(s)
| #
| s.concurrent.append(other)
| #
| concurrencyfile.write("New concurrency [" + str(s) + "][" + str(other) + "] (" + str(len(s.concurrent)) + ")\n")
| else:
| if other not in s.concurrent:
| # True
| s.concurrent.append(other)
| # I-376 & US19 get [I-376(69B)_S to I-376(69A) via pa.us019trkpit]
| #concurrencyfile.write("Added concurrency [" + str(s) + "]-[" + str(other) + "] ("+ str(len(s.concurrent)) + ")\n")
| concurrencyfile.write("Extended concurrency ")
| for x in s.concurrent:
| concurrencyfile.write("[" + str(x) + "]")
|______________________ concurrencyfile.write(" (" + str(len(s.concurrent)) + ")\n")
|
for h in highway_systems:
# h = usai
^ for r in h.route_list:
| # r = pa.i376, last Interstate we care about at this segment
| .-> for s in r.segment_list:
|___* # s = [69A to 69B via pa.i376], and then other I-376 segments we're not concerned with
| if s.waypoint1.colocated is not None and s.waypoint2.colocated is not None:
| # True
| for w1 in s.waypoint1.colocated:
| # w1 = pa.us019trk@I-376(69A), and that's the last colocated point
| if w1.route is not r:
| # w1.route = pa.us019trk; True
| for w2 in s.waypoint2.colocated:
| # w2 = pa.us019trk@I-376(69B)_N, and that's the last colocated point
| if w1.route is w2.route:
| # True
| other = w1.route.find_segment_by_waypoints(w1,w2)
| if other is not None:
| # other = [I-376(69A) to I-376(69B)_N via pa.us019trkpit]
| if s.concurrent is None:
| # False; received items in earlier pass
| s.concurrent = []
| #
| other.concurrent = s.concurrent
| #
| s.concurrent.append(s)
| #
| s.concurrent.append(other)
| #
| concurrencyfile.write("New concurrency [" + str(s) + "][" + str(other) + "] (" + str(len(s.concurrent)) + ")\n")
| else:
| if other not in s.concurrent:
| # True
| s.concurrent.append(other)
| # I-376 & US19 get [I-376(69A) to I-376(69B)_N via pa.us019trkpit]
| #concurrencyfile.write("Added concurrency [" + str(s) + "]-[" + str(other) + "] ("+ str(len(s.concurrent)) + ")\n")
| concurrencyfile.write("Extended concurrency ")
| for x in s.concurrent:
| concurrencyfile.write("[" + str(x) + "]")
|______________________________________ concurrencyfile.write(" (" + str(len(s.concurrent)) + ")\n")
|
for h in highway_systems:
# h = usaus
.-> for r in h.route_list:
| # r = pa.us019
| .-> for s in r.segment_list:
|___* # s = [I-376(69A) to I-376(69B) via pa.us019] etc.
| if s.waypoint1.colocated is not None and s.waypoint2.colocated is not None:
| # True
| for w1 in s.waypoint1.colocated:
| # w1 = pa.i376@69A, <pa.us019@I-376(69A)>, pa.us022@I-376(69A), pa.us030@I-376(69A), pa.us019trkpit@I-376(69A)
| if w1.route is not r:
| # True for all but pa.us019@I-376(69A)
| for w2 in s.waypoint2.colocated:
| # w2 = pa.i376@69B, pa.us019@I-376(69B), pa.us022@I-376(69B), pa.us030@I-376(69B), pa.us019trkpit@I-376(69B)_S, pa.us019trkpit@I-376(69B)_N
| if w1.route is w2.route:
| # True for I-376, US19, 22, 30, and True twice for US19Trk because it has two "w2"s
| other = w1.route.find_segment_by_waypoints(w1,w2)
| if other is not None:
| # other is not None:
| if s.concurrent is None:
| # False; received items in earlier pass
| s.concurrent = []
| #
| other.concurrent = s.concurrent
| #
| s.concurrent.append(s)
| #
| s.concurrent.append(other)
| #
| concurrencyfile.write("New concurrency [" + str(s) + "][" + str(other) + "] (" + str(len(s.concurrent)) + ")\n")
| else:
| if other not in s.concurrent:
|__________________________________ # False: s.concurrent was fully populated in previous pass; nothing else happens
s.concurrent.append(other)
#
#concurrencyfile.write("Added concurrency [" + str(s) + "]-[" + str(other) + "] ("+ str(len(s.concurrent)) + ")\n")
concurrencyfile.write("Extended concurrency ")
for x in s.concurrent:
concurrencyfile.write("[" + str(x) + "]")
concurrencyfile.write(" (" + str(len(s.concurrent)) + ")\n")
|
for h in highway_systems:
# h = usaus
for r in h.route_list:
# r = pa.us022
for s in r.segment_list:
# s = [I-376(69A) to I-376(69B) via pa.us022]
if s.waypoint1.colocated is not None and s.waypoint2.colocated is not None:
# True
for w1 in s.waypoint1.colocated:
# w1 = pa.us022@I-376(69A)
if w1.route is not r:
# w1.route = pa.us022; True
for w2 in s.waypoint2.colocated:
# w2 = pa.i376@69B
if w1.route is w2.route:
# True
other = w1.route.find_segment_by_waypoints(w1,w2)
if other is not None:
# other = [69A to 69B via pa.i376]
if s.concurrent is None:
# First pass for US22; True
s.concurrent = []
_______________________________________ # empty list _______________________________________
other.concurrent = s.concurrent
#
s.concurrent.append(s)
#
s.concurrent.append(other)
#
concurrencyfile.write("New concurrency [" + str(s) + "][" + str(other) + "] (" + str(len(s.concurrent)) + ")\n")
else:
if other not in s.concurrent:
#
s.concurrent.append(other)
#
#concurrencyfile.write("Added concurrency [" + str(s) + "]-[" + str(other) + "] ("+ str(len(s.concurrent)) + ")\n")
concurrencyfile.write("Extended concurrency ")
for x in s.concurrent:
concurrencyfile.write("[" + str(x) + "]")
concurrencyfile.write(" (" + str(len(s.concurrent)) + ")\n")
|
for h in highway_systems:
# h = usaus
for r in h.route_list:
# r = pa.us022
for s in r.segment_list:
# s = [I-376(69A) to I-376(69B) via pa.us022]
if s.waypoint1.colocated is not None and s.waypoint2.colocated is not None:
# True
for w1 in s.waypoint1.colocated:
# w1 = pa.us022@I-376(69A)
if w1.route is not r:
# w1.route = pa.us022; True
for w2 in s.waypoint2.colocated:
# w2 = pa.i376@69B
if w1.route is w2.route:
# True
other = w1.route.find_segment_by_waypoints(w1,w2)
if other is not None:
# other = [69A to 69B via pa.i376]
if s.concurrent is None:
# First pass for US22; True
s.concurrent = []
# empty list
other.concurrent = s.concurrent
_______________________________________ # The I-376 segment's list becomes empty too. Wait. Did we mean to do that? _______________________________________
s.concurrent.append(s)
#
s.concurrent.append(other)
#
concurrencyfile.write("New concurrency [" + str(s) + "][" + str(other) + "] (" + str(len(s.concurrent)) + ")\n")
else:
if other not in s.concurrent:
#
s.concurrent.append(other)
#
#concurrencyfile.write("Added concurrency [" + str(s) + "]-[" + str(other) + "] ("+ str(len(s.concurrent)) + ")\n")
concurrencyfile.write("Extended concurrency ")
for x in s.concurrent:
concurrencyfile.write("[" + str(x) + "]")
concurrencyfile.write(" (" + str(len(s.concurrent)) + ")\n")
|
for h in highway_systems:
# h = usaus
^ for r in h.route_list:
| # r = pa.us022
|___. for s in r.segment_list:
| # s = [I-376(69A) to I-376(69B) via pa.us022]
| if s.waypoint1.colocated is not None and s.waypoint2.colocated is not None:
| # True
|_______. for w1 in s.waypoint1.colocated:
| # w1 = pa.us022@I-376(69A)
| if w1.route is not r:
| # w1.route = pa.us022; True
|_______. for w2 in s.waypoint2.colocated:
| # w2 = pa.i376@69B
| if w1.route is w2.route:
| # True
| other = w1.route.find_segment_by_waypoints(w1,w2)
| if other is not None:
| # other = [69A to 69B via pa.i376]
| if s.concurrent is None:
| # First pass for US22; True
| s.concurrent = []
| # empty list
| other.concurrent = s.concurrent
| # I-376 segments' list empty too.
| s.concurrent.append(s)
| # I-376 & US22 get US22
| s.concurrent.append(other)
| # I-376 & US22 get I-376
|__________________ concurrencyfile.write("New concurrency [" + str(s) + "][" + str(other) + "] (" + str(len(s.concurrent)) + ")\n")
else:
if other not in s.concurrent:
#
s.concurrent.append(other)
#
#concurrencyfile.write("Added concurrency [" + str(s) + "]-[" + str(other) + "] ("+ str(len(s.concurrent)) + ")\n")
concurrencyfile.write("Extended concurrency ")
for x in s.concurrent:
concurrencyfile.write("[" + str(x) + "]")
concurrencyfile.write(" (" + str(len(s.concurrent)) + ")\n")
...and so on until the rest of the two lists are populated. |
for h in highway_systems:
# h = usausb
for r in h.route_list:
# r = pa.us019trkpit
for s in r.segment_list:
# s = [I-376(69B)_S to I-376(69A) via pa.us019trkpit]
if s.waypoint1.colocated is not None and s.waypoint2.colocated is not None:
# True
.-> for w1 in s.waypoint1.colocated:
| # w1 = pa.i376@69B, pa.us019@I-376(69B), pa.us022@I-376(69B), pa.us030@I-376(69B) ...
| if w1.route is not r:
| # True for I-376, US19, US22, US30
| for w2 in s.waypoint2.colocated:
| # w2 = pa.i376@69A, pa.us019@I-376(69A), pa.us022@I-376(69A), pa.us030@I-376(69A) ...
| if w1.route is w2.route:
| # True once for each
| other = w1.route.find_segment_by_waypoints(w1,w2)
| if other is not None:
| # other is not None:
| if s.concurrent is None:
| # First pass for [I-376(69B)_S to I-376(69A) via pa.us019trkpit] True; subsequent passes false
| s.concurrent = []
| # empty list
| other.concurrent = s.concurrent
| # 1st pass: I-376 segments' list empty too.
| s.concurrent.append(s)
| # 1st pass: I-376 & TrkS get TrkS
| s.concurrent.append(other)
| # 1st pass: I-376 & TrkS get I-376
| concurrencyfile.write("New concurrency [" + str(s) + "][" + str(other) + "] (" + str(len(s.concurrent)) + ")\n")
| else:
| if other not in s.concurrent:
| #
| s.concurrent.append(other)
| # 2nd+ passes: I-376 & TrkS get US19, 22, 30
| #concurrencyfile.write("Added concurrency [" + str(s) + "]-[" + str(other) + "] ("+ str(len(s.concurrent)) + ")\n")
| concurrencyfile.write("Extended concurrency ")
| for x in s.concurrent:
| concurrencyfile.write("[" + str(x) + "]")
|______________________________ concurrencyfile.write(" (" + str(len(s.concurrent)) + ")\n")
|
for h in highway_systems:
# h = usausb
for r in h.route_list:
# r = pa.us019trkpit
.-> for s in r.segment_list:
| # s = [I-376(69B)_S to I-376(69A) via pa.us019trkpit]
| if s.waypoint1.colocated is not None and s.waypoint2.colocated is not None:
| # True
| for w1 in s.waypoint1.colocated:
| # w1 = ... pa.us019trkpit@I-376(69B)_S, pa.us019trkpit@I-376(69B)_N
| if w1.route is not r:
|______________ # w1.route is r for both remaining points; nothing else happens; concurrency remains at 5 routes
for w2 in s.waypoint2.colocated:
#
if w1.route is w2.route:
#
other = w1.route.find_segment_by_waypoints(w1,w2)
if other is not None:
#
if s.concurrent is None:
#
s.concurrent = []
#
other.concurrent = s.concurrent
#
s.concurrent.append(s)
#
s.concurrent.append(other)
#
concurrencyfile.write("New concurrency [" + str(s) + "][" + str(other) + "] (" + str(len(s.concurrent)) + ")\n")
else:
if other not in s.concurrent:
#
s.concurrent.append(other)
#
#concurrencyfile.write("Added concurrency [" + str(s) + "]-[" + str(other) + "] ("+ str(len(s.concurrent)) + ")\n")
concurrencyfile.write("Extended concurrency ")
for x in s.concurrent:
concurrencyfile.write("[" + str(x) + "]")
concurrencyfile.write(" (" + str(len(s.concurrent)) + ")\n")
...Finally we test the one last segment, [I-376(69A) to I-376(69B)_N via pa.us019trkpit].
...which we can see in concurrencies.log. |
Why the differences in concurrencies.log?One more line sometimes, in concurrency detection:
We see this on line 114911 of Why we have 18 more augments for the travelers .listing only the I-376 segment:
As noted in the OP, adding a single What if US19TrkPit is tested first?Shouldn't be a problem. 5 concurrencies will be detected in the first pass. On the second pass, when checking a different route, all 6 concurrencies will be found. The 6th one, newly detected, will be added to all the lists. Yeah man. I'm gonna try this out! |
Wow, thanks for the epic debugging session. If this works (or even if not) I hereby award you TM's first ever Excellence in Finding Insidious Bugs award, and all the rights, privileges, and responsibilities appertaining thereto. |
🥇 |
This is in fact what happens.
Thus in concurrencies.log we see:
...and then several thousand lines later,
To emphasize, this does not harm anything (Again, 6 segments, 6 lists listing 6 segments). It just makes concurrencies.log look a little ugly. If I really wanted to, I could change the innermost IF statement: if s.concurrent is None:
if other.concurrent is None:
s.concurrent = []
other.concurrent = s.concurrent
s.concurrent.append(s)
s.concurrent.append(other)
concurrencyfile.write("New concurrency [" + str(s) + "][" + str(other) + "] (" + str(len(s.concurrent)) + ")\n")
else: # the very unusual case of a route colocated with itself, such as PA US19TrkPit
s.concurrent = other.concurrent
s.concurrent.append(s)
concurrencyfile.write("Extended concurrency ")
for x in s.concurrent:
concurrencyfile.write("[" + str(x) + "]")
concurrencyfile.write(" (" + str(len(s.concurrent)) + ")\n") but this is unnecessary; the concurrencies are detected either way. All it gets us is a prettier concurrencies.log:
...all together in one cluster. Nope. I'll open a pull request once I have Thanksgiving out of the way. |
Some background info: Re: PA: US 19 Truck (Pittsburgh)
http://forum.travelmapping.net/index.php?topic=316.msg12112#msg12112
TL;DR:
Search for
Wait. Did we mean to do that?
, in the 9th response below.may be what we need. It should link up segments beyond just the 2nd one with the 1st segment's concurrency list, and prevent erasing the 1st segment's list followed by needlessly re-detecting its concurrencies.
The text was updated successfully, but these errors were encountered: