3. Enrutamiento de vehículos¶
Ruteo, no se limita a los peatones y la mayor parte del tiempo se utiliza para la ruta de vehículos.
3.1. Ruteo para vehículos¶
Una consulta para el enrutamiento de vehículos generalmente difiere de la ruta para los peatones:
Los segmentos de carretera se consideran dirigidos
Los costos pueden ser:
Distancia
Tiempo
Euros
Pesos
Dólares
CO2emisiones
Desgaste en el vehículo, etc.
El atributo
reverse_cost
debe tenerse en cuenta en calles de dos vías.Los costes deben tener las mismas unidades que el atributo
cost
Los valores
cost
yreverse_cost
pueden ser diferentesDebido al hecho de que hay carreteras que son de una manera
Dependiendo de la geometría, la forma válida:
(
source, target
) segmentoIF cost >= 0 AND reverse_cost < 0
(
target, source
) segmentoIF cost < 0 AND reverse_cost >= 0
Un camino incorrecto se indica con un valor negativo y no se inserta en el grafo para su procesamiento.
Carreteras bidireccionales -IF cost >= 0 AND reverse_cost >= 0
y sus valores pueden ser diferentes. Por ejemplo, es más rápido ir cuesta abajo en una carretera inclinada. En general, cost
y reverse_cost
no necesitan ser de longitud; pueden ser casi cualquier cosa, por ejemplo, tiempo, pendiente, superficie, tipo de carretera, etc., o pueden ser una combinación de múltiples parámetros.
Las siguientes consultas indican el número de segmentos de carretera, donde se aplica una regla «unidireccional»:
Número de (
source, target
) segmentos concost < 0
(line 3).SELECT count(*) FROM ways WHERE cost < 0; -- line 3
count ------- 0 (1 row)
Número de segmentos (
target, source
) segmentos conreverse_cost < 0
(line 3).SELECT count(*) FROM ways WHERE reverse_cost < 0; -- line 3
count ------- 8474 (1 row)
3.1.1. Ejercicio 1: Ruteo de vehículos - ida¶
Problema:
Desde «Hangar Convention Center» hacia «Palacete Bolonha» en automóvil.
Solución:
Utilice las columnas
cost
(línea 6) yreverse_cost
(línea 7), que están en la unidadgrados
.El vehículo va desde vértice
20297
(line 10) hacia717
(line 11).
SELECT * FROM pgr_dijkstra(
'
SELECT gid AS id,
source,
target,
cost, -- line 6
reverse_cost -- line 7
FROM ways
',
20297, -- line 10
717, -- line 11
directed := true);
seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
-----+----------+-----------+---------+-------+-------+------------------------+-----------------------
1 | 1 | 20297 | 717 | 20297 | 31885 | 0.0001716356422320464 | 0
2 | 2 | 20297 | 717 | 20296 | 91 | 0.0001153433569785665 | 0.0001716356422320464
3 | 3 | 20297 | 717 | 54 | 10915 | 0.00035708800864949733 | 0.0002869789992106129
4 | 4 | 20297 | 717 | 7354 | 1743 | 0.0014322361816398747 | 0.0006440670078601103
5 | 5 | 20297 | 717 | 1033 | 1775 | 0.0015143940604290334 | 0.002076303189499985
6 | 6 | 20297 | 717 | 1051 | 10920 | 0.0009291231403867673 | 0.0035906972499290184
7 | 7 | 20297 | 717 | 7357 | 1835 | 0.0006153841892071156 | 0.004519820390315786
8 | 8 | 20297 | 717 | 1084 | 10927 | 0.0009010473905377392 | 0.005135204579522901
9 | 9 | 20297 | 717 | 7361 | 1725 | 0.0005560954684229016 | 0.006036251970060641
10 | 10 | 20297 | 717 | 1022 | 10346 | 0.0012567037916704972 | 0.006592347438483542
11 | 11 | 20297 | 717 | 6953 | 27847 | 0.00015145418449423264 | 0.00784905123015404
12 | 12 | 20297 | 717 | 21151 | 540 | 0.00010643312454210425 | 0.008000505414648272
13 | 13 | 20297 | 717 | 320 | 27845 | 0.00010051691400060946 | 0.008106938539190376
14 | 14 | 20297 | 717 | 21149 | 10350 | 0.00017279285285780552 | 0.008207455453190985
15 | 15 | 20297 | 717 | 6955 | 565 | 0.0012135304240127123 | 0.00838024830604879
16 | 16 | 20297 | 717 | 333 | 15283 | 0.0004978948483381016 | 0.009593778730061503
17 | 17 | 20297 | 717 | 10784 | 10752 | 0.0008473144934902617 | 0.010091673578399605
18 | 18 | 20297 | 717 | 7234 | 10409 | 9.610020811439204e-05 | 0.010938988071889866
19 | 19 | 20297 | 717 | 6990 | 10411 | 7.496939375540897e-05 | 0.011035088280004258
20 | 20 | 20297 | 717 | 6991 | 15288 | 0.0012184804060786285 | 0.011110057673759667
21 | 21 | 20297 | 717 | 10787 | 375 | 0.00024798082587396635 | 0.012328538079838296
22 | 22 | 20297 | 717 | 226 | 15295 | 0.00021386897858363462 | 0.012576518905712262
23 | 23 | 20297 | 717 | 10791 | 13798 | 0.00041691485941307445 | 0.012790387884295897
24 | 24 | 20297 | 717 | 9580 | 27297 | 0.00048219433841428674 | 0.013207302743708972
25 | 25 | 20297 | 717 | 20647 | 3285 | 0.000378614645781829 | 0.013689497082123258
26 | 26 | 20297 | 717 | 2040 | 15304 | 0.0001014000493093058 | 0.014068111727905086
27 | 27 | 20297 | 717 | 10796 | 13799 | 0.000690339141293269 | 0.014169511777214393
28 | 28 | 20297 | 717 | 9581 | 10935 | 6.14524206174259e-05 | 0.014859850918507661
29 | 29 | 20297 | 717 | 7366 | 3256 | 0.0006448366416395072 | 0.014921303339125088
30 | 30 | 20297 | 717 | 2023 | 15305 | 0.00019525624189873058 | 0.015566139980764594
31 | 31 | 20297 | 717 | 10797 | 18878 | 0.00041348876647511075 | 0.015761396222663326
32 | 32 | 20297 | 717 | 13516 | 18875 | 0.00037592032400472335 | 0.016174884989138435
33 | 33 | 20297 | 717 | 13514 | 18321 | 0.00039010831828777424 | 0.01655080531314316
34 | 34 | 20297 | 717 | 13078 | 3255 | 8.531377380122786e-05 | 0.016940913631430934
35 | 35 | 20297 | 717 | 2022 | 18324 | 0.00011548991298170257 | 0.017026227405232162
36 | 36 | 20297 | 717 | 13081 | 18872 | 0.0008118415241947302 | 0.017141717318213866
37 | 37 | 20297 | 717 | 13512 | 12139 | 0.00031002412809421687 | 0.017953558842408596
38 | 38 | 20297 | 717 | 8261 | 15310 | 0.00015540093307229479 | 0.018263582970502814
39 | 39 | 20297 | 717 | 10800 | 1655 | 9.117335137152959e-05 | 0.01841898390357511
40 | 40 | 20297 | 717 | 983 | 12144 | 0.00012580381552128363 | 0.01851015725494664
41 | 41 | 20297 | 717 | 8264 | 15317 | 0.00016713542413305483 | 0.018635961070467923
42 | 42 | 20297 | 717 | 10804 | 1657 | 0.0012063682718777141 | 0.018803096494600977
43 | 43 | 20297 | 717 | 985 | 10077 | 0.0007259629664562226 | 0.02000946476647869
44 | 44 | 20297 | 717 | 6769 | 10359 | 0.0001000641794043222 | 0.020735427732934915
45 | 45 | 20297 | 717 | 6960 | 7947 | 0.00024665183964426847 | 0.020835491912339237
46 | 46 | 20297 | 717 | 5227 | 508 | 0.00039454221573752794 | 0.021082143751983504
47 | 47 | 20297 | 717 | 302 | 23247 | 0.000920938461572996 | 0.02147668596772103
48 | 48 | 20297 | 717 | 16963 | 1628 | 0.00014692055676409702 | 0.022397624429294025
49 | 49 | 20297 | 717 | 966 | 1636 | 0.0003061667846102729 | 0.022544544986058124
50 | 50 | 20297 | 717 | 971 | 148 | 0.0008497233782684474 | 0.022850711770668396
51 | 51 | 20297 | 717 | 83 | 23450 | 0.0008890276261183315 | 0.023700435148936844
52 | 52 | 20297 | 717 | 17152 | 320 | 2.9017236240749123e-06 | 0.024589462775055176
53 | 53 | 20297 | 717 | 197 | 24810 | 0.0004980350690443442 | 0.02459236449867925
54 | 54 | 20297 | 717 | 18350 | 20586 | 9.151770320890743e-05 | 0.025090399567723593
55 | 55 | 20297 | 717 | 14785 | 20587 | 2.640075756076166e-05 | 0.0251819172709325
56 | 56 | 20297 | 717 | 14786 | 20524 | 0.0002720488273948793 | 0.02520831802849326
57 | 57 | 20297 | 717 | 14741 | 23244 | 0.0009270686974724552 | 0.02548036685588814
58 | 58 | 20297 | 717 | 16961 | 20514 | 0.0014042238461164686 | 0.026407435553360593
59 | 59 | 20297 | 717 | 14734 | 20515 | 1.612451547048347e-06 | 0.02781165939947706
60 | 60 | 20297 | 717 | 14735 | 20512 | 3.238826949997096e-06 | 0.02781327185102411
61 | 61 | 20297 | 717 | 14733 | 20518 | 0.00022060775145070832 | 0.027816510677974107
62 | 62 | 20297 | 717 | 14737 | 20517 | 4.669047008933728e-06 | 0.028037118429424815
63 | 63 | 20297 | 717 | 14736 | 20633 | 0.0017243292535695101 | 0.02804178747643375
64 | 64 | 20297 | 717 | 14817 | 20508 | 0.0005125725802262838 | 0.029766116730003258
65 | 65 | 20297 | 717 | 14729 | 20510 | 6.76874937153904e-05 | 0.03027868931022954
66 | 66 | 20297 | 717 | 14731 | 20507 | 0.00040236167574913325 | 0.030346376803944933
67 | 67 | 20297 | 717 | 14728 | 797 | 0.0008595892650021071 | 0.030748738479694067
68 | 68 | 20297 | 717 | 478 | 18916 | 0.0012434449764071554 | 0.03160832774469617
69 | 69 | 20297 | 717 | 13549 | 18914 | 0.001287736844233779 | 0.032851772721103324
70 | 70 | 20297 | 717 | 13548 | 400 | 0.00021713325401738864 | 0.0341395095653371
71 | 71 | 20297 | 717 | 242 | 8111 | 0.0007146295403969889 | 0.034356642819354494
72 | 72 | 20297 | 717 | 5336 | 18920 | 0.0005166207216081487 | 0.03507127235975148
73 | 73 | 20297 | 717 | 13552 | 129 | 0.0008133260046502112 | 0.03558789308135963
74 | 74 | 20297 | 717 | 73 | 23872 | 0.00105179939627213 | 0.036401219086009844
75 | 75 | 20297 | 717 | 17545 | 133 | 0.0017825034185829603 | 0.037453018482281976
76 | 76 | 20297 | 717 | 75 | 8069 | 0.0009355679558470786 | 0.039235521900864934
77 | 77 | 20297 | 717 | 5343 | 13553 | 0.0004138411893461655 | 0.040171089856712014
78 | 78 | 20297 | 717 | 9383 | 26190 | 0.0006996503269481625 | 0.04058493104605818
79 | 79 | 20297 | 717 | 19540 | 20372 | 0.0002576070200854789 | 0.04128458137300634
80 | 80 | 20297 | 717 | 14633 | 1209 | 0.0009725325958516923 | 0.041542188393091824
81 | 81 | 20297 | 717 | 730 | 8118 | 0.0003842942882742046 | 0.042514720988943516
82 | 82 | 20297 | 717 | 5340 | 8120 | 0.00017291399596771487 | 0.04289901527721772
83 | 83 | 20297 | 717 | 5341 | 1407 | 0.0006319297191941005 | 0.043071929273185434
84 | 84 | 20297 | 717 | 847 | 23627 | 0.0005970993970838893 | 0.04370385899237954
85 | 85 | 20297 | 717 | 17326 | 1201 | 0.0007297861673124474 | 0.04430095838946343
86 | 86 | 20297 | 717 | 725 | 1593 | 0.0005294386177819955 | 0.04503074455677587
87 | 87 | 20297 | 717 | 945 | 1188 | 0.000629312521724741 | 0.045560183174557865
88 | 88 | 20297 | 717 | 719 | 1546 | 0.0011405803403423656 | 0.046189495696282605
89 | 89 | 20297 | 717 | 921 | 1185 | 0.0011917061089064978 | 0.04733007603662497
90 | 90 | 20297 | 717 | 718 | 1184 | 0.0012913085006919156 | 0.04852178214553147
91 | 91 | 20297 | 717 | 717 | -1 | 0 | 0.049813090646223385
(91 rows)
3.1.2. Ejercicio 2: Ruteo de vehículos - regreso¶
Problema:
Desde «Palacete Bolonha» hacia «Hangar Convention Center» en automóvil.
Solución:
Utilizar las columnas
cost_s
(línea 6) yreverse_cost_s
(línea 7) que están en unidad de segundos.El vehículo va de vértice
717
(línea 10) para20297
(línea 11).
SELECT * FROM pgr_dijkstra(
'
SELECT gid AS id,
source,
target,
cost_s AS cost, -- line 6
reverse_cost_s AS reverse_cost -- line 7
FROM ways
',
717, -- line 10
20297, -- line 11
directed := true);
seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
-----+----------+-----------+---------+-------+-------+----------------------+--------------------
1 | 1 | 717 | 20297 | 717 | 11369 | 7.649277145705279 | 0
2 | 2 | 717 | 20297 | 7674 | 11370 | 3.1979608009334255 | 7.649277145705279
3 | 3 | 717 | 20297 | 703 | 1157 | 11.04007394672912 | 10.847237946638703
4 | 4 | 717 | 20297 | 702 | 156 | 10.929693214960086 | 21.887311893367823
5 | 5 | 717 | 20297 | 88 | 21353 | 11.542936122011175 | 32.817005108327905
6 | 6 | 717 | 20297 | 15362 | 16610 | 8.333725395076964 | 44.35994123033908
7 | 7 | 717 | 20297 | 11748 | 11111 | 1.0460058812418955 | 52.69366662541604
8 | 8 | 717 | 20297 | 7483 | 192 | 1.1224871367128515 | 53.73967250665794
9 | 9 | 717 | 20297 | 114 | 15091 | 1.201966517513442 | 54.86215964337079
10 | 10 | 717 | 20297 | 10625 | 1202 | 1.2145743248659164 | 56.06412616088423
11 | 11 | 717 | 20297 | 726 | 1089 | 10.631698839302336 | 57.27870048575014
12 | 12 | 717 | 20297 | 662 | 25766 | 1.5947062700842551 | 67.91039932505248
13 | 13 | 717 | 20297 | 19160 | 21346 | 7.209317427750495 | 69.50510559513674
14 | 14 | 717 | 20297 | 15355 | 1091 | 3.664591799120692 | 76.71442302288723
15 | 15 | 717 | 20297 | 663 | 21320 | 3.676461046720907 | 80.37901482200792
16 | 16 | 717 | 20297 | 15331 | 21322 | 8.532858200977705 | 84.05547586872882
17 | 17 | 717 | 20297 | 15333 | 1204 | 5.427710167423101 | 92.58833406970652
18 | 18 | 717 | 20297 | 727 | 20367 | 7.153961955300545 | 98.01604423712962
19 | 19 | 717 | 20297 | 14631 | 26617 | 3.843378476266271 | 105.17000619243017
20 | 20 | 717 | 20297 | 19968 | 26709 | 0.17575082816994467 | 109.01338466869643
21 | 21 | 717 | 20297 | 20060 | 26583 | 2.0069671990461964 | 109.18913549686637
22 | 22 | 717 | 20297 | 19934 | 1093 | 12.47887124092446 | 111.19610269591257
23 | 23 | 717 | 20297 | 664 | 1095 | 19.508677242653324 | 123.67497393683703
24 | 24 | 717 | 20297 | 665 | 25482 | 8.279697561260365 | 143.18365117949037
25 | 25 | 717 | 20297 | 18925 | 13642 | 3.8232835830362157 | 151.46334874075075
26 | 26 | 717 | 20297 | 9453 | 20529 | 6.140981371285463 | 155.28663232378696
27 | 27 | 717 | 20297 | 14744 | 22276 | 1.141317049151238 | 161.4276136950724
28 | 28 | 717 | 20297 | 16130 | 23240 | 5.819964005493112 | 162.56893074422365
29 | 29 | 717 | 20297 | 16957 | 23242 | 1.3616887721678947 | 168.38889474971677
30 | 30 | 717 | 20297 | 16959 | 20634 | 4.376617072113684 | 169.75058352188466
31 | 31 | 717 | 20297 | 14817 | 1096 | 0.2233733506101573 | 174.12720059399834
32 | 32 | 717 | 20297 | 666 | 18926 | 1.3044471263755029 | 174.3505739446085
33 | 33 | 717 | 20297 | 13558 | 20632 | 0.046009866596978095 | 175.655021070984
34 | 34 | 717 | 20297 | 14816 | 20527 | 12.241284182800436 | 175.70103093758098
35 | 35 | 717 | 20297 | 14743 | 13665 | 8.794184121996512 | 187.9423151203814
36 | 36 | 717 | 20297 | 9472 | 1098 | 5.233961567897756 | 196.73649924237793
37 | 37 | 717 | 20297 | 667 | 3237 | 8.575989565252819 | 201.97046081027568
38 | 38 | 717 | 20297 | 2011 | 10937 | 5.753660104916916 | 210.5464503755285
39 | 39 | 717 | 20297 | 7368 | 23470 | 4.349821481768251 | 216.30011048044543
40 | 40 | 717 | 20297 | 17170 | 19253 | 2.172887473049065 | 220.64993196221369
41 | 41 | 717 | 20297 | 13851 | 22805 | 3.3127131308112716 | 222.82281943526274
42 | 42 | 717 | 20297 | 16579 | 102 | 0.5361470911814347 | 226.135532566074
43 | 43 | 717 | 20297 | 60 | 23245 | 4.560298654310812 | 226.67167965725545
44 | 44 | 717 | 20297 | 16962 | 10360 | 3.371715219110345 | 231.23197831156625
45 | 45 | 717 | 20297 | 6961 | 1644 | 3.369172847320359 | 234.6036935306766
46 | 46 | 717 | 20297 | 977 | 7943 | 2.462066055691773 | 237.97286637799695
47 | 47 | 717 | 20297 | 5225 | 7944 | 1.5097956407383146 | 240.43493243368872
48 | 48 | 717 | 20297 | 5226 | 3194 | 0.787830328173101 | 241.94472807442702
49 | 49 | 717 | 20297 | 1982 | 1647 | 4.923602780529765 | 242.73255840260012
50 | 50 | 717 | 20297 | 979 | 27195 | 4.779578061852004 | 247.65616118312988
51 | 51 | 717 | 20297 | 20543 | 15321 | 3.2620556418627746 | 252.43573924498187
52 | 52 | 717 | 20297 | 10806 | 12145 | 1.1010412528764728 | 255.69779488684466
53 | 53 | 717 | 20297 | 8265 | 1653 | 0.7265291508959483 | 256.7988361397211
54 | 54 | 717 | 20297 | 982 | 15314 | 0.687892166829071 | 257.52536529061706
55 | 55 | 717 | 20297 | 10802 | 12141 | 1.00057182891344 | 258.2132574574461
56 | 56 | 717 | 20297 | 8262 | 18325 | 7.625877296588039 | 259.21382928635956
57 | 57 | 717 | 20297 | 13082 | 3154 | 0.6911991237607362 | 266.8397065829476
58 | 58 | 717 | 20297 | 1958 | 18322 | 0.589059340205777 | 267.5309057067083
59 | 59 | 717 | 20297 | 13079 | 15309 | 7.802332894772054 | 268.1199650469141
60 | 60 | 717 | 20297 | 10799 | 3160 | 1.451915421445249 | 275.92229794168617
61 | 61 | 717 | 20297 | 1961 | 11148 | 4.1291968838076585 | 277.3742133631314
62 | 62 | 717 | 20297 | 7512 | 18328 | 5.071210660887403 | 281.50341024693904
63 | 63 | 717 | 20297 | 13085 | 3165 | 0.6588005157910573 | 286.57462090782644
64 | 64 | 717 | 20297 | 1964 | 15302 | 0.6624379620171468 | 287.23342142361753
65 | 65 | 717 | 20297 | 10795 | 15299 | 7.64331893402423 | 287.89585938563465
66 | 66 | 717 | 20297 | 10793 | 372 | 1.6185624439136164 | 295.5391783196589
67 | 67 | 717 | 20297 | 225 | 15291 | 1.5426950808720525 | 297.1577407635725
68 | 68 | 717 | 20297 | 10789 | 10414 | 8.10018215092719 | 298.7004358444446
69 | 69 | 717 | 20297 | 6993 | 10412 | 0.8010340812788996 | 306.8006179953718
70 | 70 | 717 | 20297 | 6992 | 10755 | 0.32174055743410845 | 307.6016520766507
71 | 71 | 717 | 20297 | 7236 | 15284 | 5.603200219924484 | 307.9233926340848
72 | 72 | 717 | 20297 | 10785 | 1845 | 3.4154739303977477 | 313.52659285400927
73 | 73 | 717 | 20297 | 1090 | 3174 | 4.719295193747098 | 316.942066784407
74 | 74 | 717 | 20297 | 1970 | 3172 | 2.494985805447332 | 321.6613619781541
75 | 75 | 717 | 20297 | 1968 | 7938 | 1.1336853637583644 | 324.15634778360146
76 | 76 | 717 | 20297 | 5222 | 27846 | 0.8904302856085814 | 325.29003314735985
77 | 77 | 717 | 20297 | 21150 | 339 | 0.698022009641036 | 326.18046343296845
78 | 78 | 717 | 20297 | 207 | 27848 | 0.6564041634973928 | 326.8784854426095
79 | 79 | 717 | 20297 | 21152 | 10348 | 0.9834944305474466 | 327.53488960610684
80 | 80 | 717 | 20297 | 6954 | 10056 | 2.9402965329150215 | 328.5183840366543
81 | 81 | 717 | 20297 | 6753 | 1727 | 5.355184246550181 | 331.4586805695693
82 | 82 | 717 | 20297 | 1023 | 10929 | 3.8274834071623784 | 336.81386481611946
83 | 83 | 717 | 20297 | 7362 | 1731 | 1.4213261487655227 | 340.64134822328185
84 | 84 | 717 | 20297 | 1026 | 1733 | 4.631815146870902 | 342.06267437204735
85 | 85 | 717 | 20297 | 1027 | 10921 | 3.940277020140121 | 346.69448951891826
86 | 86 | 717 | 20297 | 7358 | 12969 | 0.8433302614957165 | 350.6347665390584
87 | 87 | 717 | 20297 | 8924 | 10392 | 5.077008239497512 | 351.4780968005541
88 | 88 | 717 | 20297 | 6978 | 12971 | 3.541402184491856 | 356.5551050400516
89 | 89 | 717 | 20297 | 8926 | 24118 | 1.163994608512139 | 360.0965072245435
90 | 90 | 717 | 20297 | 17746 | 1737 | 5.407282465448289 | 361.2605018330556
91 | 91 | 717 | 20297 | 1029 | 1741 | 5.6631558817312015 | 366.66778429850393
92 | 92 | 717 | 20297 | 1032 | 24307 | 2.8288056582150825 | 372.33094018023513
93 | 93 | 717 | 20297 | 17919 | 10919 | 1.5788656574755486 | 375.1597458384502
94 | 94 | 717 | 20297 | 7356 | 99 | 1.6125042321092125 | 376.73861149592574
95 | 95 | 717 | 20297 | 59 | 97 | 1.4555596260266292 | 378.3511157280349
96 | 96 | 717 | 20297 | 58 | 15816 | 0.7379112639781683 | 379.80667535406155
97 | 97 | 717 | 20297 | 11171 | 510 | 1.0674675004507879 | 380.5445866180397
98 | 98 | 717 | 20297 | 304 | 26944 | 0.9357212700059486 | 381.6120541184905
99 | 99 | 717 | 20297 | 20297 | -1 | 0 | 382.54777538849646
(99 rows)
Nota
En un grafo dirigido, las rutas para ir y volver, la mayoría de las veces son diferentes.
3.1.3. Ejercicio 3: Ruteo de vehículos cuando el tiempo es dinero¶
Problema:
Desde «Palacete Bolonha» hacia «Hangar Convention Center» en taxi.
Solución:
El costo es de
$100 por hora
.Utilizar las columnas
cost_s
(línea 6) yreverse_cost_s
(línea 7) que están en unidad desegundos
.La duración en horas es
cost_s / 3600
.El costo en
dollars
escost_s / 3600 * 100
.
El vehículo va de vértice
717
(línea 10) para20297
(línea 11).
SELECT * FROM pgr_dijkstra(
'
SELECT gid AS id,
source,
target,
cost_s / 3600 * 100 AS cost, -- line 6
reverse_cost_s / 3600 * 100 AS reverse_cost -- line 7
FROM ways
',
717, -- line 10
20297); -- line 11
seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
-----+----------+-----------+---------+-------+-------+-----------------------+---------------------
1 | 1 | 717 | 20297 | 717 | 11369 | 0.21247992071403554 | 0
2 | 2 | 717 | 20297 | 7674 | 11370 | 0.08883224447037294 | 0.21247992071403554
3 | 3 | 717 | 20297 | 703 | 1157 | 0.30666872074247553 | 0.3013121651844085
4 | 4 | 717 | 20297 | 702 | 156 | 0.30360258930444683 | 0.607980885926884
5 | 5 | 717 | 20297 | 88 | 21353 | 0.3206371145003104 | 0.9115834752313309
6 | 6 | 717 | 20297 | 15362 | 16610 | 0.23149237208547122 | 1.2322205897316412
7 | 7 | 717 | 20297 | 11748 | 11111 | 0.029055718923385987 | 1.4637129618171123
8 | 8 | 717 | 20297 | 7483 | 192 | 0.031180198242023654 | 1.4927686807404983
9 | 9 | 717 | 20297 | 114 | 15091 | 0.033387958819817834 | 1.523948878982522
10 | 10 | 717 | 20297 | 10625 | 1202 | 0.0337381756907199 | 1.5573368378023398
11 | 11 | 717 | 20297 | 726 | 1089 | 0.2953249677583982 | 1.5910750134930596
12 | 12 | 717 | 20297 | 662 | 25766 | 0.04429739639122931 | 1.8863999812514578
13 | 13 | 717 | 20297 | 19160 | 21346 | 0.20025881743751375 | 1.930697377642687
14 | 14 | 717 | 20297 | 15355 | 1091 | 0.10179421664224145 | 2.1309561950802007
15 | 15 | 717 | 20297 | 663 | 21320 | 0.10212391796446964 | 2.232750411722442
16 | 16 | 717 | 20297 | 15331 | 21322 | 0.23702383891604736 | 2.3348743296869117
17 | 17 | 717 | 20297 | 15333 | 1204 | 0.15076972687286394 | 2.571898168602959
18 | 18 | 717 | 20297 | 727 | 20367 | 0.19872116542501514 | 2.722667895475823
19 | 19 | 717 | 20297 | 14631 | 26617 | 0.10676051322961863 | 2.921389060900838
20 | 20 | 717 | 20297 | 19968 | 26709 | 0.00488196744916513 | 3.028149574130457
21 | 21 | 717 | 20297 | 20060 | 26583 | 0.05574908886239434 | 3.033031541579622
22 | 22 | 717 | 20297 | 19934 | 1093 | 0.3466353122479017 | 3.0887806304420162
23 | 23 | 717 | 20297 | 664 | 1095 | 0.5419077011848146 | 3.435415942689918
24 | 24 | 717 | 20297 | 665 | 25482 | 0.22999159892389903 | 3.9773236438747324
25 | 25 | 717 | 20297 | 18925 | 13642 | 0.106202321751006 | 4.207315242798631
26 | 26 | 717 | 20297 | 9453 | 20529 | 0.17058281586904062 | 4.313517564549637
27 | 27 | 717 | 20297 | 14744 | 22276 | 0.03170325136531217 | 4.484100380418678
28 | 28 | 717 | 20297 | 16130 | 23240 | 0.16166566681925312 | 4.51580363178399
29 | 29 | 717 | 20297 | 16957 | 23242 | 0.03782468811577486 | 4.677469298603243
30 | 30 | 717 | 20297 | 16959 | 20634 | 0.12157269644760234 | 4.715293986719018
31 | 31 | 717 | 20297 | 14817 | 1096 | 0.006204815294726592 | 4.83686668316662
32 | 32 | 717 | 20297 | 666 | 18926 | 0.036234642399319526 | 4.843071498461346
33 | 33 | 717 | 20297 | 13558 | 20632 | 0.0012780518499160582 | 4.879306140860666
34 | 34 | 717 | 20297 | 14816 | 20527 | 0.3400356717444566 | 4.880584192710582
35 | 35 | 717 | 20297 | 14743 | 13665 | 0.24428289227768088 | 5.220619864455039
36 | 36 | 717 | 20297 | 9472 | 1098 | 0.14538782133049324 | 5.46490275673272
37 | 37 | 717 | 20297 | 667 | 3237 | 0.23822193236813383 | 5.610290578063213
38 | 38 | 717 | 20297 | 2011 | 10937 | 0.1598238918032477 | 5.848512510431347
39 | 39 | 717 | 20297 | 7368 | 23470 | 0.12082837449356253 | 6.008336402234595
40 | 40 | 717 | 20297 | 17170 | 19253 | 0.060357985362474026 | 6.129164776728158
41 | 41 | 717 | 20297 | 13851 | 22805 | 0.092019809189202 | 6.189522762090632
42 | 42 | 717 | 20297 | 16579 | 102 | 0.014892974755039852 | 6.281542571279834
43 | 43 | 717 | 20297 | 60 | 23245 | 0.12667496261974479 | 6.296435546034874
44 | 44 | 717 | 20297 | 16962 | 10360 | 0.09365875608639847 | 6.423110508654619
45 | 45 | 717 | 20297 | 6961 | 1644 | 0.09358813464778774 | 6.516769264741018
46 | 46 | 717 | 20297 | 977 | 7943 | 0.06839072376921593 | 6.610357399388805
47 | 47 | 717 | 20297 | 5225 | 7944 | 0.041938767798286515 | 6.678748123158021
48 | 48 | 717 | 20297 | 5226 | 3194 | 0.021884175782586137 | 6.720686890956308
49 | 49 | 717 | 20297 | 1982 | 1647 | 0.1367667439036046 | 6.742571066738893
50 | 50 | 717 | 20297 | 979 | 27195 | 0.13276605727366678 | 6.879337810642498
51 | 51 | 717 | 20297 | 20543 | 15321 | 0.09061265671841041 | 7.0121038679161645
52 | 52 | 717 | 20297 | 10806 | 12145 | 0.030584479246568687 | 7.102716524634575
53 | 53 | 717 | 20297 | 8265 | 1653 | 0.02018136530266523 | 7.133301003881144
54 | 54 | 717 | 20297 | 982 | 15314 | 0.01910811574525197 | 7.153482369183809
55 | 55 | 717 | 20297 | 10802 | 12141 | 0.027793661914262222 | 7.172590484929061
56 | 56 | 717 | 20297 | 8262 | 18325 | 0.2118299249052233 | 7.200384146843323
57 | 57 | 717 | 20297 | 13082 | 3154 | 0.019199975660020453 | 7.412214071748546
58 | 58 | 717 | 20297 | 1958 | 18322 | 0.016362759450160472 | 7.431414047408567
59 | 59 | 717 | 20297 | 13079 | 15309 | 0.2167314692992237 | 7.447776806858728
60 | 60 | 717 | 20297 | 10799 | 3160 | 0.04033098392903469 | 7.664508276157951
61 | 61 | 717 | 20297 | 1961 | 11148 | 0.11469991343910162 | 7.704839260086986
62 | 62 | 717 | 20297 | 7512 | 18328 | 0.14086696280242786 | 7.819539173526088
63 | 63 | 717 | 20297 | 13085 | 3165 | 0.018300014327529368 | 7.960406136328516
64 | 64 | 717 | 20297 | 1964 | 15302 | 0.0184010545004763 | 7.978706150656046
65 | 65 | 717 | 20297 | 10795 | 15299 | 0.21231441483400637 | 7.997107205156522
66 | 66 | 717 | 20297 | 10793 | 372 | 0.04496006788648934 | 8.209421619990529
67 | 67 | 717 | 20297 | 225 | 15291 | 0.04285264113533479 | 8.254381687877018
68 | 68 | 717 | 20297 | 10789 | 10414 | 0.2250050597479775 | 8.297234329012353
69 | 69 | 717 | 20297 | 6993 | 10412 | 0.022250946702191656 | 8.52223938876033
70 | 70 | 717 | 20297 | 6992 | 10755 | 0.008937237706503013 | 8.544490335462521
71 | 71 | 717 | 20297 | 7236 | 15284 | 0.1556444505534579 | 8.553427573169024
72 | 72 | 717 | 20297 | 10785 | 1845 | 0.09487427584438188 | 8.709072023722483
73 | 73 | 717 | 20297 | 1090 | 3174 | 0.13109153315964162 | 8.803946299566864
74 | 74 | 717 | 20297 | 1970 | 3172 | 0.06930516126242589 | 8.935037832726506
75 | 75 | 717 | 20297 | 1968 | 7938 | 0.03149126010439901 | 9.004342993988931
76 | 76 | 717 | 20297 | 5222 | 27846 | 0.02473417460023837 | 9.03583425409333
77 | 77 | 717 | 20297 | 21150 | 339 | 0.019389500267806555 | 9.06056842869357
78 | 78 | 717 | 20297 | 207 | 27848 | 0.01823344898603869 | 9.079957928961376
79 | 79 | 717 | 20297 | 21152 | 10348 | 0.027319289737429073 | 9.098191377947414
80 | 80 | 717 | 20297 | 6954 | 10056 | 0.08167490369208392 | 9.125510667684843
81 | 81 | 717 | 20297 | 6753 | 1727 | 0.14875511795972723 | 9.207185571376927
82 | 82 | 717 | 20297 | 1023 | 10929 | 0.10631898353228829 | 9.355940689336654
83 | 83 | 717 | 20297 | 7362 | 1731 | 0.03948128191015341 | 9.462259672868942
84 | 84 | 717 | 20297 | 1026 | 1733 | 0.12866153185752505 | 9.501740954779097
85 | 85 | 717 | 20297 | 1027 | 10921 | 0.10945213944833669 | 9.630402486636621
86 | 86 | 717 | 20297 | 7358 | 12969 | 0.023425840597103235 | 9.739854626084957
87 | 87 | 717 | 20297 | 8924 | 10392 | 0.14102800665270868 | 9.76328046668206
88 | 88 | 717 | 20297 | 6978 | 12971 | 0.09837228290255155 | 9.904308473334769
89 | 89 | 717 | 20297 | 8926 | 24118 | 0.03233318356978164 | 10.002680756237321
90 | 90 | 717 | 20297 | 17746 | 1737 | 0.15020229070689692 | 10.035013939807103
91 | 91 | 717 | 20297 | 1029 | 1741 | 0.15730988560364448 | 10.185216230514
92 | 92 | 717 | 20297 | 1032 | 24307 | 0.07857793495041895 | 10.342526116117645
93 | 93 | 717 | 20297 | 17919 | 10919 | 0.0438573793743208 | 10.421104051068063
94 | 94 | 717 | 20297 | 7356 | 99 | 0.044791784225255905 | 10.464961430442385
95 | 95 | 717 | 20297 | 59 | 97 | 0.040432211834073035 | 10.50975321466764
96 | 96 | 717 | 20297 | 58 | 15816 | 0.020497535110504676 | 10.550185426501713
97 | 97 | 717 | 20297 | 11171 | 510 | 0.029651875012521884 | 10.570682961612217
98 | 98 | 717 | 20297 | 304 | 26944 | 0.02599225750016524 | 10.60033483662474
99 | 99 | 717 | 20297 | 20297 | -1 | 0 | 10.626327094124905
(99 rows)
Nota
Comparación con Ejercicio 2: Ruteo de vehículos - regreso:
El número total de registros es idéntico.
La secuencia de nodos es idéntica.
La secuencia de aristas es idéntica.
El coste y los resultados agg_cost son directamente proporcionales.
3.2. Manipulaciones de costes¶
Al tratar con datos, ser consciente de qué tipo de datos se están utilizando puede mejorar los resultados.
Los vehículos no pueden circular por vías peatonales
Penalizar o eliminar las vías peatonales hará que los resultados se acerquen a la realidad.
Al convertir datos del formato OSM mediante la herramienta osm2pgrouting, hay una tabla adicional: configuration
.
La estructura de tabla configuration
se puede obtener con el siguiente comando.
\dS+ configuration
Table "public.configuration"
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
-------------------+------------------+-----------+----------+-------------------------------------------+----------+-------------+--------------+-------------
id | integer | | not null | nextval('configuration_id_seq'::regclass) | plain | | |
tag_id | integer | | | | plain | | |
tag_key | text | | | | extended | | |
tag_value | text | | | | extended | | |
priority | double precision | | | | plain | | |
maxspeed | double precision | | | | plain | | |
maxspeed_forward | double precision | | | | plain | | |
maxspeed_backward | double precision | | | | plain | | |
force | character(1) | | | | extended | | |
Indexes:
"configuration_pkey" PRIMARY KEY, btree (id)
"configuration_tag_id_key" UNIQUE CONSTRAINT, btree (tag_id)
Referenced by:
TABLE "ways" CONSTRAINT "ways_tag_id_fkey" FOREIGN KEY (tag_id) REFERENCES configuration(tag_id)
Access method: heap
Options: autovacuum_enabled=false
En la imagen de arriba hay un detalle de la tag_id
de las carreteras.
Los tipos OSM way
:
SELECT tag_id, tag_key, tag_value
FROM configuration
ORDER BY tag_id;
tag_id | tag_key | tag_value
--------+-----------+-------------------
100 | highway | road
101 | highway | motorway
102 | highway | motorway_link
103 | highway | motorway_junction
104 | highway | trunk
105 | highway | trunk_link
106 | highway | primary
107 | highway | primary_link
108 | highway | secondary
109 | highway | tertiary
110 | highway | residential
111 | highway | living_street
112 | highway | service
113 | highway | track
114 | highway | pedestrian
115 | highway | services
116 | highway | bus_guideway
117 | highway | path
118 | highway | cycleway
119 | highway | footway
120 | highway | bridleway
121 | highway | byway
122 | highway | steps
123 | highway | unclassified
124 | highway | secondary_link
125 | highway | tertiary_link
201 | cycleway | lane
202 | cycleway | track
203 | cycleway | opposite_lane
204 | cycleway | opposite
301 | tracktype | grade1
302 | tracktype | grade2
303 | tracktype | grade3
304 | tracktype | grade4
305 | tracktype | grade5
401 | junction | roundabout
(36 rows)
Además, en la tabla ways
hay una columna que se puede utilizar para JOIN
con la tabla configuration
.
Los tipos de caminos
:
SELECT distinct tag_id, tag_key, tag_value
FROM ways JOIN configuration USING (tag_id)
ORDER BY tag_id;
tag_id | tag_key | tag_value
--------+----------+----------------
104 | highway | trunk
105 | highway | trunk_link
106 | highway | primary
107 | highway | primary_link
108 | highway | secondary
109 | highway | tertiary
110 | highway | residential
111 | highway | living_street
112 | highway | service
113 | highway | track
114 | highway | pedestrian
117 | highway | path
118 | highway | cycleway
119 | highway | footway
120 | highway | bridleway
122 | highway | steps
123 | highway | unclassified
124 | highway | secondary_link
125 | highway | tertiary_link
201 | cycleway | lane
204 | cycleway | opposite
(21 rows)
En este taller, los costes se van a manipular utilizando la tabla configuración
.
3.2.1. Ejercicio 4: Ruteo de vehículos sin penalización¶
Problema:
Desde «Palacete Bolonha» hacia «Hangar Convention Center»
Solución:
Agregar una columna de penalización
Todas las carreteras tienen una
penalización
de1
(línea 3).
Consulta
El costo del vehículo en este caso será penalizado en segundos.
Los costos (en segundos) deben multiplicarse por
penalty
(líneas 12 y 13).Los costes no cambiarán (las veces 1 dejan el valor sin cambios).
La tabla
configuration
está vinculada a la tablaways
mediante el campotag_id
y usando unJOIN
(líneas 14 y 15).El vehículo va desde el vértice
717
(línea 17) al vértice20297
(línea 18).
ALTER TABLE configuration ADD COLUMN penalty FLOAT;
-- No penalty
UPDATE configuration SET penalty=1; -- line 3
SELECT *
FROM pgr_dijkstra(
'
SELECT gid AS id,
source,
target,
cost_s * penalty AS cost, -- line 12
reverse_cost_s * penalty AS reverse_cost -- line 13
FROM ways JOIN configuration -- line 14
USING (tag_id) -- line 15
',
717, -- line 17
20297); -- line 18
ALTER TABLE
UPDATE 36
seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
-----+----------+-----------+---------+-------+-------+----------------------+--------------------
1 | 1 | 717 | 20297 | 717 | 11369 | 7.649277145705279 | 0
2 | 2 | 717 | 20297 | 7674 | 11370 | 3.1979608009334255 | 7.649277145705279
3 | 3 | 717 | 20297 | 703 | 1157 | 11.04007394672912 | 10.847237946638703
4 | 4 | 717 | 20297 | 702 | 156 | 10.929693214960086 | 21.887311893367823
5 | 5 | 717 | 20297 | 88 | 21353 | 11.542936122011175 | 32.817005108327905
6 | 6 | 717 | 20297 | 15362 | 16610 | 8.333725395076964 | 44.35994123033908
7 | 7 | 717 | 20297 | 11748 | 11111 | 1.0460058812418955 | 52.69366662541604
8 | 8 | 717 | 20297 | 7483 | 192 | 1.1224871367128515 | 53.73967250665794
9 | 9 | 717 | 20297 | 114 | 15091 | 1.201966517513442 | 54.86215964337079
10 | 10 | 717 | 20297 | 10625 | 1202 | 1.2145743248659164 | 56.06412616088423
11 | 11 | 717 | 20297 | 726 | 1089 | 10.631698839302336 | 57.27870048575014
12 | 12 | 717 | 20297 | 662 | 25766 | 1.5947062700842551 | 67.91039932505248
13 | 13 | 717 | 20297 | 19160 | 21346 | 7.209317427750495 | 69.50510559513674
14 | 14 | 717 | 20297 | 15355 | 1091 | 3.664591799120692 | 76.71442302288723
15 | 15 | 717 | 20297 | 663 | 21320 | 3.676461046720907 | 80.37901482200792
16 | 16 | 717 | 20297 | 15331 | 21322 | 8.532858200977705 | 84.05547586872882
17 | 17 | 717 | 20297 | 15333 | 1204 | 5.427710167423101 | 92.58833406970652
18 | 18 | 717 | 20297 | 727 | 20367 | 7.153961955300545 | 98.01604423712962
19 | 19 | 717 | 20297 | 14631 | 26617 | 3.843378476266271 | 105.17000619243017
20 | 20 | 717 | 20297 | 19968 | 26709 | 0.17575082816994467 | 109.01338466869643
21 | 21 | 717 | 20297 | 20060 | 26583 | 2.0069671990461964 | 109.18913549686637
22 | 22 | 717 | 20297 | 19934 | 1093 | 12.47887124092446 | 111.19610269591257
23 | 23 | 717 | 20297 | 664 | 1095 | 19.508677242653324 | 123.67497393683703
24 | 24 | 717 | 20297 | 665 | 25482 | 8.279697561260365 | 143.18365117949037
25 | 25 | 717 | 20297 | 18925 | 13642 | 3.8232835830362157 | 151.46334874075075
26 | 26 | 717 | 20297 | 9453 | 20529 | 6.140981371285463 | 155.28663232378696
27 | 27 | 717 | 20297 | 14744 | 22276 | 1.141317049151238 | 161.4276136950724
28 | 28 | 717 | 20297 | 16130 | 23240 | 5.819964005493112 | 162.56893074422365
29 | 29 | 717 | 20297 | 16957 | 23242 | 1.3616887721678947 | 168.38889474971677
30 | 30 | 717 | 20297 | 16959 | 20634 | 4.376617072113684 | 169.75058352188466
31 | 31 | 717 | 20297 | 14817 | 1096 | 0.2233733506101573 | 174.12720059399834
32 | 32 | 717 | 20297 | 666 | 18926 | 1.3044471263755029 | 174.3505739446085
33 | 33 | 717 | 20297 | 13558 | 20632 | 0.046009866596978095 | 175.655021070984
34 | 34 | 717 | 20297 | 14816 | 20527 | 12.241284182800436 | 175.70103093758098
35 | 35 | 717 | 20297 | 14743 | 13665 | 8.794184121996512 | 187.9423151203814
36 | 36 | 717 | 20297 | 9472 | 1098 | 5.233961567897756 | 196.73649924237793
37 | 37 | 717 | 20297 | 667 | 3237 | 8.575989565252819 | 201.97046081027568
38 | 38 | 717 | 20297 | 2011 | 10937 | 5.753660104916916 | 210.5464503755285
39 | 39 | 717 | 20297 | 7368 | 23470 | 4.349821481768251 | 216.30011048044543
40 | 40 | 717 | 20297 | 17170 | 19253 | 2.172887473049065 | 220.64993196221369
41 | 41 | 717 | 20297 | 13851 | 22805 | 3.3127131308112716 | 222.82281943526274
42 | 42 | 717 | 20297 | 16579 | 102 | 0.5361470911814347 | 226.135532566074
43 | 43 | 717 | 20297 | 60 | 23245 | 4.560298654310812 | 226.67167965725545
44 | 44 | 717 | 20297 | 16962 | 10360 | 3.371715219110345 | 231.23197831156625
45 | 45 | 717 | 20297 | 6961 | 1644 | 3.369172847320359 | 234.6036935306766
46 | 46 | 717 | 20297 | 977 | 7943 | 2.462066055691773 | 237.97286637799695
47 | 47 | 717 | 20297 | 5225 | 7944 | 1.5097956407383146 | 240.43493243368872
48 | 48 | 717 | 20297 | 5226 | 3194 | 0.787830328173101 | 241.94472807442702
49 | 49 | 717 | 20297 | 1982 | 1647 | 4.923602780529765 | 242.73255840260012
50 | 50 | 717 | 20297 | 979 | 27195 | 4.779578061852004 | 247.65616118312988
51 | 51 | 717 | 20297 | 20543 | 15321 | 3.2620556418627746 | 252.43573924498187
52 | 52 | 717 | 20297 | 10806 | 12145 | 1.1010412528764728 | 255.69779488684466
53 | 53 | 717 | 20297 | 8265 | 1653 | 0.7265291508959483 | 256.7988361397211
54 | 54 | 717 | 20297 | 982 | 15314 | 0.687892166829071 | 257.52536529061706
55 | 55 | 717 | 20297 | 10802 | 12141 | 1.00057182891344 | 258.2132574574461
56 | 56 | 717 | 20297 | 8262 | 18325 | 7.625877296588039 | 259.21382928635956
57 | 57 | 717 | 20297 | 13082 | 3154 | 0.6911991237607362 | 266.8397065829476
58 | 58 | 717 | 20297 | 1958 | 18322 | 0.589059340205777 | 267.5309057067083
59 | 59 | 717 | 20297 | 13079 | 15309 | 7.802332894772054 | 268.1199650469141
60 | 60 | 717 | 20297 | 10799 | 3160 | 1.451915421445249 | 275.92229794168617
61 | 61 | 717 | 20297 | 1961 | 11148 | 4.1291968838076585 | 277.3742133631314
62 | 62 | 717 | 20297 | 7512 | 18328 | 5.071210660887403 | 281.50341024693904
63 | 63 | 717 | 20297 | 13085 | 3165 | 0.6588005157910573 | 286.57462090782644
64 | 64 | 717 | 20297 | 1964 | 15302 | 0.6624379620171468 | 287.23342142361753
65 | 65 | 717 | 20297 | 10795 | 15299 | 7.64331893402423 | 287.89585938563465
66 | 66 | 717 | 20297 | 10793 | 372 | 1.6185624439136164 | 295.5391783196589
67 | 67 | 717 | 20297 | 225 | 15291 | 1.5426950808720525 | 297.1577407635725
68 | 68 | 717 | 20297 | 10789 | 10414 | 8.10018215092719 | 298.7004358444446
69 | 69 | 717 | 20297 | 6993 | 10412 | 0.8010340812788996 | 306.8006179953718
70 | 70 | 717 | 20297 | 6992 | 10755 | 0.32174055743410845 | 307.6016520766507
71 | 71 | 717 | 20297 | 7236 | 15284 | 5.603200219924484 | 307.9233926340848
72 | 72 | 717 | 20297 | 10785 | 1845 | 3.4154739303977477 | 313.52659285400927
73 | 73 | 717 | 20297 | 1090 | 3174 | 4.719295193747098 | 316.942066784407
74 | 74 | 717 | 20297 | 1970 | 3172 | 2.494985805447332 | 321.6613619781541
75 | 75 | 717 | 20297 | 1968 | 7938 | 1.1336853637583644 | 324.15634778360146
76 | 76 | 717 | 20297 | 5222 | 27846 | 0.8904302856085814 | 325.29003314735985
77 | 77 | 717 | 20297 | 21150 | 339 | 0.698022009641036 | 326.18046343296845
78 | 78 | 717 | 20297 | 207 | 27848 | 0.6564041634973928 | 326.8784854426095
79 | 79 | 717 | 20297 | 21152 | 10348 | 0.9834944305474466 | 327.53488960610684
80 | 80 | 717 | 20297 | 6954 | 10056 | 2.9402965329150215 | 328.5183840366543
81 | 81 | 717 | 20297 | 6753 | 1727 | 5.355184246550181 | 331.4586805695693
82 | 82 | 717 | 20297 | 1023 | 10929 | 3.8274834071623784 | 336.81386481611946
83 | 83 | 717 | 20297 | 7362 | 1731 | 1.4213261487655227 | 340.64134822328185
84 | 84 | 717 | 20297 | 1026 | 1733 | 4.631815146870902 | 342.06267437204735
85 | 85 | 717 | 20297 | 1027 | 10921 | 3.940277020140121 | 346.69448951891826
86 | 86 | 717 | 20297 | 7358 | 12969 | 0.8433302614957165 | 350.6347665390584
87 | 87 | 717 | 20297 | 8924 | 10392 | 5.077008239497512 | 351.4780968005541
88 | 88 | 717 | 20297 | 6978 | 12971 | 3.541402184491856 | 356.5551050400516
89 | 89 | 717 | 20297 | 8926 | 24118 | 1.163994608512139 | 360.0965072245435
90 | 90 | 717 | 20297 | 17746 | 1737 | 5.407282465448289 | 361.2605018330556
91 | 91 | 717 | 20297 | 1029 | 1741 | 5.6631558817312015 | 366.66778429850393
92 | 92 | 717 | 20297 | 1032 | 24307 | 2.8288056582150825 | 372.33094018023513
93 | 93 | 717 | 20297 | 17919 | 10919 | 1.5788656574755486 | 375.1597458384502
94 | 94 | 717 | 20297 | 7356 | 99 | 1.6125042321092125 | 376.73861149592574
95 | 95 | 717 | 20297 | 59 | 97 | 1.4555596260266292 | 378.3511157280349
96 | 96 | 717 | 20297 | 58 | 15816 | 0.7379112639781683 | 379.80667535406155
97 | 97 | 717 | 20297 | 11171 | 510 | 1.0674675004507879 | 380.5445866180397
98 | 98 | 717 | 20297 | 304 | 26944 | 0.9357212700059486 | 381.6120541184905
99 | 99 | 717 | 20297 | 20297 | -1 | 0 | 382.54777538849646
(99 rows)
3.2.2. Ejercicio 5: Ruteo de vehículos con penalización¶
Concepto:
Cambiar los valores de coste de la tabla configuration
de forma que el
No se utilizan carreteras peatonales.
penalty < 0
hace que el segmento no se incluya en el grafo.
No se fomenta el uso de carreteras residenciales.
penalty > 1
hace que el segmento sea más lento para los cálculos.
El uso de carreteras «más rápidas» es muy alentador.
penalty < 1
hace que el segmento más rápido para los cálculos.
Los valores penalty
se pueden cambiar con las consultas UPDATE
.
Nota
Estos valores son una exageración.
-- Not including pedestrian ways
UPDATE configuration SET penalty=-1.0
WHERE tag_value IN ('steps','footway','pedestrian','cycleway');
-- Penalizing with 5 times the costs the unknown
UPDATE configuration SET penalty=5 WHERE tag_value IN ('unclassified');
-- Encuraging the use of "fast" roads
UPDATE configuration SET penalty=0.5 WHERE tag_value IN ('tertiary');
UPDATE configuration SET penalty=0.3
WHERE tag_value IN (
'primary','primary_link',
'trunk','trunk_link',
'motorway','motorway_junction','motorway_link',
'secondary');
Problema:
Desde «Palacete Bolonha» hacia «Hangar Convention Center» con la penalización.
Solución:
Utilizar las columnas
cost_s
(línea 6) yreverse_cost_s
(línea 7) que están en unidad desegundos
.Los costos deben multiplicarse por
penalty
(líneas 6 y 7).
La tabla
configuration
está vinculada a la tablaways
por el campo:code:tag_id mediante un campoJOIN
(líneas 8 y 9).El vehículo va de vértice
717
(línea 11) al vértice20297
(línea 12).
SELECT * FROM pgr_dijkstra(
'
SELECT gid AS id,
source,
target,
cost_s * penalty AS cost, -- line 6
reverse_cost_s * penalty AS reverse_cost -- line 7
FROM ways JOIN configuration -- line 8
USING (tag_id) -- line 9
',
717, -- line 11
20297); -- line 12
seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
-----+----------+-----------+---------+-------+-------+---------------------+--------------------
1 | 1 | 717 | 20297 | 717 | 1183 | 0.2960057352141056 | 0
2 | 2 | 717 | 20297 | 716 | 23539 | 3.5400047592944794 | 0.2960057352141056
3 | 3 | 717 | 20297 | 17233 | 16690 | 7.8358053541959585 | 3.836010494508585
4 | 4 | 717 | 20297 | 11804 | 10431 | 0.7643930526247685 | 11.671815848704544
5 | 5 | 717 | 20297 | 7006 | 13584 | 2.2684808789218165 | 12.436208901329312
6 | 6 | 717 | 20297 | 9405 | 13586 | 1.1069099932147388 | 14.70468978025113
7 | 7 | 717 | 20297 | 9406 | 26463 | 0.8553405109687702 | 15.811599773465868
8 | 8 | 717 | 20297 | 19814 | 16689 | 1.33651411869866 | 16.666940284434638
9 | 9 | 717 | 20297 | 11803 | 21121 | 0.3972810368164751 | 18.003454403133297
10 | 10 | 717 | 20297 | 15159 | 1549 | 2.9702320596337426 | 18.400735439949774
11 | 11 | 717 | 20297 | 922 | 321 | 2.77572136730283 | 21.370967499583514
12 | 12 | 717 | 20297 | 198 | 23635 | 1.0302304079691458 | 24.146688866886343
13 | 13 | 717 | 20297 | 17334 | 23637 | 0.7605955432844383 | 25.17691927485549
14 | 14 | 717 | 20297 | 17335 | 26056 | 2.2793490335041517 | 25.937514818139928
15 | 15 | 717 | 20297 | 19405 | 27290 | 1.0011633798277397 | 28.216863851644078
16 | 16 | 717 | 20297 | 20639 | 23643 | 0.7170853581581006 | 29.21802723147182
17 | 17 | 717 | 20297 | 17341 | 8117 | 0.05432648513812345 | 29.93511258962992
18 | 18 | 717 | 20297 | 5339 | 23010 | 1.5206434695923998 | 29.989439074768043
19 | 19 | 717 | 20297 | 16756 | 20374 | 1.4454066122998621 | 31.510082544360444
20 | 20 | 717 | 20297 | 14634 | 23377 | 1.6560410968556265 | 32.955489156660306
21 | 21 | 717 | 20297 | 17084 | 26684 | 1.4722213508349837 | 34.61153025351593
22 | 22 | 717 | 20297 | 20035 | 27611 | 0.08917852794242753 | 36.083751604350915
23 | 23 | 717 | 20297 | 20912 | 20329 | 0.22644193710012114 | 36.172930132293345
24 | 24 | 717 | 20297 | 14602 | 18897 | 1.898086733563235 | 36.399372069393465
25 | 25 | 717 | 20297 | 13533 | 26428 | 0.3042530905199942 | 38.2974588029567
26 | 26 | 717 | 20297 | 19779 | 26766 | 0.8862794292609869 | 38.60171189347669
27 | 27 | 717 | 20297 | 20117 | 1099 | 2.3041021996747384 | 39.48799132273768
28 | 28 | 717 | 20297 | 668 | 26855 | 0.23226015198338862 | 41.792093522412415
29 | 29 | 717 | 20297 | 20208 | 23388 | 0.4430726392125957 | 42.024353674395805
30 | 30 | 717 | 20297 | 17096 | 1101 | 0.45625095251626535 | 42.4674263136084
31 | 31 | 717 | 20297 | 669 | 27184 | 2.2656472325815242 | 42.92367726612466
32 | 32 | 717 | 20297 | 20532 | 1125 | 0.30789185698870647 | 45.189324498706185
33 | 33 | 717 | 20297 | 684 | 27612 | 2.9172937055237687 | 45.49721635569489
34 | 34 | 717 | 20297 | 20913 | 20388 | 1.5935137876166687 | 48.41451006121866
35 | 35 | 717 | 20297 | 14646 | 20389 | 3.7759663390562848 | 50.00802384883533
36 | 36 | 717 | 20297 | 14647 | 23385 | 1.3779163294442702 | 53.78399018789161
37 | 37 | 717 | 20297 | 17092 | 20391 | 0.7212891460549953 | 55.16190651733588
38 | 38 | 717 | 20297 | 14648 | 20393 | 2.088273529229889 | 55.88319566339087
39 | 39 | 717 | 20297 | 14649 | 23382 | 1.1698979217128171 | 57.97146919262076
40 | 40 | 717 | 20297 | 17089 | 20394 | 2.8020997349636643 | 59.141367114333576
41 | 41 | 717 | 20297 | 14650 | 12754 | 0.743484124264174 | 61.94346684929724
42 | 42 | 717 | 20297 | 8757 | 11995 | 0.7535548812805611 | 62.68695097356141
43 | 43 | 717 | 20297 | 8139 | 10847 | 0.17928453155545482 | 63.44050585484197
44 | 44 | 717 | 20297 | 7295 | 7967 | 1.521051231781284 | 63.619790386397426
45 | 45 | 717 | 20297 | 5243 | 25521 | 0.3977855879901294 | 65.14084161817871
46 | 46 | 717 | 20297 | 18962 | 10375 | 1.0244476150686697 | 65.53862720616884
47 | 47 | 717 | 20297 | 6970 | 2710 | 0.35838559039750933 | 66.5630748212375
48 | 48 | 717 | 20297 | 1669 | 15160 | 0.5951480500947322 | 66.92146041163501
49 | 49 | 717 | 20297 | 10678 | 15157 | 0.32541153954163504 | 67.51660846172975
50 | 50 | 717 | 20297 | 10676 | 10845 | 0.4496486476432563 | 67.84202000127138
51 | 51 | 717 | 20297 | 7294 | 10844 | 0.903123685521604 | 68.29166864891464
52 | 52 | 717 | 20297 | 7293 | 10842 | 1.0909150137845127 | 69.19479233443624
53 | 53 | 717 | 20297 | 7291 | 24811 | 0.32493410377611615 | 70.28570734822075
54 | 54 | 717 | 20297 | 18351 | 10839 | 0.8556790177023017 | 70.61064145199687
55 | 55 | 717 | 20297 | 7289 | 10826 | 0.08209178643889901 | 71.46632046969917
56 | 56 | 717 | 20297 | 7279 | 10836 | 0.9198432656860073 | 71.54841225613806
57 | 57 | 717 | 20297 | 7287 | 626 | 0.6684518844132583 | 72.46825552182408
58 | 58 | 717 | 20297 | 368 | 10372 | 4.348360854966903 | 73.13670740623733
59 | 59 | 717 | 20297 | 6968 | 10366 | 0.9233520605154579 | 77.48506826120423
60 | 60 | 717 | 20297 | 6965 | 10939 | 2.420743212977811 | 78.40842032171969
61 | 61 | 717 | 20297 | 7369 | 10363 | 1.7305037827913727 | 80.8291635346975
62 | 62 | 717 | 20297 | 6963 | 23340 | 0.31531573482697495 | 82.55966731748887
63 | 63 | 717 | 20297 | 17048 | 10938 | 1.2654733938415637 | 82.87498305231586
64 | 64 | 717 | 20297 | 7368 | 23470 | 1.304946444530475 | 84.14045644615742
65 | 65 | 717 | 20297 | 17170 | 19253 | 0.6518662419147195 | 85.44540289068789
66 | 66 | 717 | 20297 | 13851 | 22805 | 0.9938139392433815 | 86.0972691326026
67 | 67 | 717 | 20297 | 16579 | 102 | 0.1608441273544304 | 87.09108307184599
68 | 68 | 717 | 20297 | 60 | 23245 | 1.3680895962932436 | 87.25192719920042
69 | 69 | 717 | 20297 | 16962 | 10360 | 1.0115145657331035 | 88.62001679549367
70 | 70 | 717 | 20297 | 6961 | 1644 | 1.0107518541961076 | 89.63153136122678
71 | 71 | 717 | 20297 | 977 | 7943 | 0.7386198167075319 | 90.64228321542288
72 | 72 | 717 | 20297 | 5225 | 7944 | 0.45293869222149435 | 91.3809030321304
73 | 73 | 717 | 20297 | 5226 | 3194 | 0.23634909845193028 | 91.8338417243519
74 | 74 | 717 | 20297 | 1982 | 1647 | 1.4770808341589294 | 92.07019082280382
75 | 75 | 717 | 20297 | 979 | 27195 | 1.4338734185556012 | 93.54727165696275
76 | 76 | 717 | 20297 | 20543 | 15321 | 0.9786166925588323 | 94.98114507551836
77 | 77 | 717 | 20297 | 10806 | 12145 | 0.3303123758629418 | 95.95976176807719
78 | 78 | 717 | 20297 | 8265 | 1653 | 0.21795874526878448 | 96.29007414394013
79 | 79 | 717 | 20297 | 982 | 15314 | 0.2063676500487213 | 96.50803288920892
80 | 80 | 717 | 20297 | 10802 | 12141 | 0.300171548674032 | 96.71440053925764
81 | 81 | 717 | 20297 | 8262 | 18325 | 2.2877631889764114 | 97.01457208793167
82 | 82 | 717 | 20297 | 13082 | 3154 | 0.20735973712822087 | 99.30233527690808
83 | 83 | 717 | 20297 | 1958 | 18322 | 0.1767178020617331 | 99.5096950140363
84 | 84 | 717 | 20297 | 13079 | 15309 | 2.340699868431616 | 99.68641281609803
85 | 85 | 717 | 20297 | 10799 | 3160 | 0.4355746264335747 | 102.02711268452964
86 | 86 | 717 | 20297 | 1961 | 11148 | 1.2387590651422975 | 102.46268731096322
87 | 87 | 717 | 20297 | 7512 | 18328 | 1.521363198266221 | 103.70144637610552
88 | 88 | 717 | 20297 | 13085 | 3165 | 0.19764015473731716 | 105.22280957437174
89 | 89 | 717 | 20297 | 1964 | 15302 | 0.19873138860514403 | 105.42044972910905
90 | 90 | 717 | 20297 | 10795 | 15299 | 2.292995680207269 | 105.61918111771419
91 | 91 | 717 | 20297 | 10793 | 372 | 0.4855687331740849 | 107.91217679792146
92 | 92 | 717 | 20297 | 225 | 15291 | 0.46280852426161573 | 108.39774553109555
93 | 93 | 717 | 20297 | 10789 | 10414 | 2.430054645278157 | 108.86055405535717
94 | 94 | 717 | 20297 | 6993 | 10412 | 0.2403102243836699 | 111.29060870063533
95 | 95 | 717 | 20297 | 6992 | 10755 | 0.09652216723023253 | 111.530918925019
96 | 96 | 717 | 20297 | 7236 | 15284 | 1.6809600659773452 | 111.62744109224923
97 | 97 | 717 | 20297 | 10785 | 1845 | 1.0246421791193243 | 113.30840115822657
98 | 98 | 717 | 20297 | 1090 | 3174 | 1.4157885581241294 | 114.3330433373459
99 | 99 | 717 | 20297 | 1970 | 3172 | 0.7484957416341996 | 115.74883189547003
100 | 100 | 717 | 20297 | 1968 | 7938 | 0.3401056091275093 | 116.49732763710423
101 | 101 | 717 | 20297 | 5222 | 27846 | 0.26712908568257443 | 116.83743324623174
102 | 102 | 717 | 20297 | 21150 | 339 | 0.2094066028923108 | 117.10456233191431
103 | 103 | 717 | 20297 | 207 | 27848 | 0.19692124904921784 | 117.31396893480662
104 | 104 | 717 | 20297 | 21152 | 10348 | 0.29504832916423396 | 117.51089018385584
105 | 105 | 717 | 20297 | 6954 | 10056 | 0.8820889598745064 | 117.80593851302007
106 | 106 | 717 | 20297 | 6753 | 1727 | 1.6065552739650542 | 118.68802747289457
107 | 107 | 717 | 20297 | 1023 | 10929 | 1.1482450221487135 | 120.29458274685963
108 | 108 | 717 | 20297 | 7362 | 1731 | 0.4263978446296568 | 121.44282776900835
109 | 109 | 717 | 20297 | 1026 | 1733 | 1.3895445440612704 | 121.86922561363801
110 | 110 | 717 | 20297 | 1027 | 10921 | 1.1820831060420363 | 123.25877015769927
111 | 111 | 717 | 20297 | 7358 | 12969 | 0.25299907844871494 | 124.44085326374132
112 | 112 | 717 | 20297 | 8924 | 10392 | 1.5231024718492534 | 124.69385234219003
113 | 113 | 717 | 20297 | 6978 | 12971 | 1.0624206553475568 | 126.21695481403928
114 | 114 | 717 | 20297 | 8926 | 24118 | 0.3491983825536417 | 127.27937546938684
115 | 115 | 717 | 20297 | 17746 | 1737 | 1.6221847396344866 | 127.62857385194047
116 | 116 | 717 | 20297 | 1029 | 1741 | 1.6989467645193603 | 129.25075859157496
117 | 117 | 717 | 20297 | 1032 | 24307 | 0.8486416974645247 | 130.9497053560943
118 | 118 | 717 | 20297 | 17919 | 10919 | 0.47365969724266455 | 131.79834705355884
119 | 119 | 717 | 20297 | 7356 | 99 | 0.4837512696327637 | 132.2720067508015
120 | 120 | 717 | 20297 | 59 | 97 | 0.43666788780798876 | 132.75575802043426
121 | 121 | 717 | 20297 | 58 | 15816 | 0.2213733791934505 | 133.19242590824226
122 | 122 | 717 | 20297 | 11171 | 510 | 0.3202402501352363 | 133.4137992874357
123 | 123 | 717 | 20297 | 304 | 26944 | 0.2807163810017846 | 133.73403953757094
124 | 124 | 717 | 20297 | 20297 | -1 | 0 | 134.01475591857272
(124 rows)
Nota
Comparando con Ejercicio 3: Ruteo de vehículos cuando el tiempo es dinero:
El número total de registros cambió.
La secuencia de nodos cambió.
La secuencia de bordes cambió.
La ruta está evitando las carreteras residenciales que tienen
tag_id = 110
.Los costos no cambian proporcionalmente.
3.2.3. Ejercicio 6: Tiempo en segundos de la ruta penalizada¶
Problema:
Obtener el tiempo en segundos de una ruta penalizada
Solución:
Utilizar como consulta interna la consulta penalizada unida a la tabla
ways
Mantener el
edge
comogid
(línea 6)Unir usando
gid
(línea 18)
SELECT * FROM pgr_dijkstra(
$$
SELECT gid AS id, source, target, cost_s AS cost, reverse_cost_s AS reverse_cost
FROM (
-- penalized query
SELECT edge AS gid FROM pgr_dijkstra( -- line 6
'
SELECT gid AS id,
source,
target,
cost_s * penalty AS cost,
reverse_cost_s * penalty AS reverse_cost
FROM ways JOIN configuration
USING (tag_id)
',
717,
20297) ) AS edges_in_route
JOIN ways USING (gid) -- line 18
$$,
717, 20297);
seq | path_seq | start_vid | end_vid | node | edge | cost | agg_cost
-----+----------+-----------+---------+-------+-------+---------------------+--------------------
1 | 1 | 717 | 20297 | 717 | 1183 | 0.9866857840470188 | 0
2 | 2 | 717 | 20297 | 716 | 23539 | 3.5400047592944794 | 0.9866857840470188
3 | 3 | 717 | 20297 | 17233 | 16690 | 7.8358053541959585 | 4.526690543341498
4 | 4 | 717 | 20297 | 11804 | 10431 | 0.7643930526247685 | 12.362495897537457
5 | 5 | 717 | 20297 | 7006 | 13584 | 7.561602929739388 | 13.126888950162225
6 | 6 | 717 | 20297 | 9405 | 13586 | 3.6896999773824626 | 20.688491879901612
7 | 7 | 717 | 20297 | 9406 | 26463 | 2.8511350365625674 | 24.378191857284076
8 | 8 | 717 | 20297 | 19814 | 16689 | 4.455047062328867 | 27.229326893846643
9 | 9 | 717 | 20297 | 11803 | 21121 | 1.3242701227215836 | 31.68437395617551
10 | 10 | 717 | 20297 | 15159 | 1549 | 9.900773532112476 | 33.00864407889709
11 | 11 | 717 | 20297 | 922 | 321 | 9.2524045576761 | 42.909417611009566
12 | 12 | 717 | 20297 | 198 | 23635 | 3.434101359897153 | 52.16182216868567
13 | 13 | 717 | 20297 | 17334 | 23637 | 2.5353184776147946 | 55.59592352858282
14 | 14 | 717 | 20297 | 17335 | 26056 | 7.597830111680507 | 58.13124200619762
15 | 15 | 717 | 20297 | 19405 | 27290 | 3.3372112660924658 | 65.72907211787812
16 | 16 | 717 | 20297 | 20639 | 23643 | 2.3902845271936686 | 69.06628338397059
17 | 17 | 717 | 20297 | 17341 | 8117 | 0.18108828379374484 | 71.45656791116426
18 | 18 | 717 | 20297 | 5339 | 23010 | 5.068811565308 | 71.637656194958
19 | 19 | 717 | 20297 | 16756 | 20374 | 4.818022040999541 | 76.706467760266
20 | 20 | 717 | 20297 | 14634 | 23377 | 5.520136989518755 | 81.52448980126553
21 | 21 | 717 | 20297 | 17084 | 26684 | 4.9074045027832796 | 87.04462679078429
22 | 22 | 717 | 20297 | 20035 | 27611 | 0.2972617598080918 | 91.95203129356757
23 | 23 | 717 | 20297 | 20912 | 20329 | 0.7548064570004038 | 92.24929305337567
24 | 24 | 717 | 20297 | 14602 | 18897 | 6.326955778544117 | 93.00409951037607
25 | 25 | 717 | 20297 | 13533 | 26428 | 1.0141769683999808 | 99.33105528892018
26 | 26 | 717 | 20297 | 19779 | 26766 | 2.9542647642032898 | 100.34523225732016
27 | 27 | 717 | 20297 | 20117 | 1099 | 7.680340665582461 | 103.29949702152345
28 | 28 | 717 | 20297 | 668 | 26855 | 0.7742005066112955 | 110.97983768710591
29 | 29 | 717 | 20297 | 20208 | 23388 | 1.476908797375319 | 111.75403819371721
30 | 30 | 717 | 20297 | 17096 | 1101 | 1.5208365083875512 | 113.23094699109252
31 | 31 | 717 | 20297 | 669 | 27184 | 7.552157441938414 | 114.75178349948007
32 | 32 | 717 | 20297 | 20532 | 1125 | 1.026306189962355 | 122.30394094141849
33 | 33 | 717 | 20297 | 684 | 27612 | 9.724312351745896 | 123.33024713138084
34 | 34 | 717 | 20297 | 20913 | 20388 | 5.311712625388896 | 133.05455948312675
35 | 35 | 717 | 20297 | 14646 | 20389 | 12.58655446352095 | 138.36627210851566
36 | 36 | 717 | 20297 | 14647 | 23385 | 4.593054431480901 | 150.9528265720366
37 | 37 | 717 | 20297 | 17092 | 20391 | 2.404297153516651 | 155.5458810035175
38 | 38 | 717 | 20297 | 14648 | 20393 | 6.960911764099629 | 157.95017815703414
39 | 39 | 717 | 20297 | 14649 | 23382 | 3.899659739042724 | 164.91108992113377
40 | 40 | 717 | 20297 | 17089 | 20394 | 9.340332449878881 | 168.8107496601765
41 | 41 | 717 | 20297 | 14650 | 12754 | 2.478280414213913 | 178.15108211005537
42 | 42 | 717 | 20297 | 8757 | 11995 | 2.511849604268537 | 180.62936252426928
43 | 43 | 717 | 20297 | 8139 | 10847 | 0.5976151051848494 | 183.14121212853783
44 | 44 | 717 | 20297 | 7295 | 7967 | 5.07017077260428 | 183.73882723372267
45 | 45 | 717 | 20297 | 5243 | 25521 | 1.3259519599670981 | 188.80899800632696
46 | 46 | 717 | 20297 | 18962 | 10375 | 3.4148253835622326 | 190.13494996629404
47 | 47 | 717 | 20297 | 6970 | 2710 | 1.1946186346583645 | 193.54977534985628
48 | 48 | 717 | 20297 | 1669 | 15160 | 1.9838268336491074 | 194.74439398451463
49 | 49 | 717 | 20297 | 10678 | 15157 | 1.0847051318054501 | 196.72822081816375
50 | 50 | 717 | 20297 | 10676 | 10845 | 1.498828825477521 | 197.8129259499692
51 | 51 | 717 | 20297 | 7294 | 10844 | 3.0104122850720136 | 199.31175477544673
52 | 52 | 717 | 20297 | 7293 | 10842 | 3.636383379281709 | 202.32216706051875
53 | 53 | 717 | 20297 | 7291 | 24811 | 1.0831136792537206 | 205.95855043980046
54 | 54 | 717 | 20297 | 18351 | 10839 | 2.8522633923410057 | 207.0416641190542
55 | 55 | 717 | 20297 | 7289 | 10826 | 0.27363928812966337 | 209.8939275113952
56 | 56 | 717 | 20297 | 7279 | 10836 | 3.0661442189533576 | 210.16756679952485
57 | 57 | 717 | 20297 | 7287 | 626 | 2.2281729480441945 | 213.2337110184782
58 | 58 | 717 | 20297 | 368 | 10372 | 14.49453618322301 | 215.4618839665224
59 | 59 | 717 | 20297 | 6968 | 10366 | 3.0778402017181934 | 229.9564201497454
60 | 60 | 717 | 20297 | 6965 | 10939 | 8.069144043259369 | 233.03426035146362
61 | 61 | 717 | 20297 | 7369 | 10363 | 5.768345942637909 | 241.103404394723
62 | 62 | 717 | 20297 | 6963 | 23340 | 1.0510524494232498 | 246.8717503373609
63 | 63 | 717 | 20297 | 17048 | 10938 | 4.218244646138546 | 247.92280278678416
64 | 64 | 717 | 20297 | 7368 | 23470 | 4.349821481768251 | 252.1410474329227
65 | 65 | 717 | 20297 | 17170 | 19253 | 2.172887473049065 | 256.49086891469096
66 | 66 | 717 | 20297 | 13851 | 22805 | 3.3127131308112716 | 258.66375638774
67 | 67 | 717 | 20297 | 16579 | 102 | 0.5361470911814347 | 261.9764695185513
68 | 68 | 717 | 20297 | 60 | 23245 | 4.560298654310812 | 262.51261660973273
69 | 69 | 717 | 20297 | 16962 | 10360 | 3.371715219110345 | 267.07291526404356
70 | 70 | 717 | 20297 | 6961 | 1644 | 3.369172847320359 | 270.4446304831539
71 | 71 | 717 | 20297 | 977 | 7943 | 2.462066055691773 | 273.8138033304743
72 | 72 | 717 | 20297 | 5225 | 7944 | 1.5097956407383146 | 276.27586938616605
73 | 73 | 717 | 20297 | 5226 | 3194 | 0.787830328173101 | 277.7856650269044
74 | 74 | 717 | 20297 | 1982 | 1647 | 4.923602780529765 | 278.5734953550775
75 | 75 | 717 | 20297 | 979 | 27195 | 4.779578061852004 | 283.4970981356073
76 | 76 | 717 | 20297 | 20543 | 15321 | 3.2620556418627746 | 288.2766761974593
77 | 77 | 717 | 20297 | 10806 | 12145 | 1.1010412528764728 | 291.5387318393221
78 | 78 | 717 | 20297 | 8265 | 1653 | 0.7265291508959483 | 292.6397730921986
79 | 79 | 717 | 20297 | 982 | 15314 | 0.687892166829071 | 293.36630224309454
80 | 80 | 717 | 20297 | 10802 | 12141 | 1.00057182891344 | 294.0541944099236
81 | 81 | 717 | 20297 | 8262 | 18325 | 7.625877296588039 | 295.05476623883703
82 | 82 | 717 | 20297 | 13082 | 3154 | 0.6911991237607362 | 302.6806435354251
83 | 83 | 717 | 20297 | 1958 | 18322 | 0.589059340205777 | 303.3718426591858
84 | 84 | 717 | 20297 | 13079 | 15309 | 7.802332894772054 | 303.9609019993916
85 | 85 | 717 | 20297 | 10799 | 3160 | 1.451915421445249 | 311.76323489416365
86 | 86 | 717 | 20297 | 1961 | 11148 | 4.1291968838076585 | 313.21515031560887
87 | 87 | 717 | 20297 | 7512 | 18328 | 5.071210660887403 | 317.3443471994165
88 | 88 | 717 | 20297 | 13085 | 3165 | 0.6588005157910573 | 322.4155578603039
89 | 89 | 717 | 20297 | 1964 | 15302 | 0.6624379620171468 | 323.074358376095
90 | 90 | 717 | 20297 | 10795 | 15299 | 7.64331893402423 | 323.73679633811213
91 | 91 | 717 | 20297 | 10793 | 372 | 1.6185624439136164 | 331.3801152721364
92 | 92 | 717 | 20297 | 225 | 15291 | 1.5426950808720525 | 332.99867771605
93 | 93 | 717 | 20297 | 10789 | 10414 | 8.10018215092719 | 334.5413727969221
94 | 94 | 717 | 20297 | 6993 | 10412 | 0.8010340812788996 | 342.6415549478493
95 | 95 | 717 | 20297 | 6992 | 10755 | 0.32174055743410845 | 343.44258902912816
96 | 96 | 717 | 20297 | 7236 | 15284 | 5.603200219924484 | 343.76432958656227
97 | 97 | 717 | 20297 | 10785 | 1845 | 3.4154739303977477 | 349.36752980648674
98 | 98 | 717 | 20297 | 1090 | 3174 | 4.719295193747098 | 352.7830037368845
99 | 99 | 717 | 20297 | 1970 | 3172 | 2.494985805447332 | 357.5022989306316
100 | 100 | 717 | 20297 | 1968 | 7938 | 1.1336853637583644 | 359.99728473607894
101 | 101 | 717 | 20297 | 5222 | 27846 | 0.8904302856085814 | 361.1309700998373
102 | 102 | 717 | 20297 | 21150 | 339 | 0.698022009641036 | 362.02140038544593
103 | 103 | 717 | 20297 | 207 | 27848 | 0.6564041634973928 | 362.71942239508695
104 | 104 | 717 | 20297 | 21152 | 10348 | 0.9834944305474466 | 363.3758265585843
105 | 105 | 717 | 20297 | 6954 | 10056 | 2.9402965329150215 | 364.3593209891318
106 | 106 | 717 | 20297 | 6753 | 1727 | 5.355184246550181 | 367.2996175220468
107 | 107 | 717 | 20297 | 1023 | 10929 | 3.8274834071623784 | 372.65480176859694
108 | 108 | 717 | 20297 | 7362 | 1731 | 1.4213261487655227 | 376.48228517575933
109 | 109 | 717 | 20297 | 1026 | 1733 | 4.631815146870902 | 377.90361132452483
110 | 110 | 717 | 20297 | 1027 | 10921 | 3.940277020140121 | 382.53542647139574
111 | 111 | 717 | 20297 | 7358 | 12969 | 0.8433302614957165 | 386.47570349153585
112 | 112 | 717 | 20297 | 8924 | 10392 | 5.077008239497512 | 387.3190337530316
113 | 113 | 717 | 20297 | 6978 | 12971 | 3.541402184491856 | 392.3960419925291
114 | 114 | 717 | 20297 | 8926 | 24118 | 1.163994608512139 | 395.93744417702095
115 | 115 | 717 | 20297 | 17746 | 1737 | 5.407282465448289 | 397.1014387855331
116 | 116 | 717 | 20297 | 1029 | 1741 | 5.6631558817312015 | 402.5087212509814
117 | 117 | 717 | 20297 | 1032 | 24307 | 2.8288056582150825 | 408.1718771327126
118 | 118 | 717 | 20297 | 17919 | 10919 | 1.5788656574755486 | 411.00068279092767
119 | 119 | 717 | 20297 | 7356 | 99 | 1.6125042321092125 | 412.5795484484032
120 | 120 | 717 | 20297 | 59 | 97 | 1.4555596260266292 | 414.1920526805124
121 | 121 | 717 | 20297 | 58 | 15816 | 0.7379112639781683 | 415.64761230653903
122 | 122 | 717 | 20297 | 11171 | 510 | 1.0674675004507879 | 416.3855235705172
123 | 123 | 717 | 20297 | 304 | 26944 | 0.9357212700059486 | 417.452991070968
124 | 124 | 717 | 20297 | 20297 | -1 | 0 | 418.38871234097394
(124 rows)
Nota
Comparando con Ejercicio 5: Ruteo de vehículos con penalización:
El número total de registros es el mismo.
La ruta es la misma
La columna
cost
tiene los valores originales de la tablaways
.