Skip to content
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

label simplification at loop endpoints #260

Open
yakra opened this issue Nov 19, 2019 · 8 comments
Open

label simplification at loop endpoints #260

yakra opened this issue Nov 19, 2019 · 8 comments
Assignees

Comments

@yakra
Copy link
Contributor

yakra commented Nov 19, 2019

# TODO: I-610@TX288&I-610@38&TX288@I-610
# this is the overlap point of a loop

// TODO: I-610@TX288&I-610@38&TX288@I-610
// this is the overlap point of a loop

A shell script to help find examples:

lines=`egrep "^Keep failsafe: .*@.*&.*@.*&.*@.*" \
         waypointsimplification.log \
       | egrep -v '@[A-Z]+/[A-Z]+$' \
       | cut -f3 -d' '`
echo -n 'NumLines: '
echo $lines | wc -w
for line in $lines; do
  routes='%'
  points=`echo $line | tr '&' ' '`
  for point in $points; do
    route=`echo $point | cut -f1 -d@`
    label=`echo $point | cut -f2 -d@`
    if [[ `echo $routes | egrep "^$route$|^$route | $route$"` == $routes ]]; then
      echo $line
      break
    fi
    routes=`echo $routes $route`
  done
done

...and the 67 examples it finds:

A118@KroSho_E&A118@KroSho_W&KAD@KroSho_E&KAD@KroSho_W
MR@SkovAll_E&OSae@FreVej_N&OSae@SkovAll_E
PR35@DroGade&OHjo@PR35&OHjo@PR35_W
AH6@1(MKAD)&AH8@1(MKAD)&E115@1(MKAD)&E22@1(MKAD)&M7@MKAD&MKAD@1&MKAD@M7
M09@R1_E&M09@R1_W&MinKobAut@M9&MKAD@R1_E&MKAD@R1_W
MROde@HoeGulGade&SR451@HoeGulGade&O1Hor@HoeGulGade_E&O1Hor@HoeGulGade_W
SR195@FonGade&OHer@SR195&OHer@SR195_E
MROde@KobGade_N&OFre@KobGade_N&OFre@PriGade_E
MR@O_KolW&SR191@VejVej_S&OKol@SR191&OKol@SR191_W
CenRingArn@N224_E&CenRingArn@N224_W&N224@CenRing
A4@1&E411@R0&N4@R0&R0@E411/A4_N&R0@E411/A4_S
N424@R4&R4@1&R4@N424
N43Mou@R43&R36@N43_S&R36@N43_W
B38@GoeStr&BBMR@GoeStr_N&BBMR@GoeStr_S
B3@ForStr&BBMR@B3_E&BBMR@ForStr
A54@27&E420@27(A54)&E420Cha@27(R9)&R9@27E&R9@27O
D913-92@N1013&D993-92@N1013_E&D993-92@N1013_W&N1013@D913/D993
D344-77@D344P_E&D344-77@D344P_W&D344P-77@D344
A4@BlvdPer&BP@A4_N&BP@A4_S&E15@A4&E50@A4/BlvdPer
G4501@1&G4501@G45&G45Miy@9
AH1@48A(Ex1)&Ex1@48A&Ex100@1&Ex100@Ex1
G2501@1&G2501@G25_N&G25Nan@1(G2501)
AH1@G1501_E&AH1She@G4/G15&G4@2150&G1501@G4_E&G1501@G4_W&G15@18(G1501)
G1501@S21&G98@S21_E&G98@S21_W
AH1@O4/O20&E88Ank@1(O20)&E89@O4/O20&O4@O20&O20@1&O20@O4
SS613@SS694&SS694@1&SS694@SS613
SS16Bar@A14&SS673@A14_N&SS673@A14_S
AGRA@1&AGRA@SS1&SS1Civ@AGRA
A821@LochKat&TroTrl@A821_N&TroTrl@A821_S
A2@+Gra&TTCir@Gra_E&TTCir@Gra_W
IE100@R242&R242@L1031&WAW@R242_A&WAW@R242_B
BoyVlyDr@L2800&BoyVlyDr@R154/L2800&R154@L2800
A560@M60(27)&A626@M60&B6104@M60&M60@27&M60@A626
A6@A601(2)&A52@A601(2)&A601@2&A601@A52_E
A4053@1&A4053@B4113&B4113@A4053
A435@A4540&A4540@1&A4540@A435&B4126@1(A4540)
B4066@FroHill&CSSR@B4066&CSSR@FroHill
A13@31&E46@A13/N814&E46Cae@1(N814)&N814@1&N814@A13
E3@1(N136)&E50@N136/N157&N136@1&N136@N157&N157@N136
AB2@535&AB216@78&AB216@AB2
A2@311&E90@311(A2)&NIIZar@A2&Z40@311A(A2)&Z40@33
A1@10&E5@A1/M30&M11@A1/M30&M30@0&M30@32
A1@13&E5@13(A1)&M40@1&M40@A1
A4@537&E5@537(A4)&SE30@0&SE30@A4
I-376@69B&PA51@I-376(69B)&US19@I-376(69B)&US19TrkPit@I-376(69B)_N&US19TrkPit@I-376(69B)_S&US22@I-376(69B)&US30@I-376(69B)
I-71@101&I-270@55&I-270@I-71
I-65@106&I-69FutInd@53(465)&I-74@53(465)&I-465@53&I-465@I-65&IN37@I-465(53)&IN67@I-465(53)&US31@53(465)&US36@I-465(53)&US40@I-465(53)
VA228@VA228TrkHer_S&VA228TrkHer@EldSt&VA228TrkHer@VA228_S
KY4@19&KY4@US27&US27@KY4(19)
I-85@48&I-485@30&I-485@I-85(48)
CadCoveLpRd@LauCreRd_A&CadCoveLpRd@LauCreRd_B&LauCreRd@CadCoveLp
GA8@GA10Lp(1)&GA10LpAth@1&GA10LpAth@US78&GA316@GA10Lp(1)&US29@GA10Lp(1)&US78@GA10Lp(1)
GA279@I-85/285&I-85@69&I-285@62&I-285@GA279
I-95@337&I-295@61&I-295@I-95
GraLpRd@NEntRd_E&GraLpRd@NEntRd_W&NEntRd@GraLoopRd
I-40@75&TXLp335@I-40(75)_N&TXLp335@I-40(75)_S&US287@I-40(75)
CraLakeHwy@RimDr&CraLakeRimDr@CraLakeHwy_E&CraLakeRimDr@CraLakeHwy_W
I-30@TX/AR&I-30@TX/AR&US59@I-30(223)&US71@I-30
I-35E@436&TXLp12@I-35E(436)_E&TXLp12@I-35E(436)_W&US77@I-35E(436)
I-35@304&TXLp363@I-35(304)_E&TXLp363@I-35(304)_W
I-610@38&I-610@TX288&TX288@I-610
I-10@587&TXLp1604@I-10(587)_N&TXLp1604@I-10(587)_S&TX130@587(10)&US90@I-10(587)
I-35@145A&I-410@53&I-410@I-35(145A)&TX16@I-410(53)&TX130@53(410)
I-27@1A&TXLp289@I-27(1A)_E&TXLp289@I-27(1A)_W&US87@I-27(1A)
I-20@121&TXLp338@I-20(121)_N&TXLp338@I-20(121)_S
SH1@ManRd&TCDR@ManRd&TCDR@SH1_TH
SH1@SchRd&TCDR@SchRd_A&TCDR@SchRd_B

(HighwayData @ 385486bf3a41c1aee84ef28b2b711c53648c90c4)
Note our old pal PA US19TrkPit. Not technically a loop endpoint.


To start out, test whether we have the same Route object more than once in a given colocation list.

@yakra yakra self-assigned this Nov 19, 2019
@yakra yakra added the CWN canonical_waypoint_name label Mar 2, 2021
@yakra
Copy link
Contributor Author

yakra commented Mar 2, 2021

See also #418

@yakra
Copy link
Contributor Author

yakra commented Mar 14, 2021

a4c1f49 Exit_number

A happy accident when optimizing for speed:

points simplified
I-376 69B
PA51 I-376(69B)
US19 I-376(69B)
US19TrkPit I-376(69B)_N
US19TrkPit I-376(69B)_S
US22 I-376(69B)
US30 I-376(69B)
I-376(69B)/PA51/US19/US19TrkPit/US19TrkPit/US22/US30
I-40 75
TXLp335 I-40(75)_N
TXLp335 I-40(75)_S
US287 I-40(75)
I-40(75)/TXLp335/TXLp335/US287
I-35E 436
TXLp12 I-35E(436)_E
TXLp12 I-35E(436)_W
US77 I-35E(436)
I-35E(436)/TXLp12/TXLp12/US77
I-35 304
TXLp363 I-35(304)_E
TXLp363 I-35(304)_W
I-35(304)/TXLp363/TXLp363
I-10 587
TXLp1604 I-10(587)_N
TXLp1604 I-10(587)_S
TX130 587(10)
US90 I-10(587)
I-10(587)/TXLp1604/TXLp1604/TX130/US90
I-27 1A
TXLp289 I-27(1A)_E
TXLp289 I-27(1A)_W
US87 I-27(1A)
I-27(1A)/TXLp289/TXLp289/US87
I-20 121
TXLp338 I-20(121)_N
TXLp338 I-20(121)_S
I-20(121)/TXLp338/TXLp338

The net widened just enough to allow a _ after the ), rather than requiring the string to end.
Sure, anything else after the ) would also get simplified, but these cases are vanishingly improbable. Literally. Willing to take the minuscule risk to have fast & simple code.
Routes with loop endpoints are still doubled up, but this is nonetheless an improvement over no-build.

  • Simplifying out the double-ups in the future should be easy.

@jteresco
Copy link
Contributor

I like it, thanks!

@yakra
Copy link
Contributor Author

yakra commented Mar 15, 2021

e259932 Going off-topic, but...
Those 7 cases were all there was to be gained. :)
Sillier still, if we add suffix & slash checks after the list_entry_name() check, as we have after the name_no_abbrev() check now, we get all of:

263048c263048
< Keep_failsafe: I-910@13&US90@US90BusNew_E&US90BusNew@13
---
> Exit_number: I-910@13&US90@US90BusNew_E&US90BusNew@13 -> I-910/US90/US90BusNew(13)

If it's a PitA to implement in Python, I won't include it. :)

@yakra yakra mentioned this issue May 6, 2021
@yakra
Copy link
Contributor Author

yakra commented May 12, 2021

yakra added a commit to yakra/DataProcessing that referenced this issue May 19, 2021
consolidate no_abbrev(##) check
7 more simplifications:
TravelMapping#260 (comment)
yakra added a commit to yakra/DataProcessing that referenced this issue May 19, 2021
@yakra yakra mentioned this issue Jun 16, 2021
2 tasks
yakra added a commit to yakra/DataProcessing that referenced this issue Jun 16, 2021
@yakra
Copy link
Contributor Author

yakra commented Jun 16, 2021

a4c1f49 Exit_number

A happy accident when optimizing for speed:
...

  • Simplifying out the double-ups in the future should be easy.

Similar Exit/Intersection optimizations turned 6 of the 7 examples (not the one with TX130@587(10)) into Exit/Intersection cases instead.
Got rid of the double-ups over there in #439.

@yakra
Copy link
Contributor Author

yakra commented Nov 27, 2021

Contrary to the failsafe cases in the OP, here's how to find the simplified ones:
egrep ' -> (.+)/\1/|/(.+)/\2$' waypointsimplification.log

  • 97 3+_intersection
  • 6 Exit_number
  • 3 Exit/Intersection (3 of these: 2 of these & 1 of these)

@yakra
Copy link
Contributor Author

yakra commented Nov 28, 2021

A way faster alternative to the OP that also picks up some cases at region boundaries:
egrep ' (.+)@.*&\1@|&(.+)@.*&\2@' waypointsimplification.log | grep "^Keep_failsafe: .*@.*&.*@.*&.*@.*" | cut -f2 -d' '

AH3@RUS/MNG&A340@RUS/MGL&AH3@RUS/MNG
AB16@AB/SK&AB17@AB16&SK17@AB16&TCHYel@AB/SK&SK16@AB/SK&TCHYel@AB/SK
ID41@US2&US2@WA/ID&US2@WA/ID
E30@BLR/RUS&M01@BEL/RUS&AH6@RUS/BLR&E30@BLR/RUS&M1@RUS/BLR
AP68@PV/CL&E804@RI/CL&AP68@PV/CL&E804@RI/CL
A33@77&A31@173&A33@79
DE54Whi@US13&US13@MD/DE&MD54Del@US13&US13@MD/DE
H3@ISR/PSE&M40@PSE/ISR&R424@H3&H3@ISR/PSE&M40Lat@PSE/ISR
KY400@US41Alt&US41AltNas@TN/KY&US41AltNas@TN/KY
B419@RP/SL&L132@B419&B419@RP/SL
EA2.1@TZA/UGA&RTR15@KEN/TZA&T4@UGA/TZA&EA2.1@TZA/UGA
KY893@US641_S&US641@TN/KY&US641@TN/KY
B4398@ENG/WLS&A483@B4398&B4398@A483

These aren't loop ends of course, but the point is that this is a way better script than the OP.
Pipe it into egrep -v '@[A-Z]+/[A-Z]+$' like in the OP and it's the same thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants