Skip to main content

Sumber dan pengukuran

Sumber dan pengukuran

Setiap angka dan fakta dalam bab-bab tutorial berasal dari keluaran sel di bab yang sama atau dari salah satu baris tabel ini. Bab yang menulis ledger L1 merujuk ke baris L1 di bawah.

Setiap baris memiliki status:

  • MEASURED: dihitung untuk tutorial ini; baris itu menyebutkan perintah, skrip, atau eksekusi notebook yang dipakai.
  • CITED: dibaca dari sumber primer pada tanggal yang tercantum; baris itu menautkannya.
  • VERIFY: diyakini benar tetapi belum dikonfirmasi. Bab-bab tutorial tidak bergantung pada baris ini.

Tabel ini berbahasa Inggris di kedua versi bahasa halaman ini.

Ledger

ID Fact Status Source
L1 The PostGIS 3.7.0 bundle for Windows includes pgRouting 4.0.3 CITED 2026-12-04 https://postgis.net/documentation/getting_started/install_windows/released_versions/
L2 conda-forge publishes postgis 3.7.0 for Linux (64-bit and aarch64) and macOS (Intel and Apple silicon), and pgrouting 4.0.3 for 64-bit Linux and Intel macOS. Neither has a Windows build MEASURED 2026-12-04 Platforms listed by https://api.anaconda.org/package/conda-forge/postgis and https://api.anaconda.org/package/conda-forge/pgrouting
L3 In the author’s environment (numpy 2.5.4 from conda-forge, Python 3.14.10, Windows 11), a 200 x 200 matrix product in numpy ends the process with exit code 127 and no message, unless the environment variable MKL_THREADING_LAYER is SEQUENTIAL MEASURED 2026-12-04 The same one-line product run with and without the variable
L4 sample-data/cafes.csv: fifteen stops in Kota Bandung, names and positions from OpenStreetMap (Overpass API, 2026-12-03, ODbL 1.0), chosen by hand from 524 mapped cafes in and around the city. Large chains were left out and one branch was kept per name. Whether each place is open today was not checked. SHA-256 of the file: 58e915d3353e311bd73736399db01c227c3f664f24e7a7159190953d26c041a7 MEASURED 2026-12-04 sample-data/README.md
L5 PostgreSQL evaluates the recursive half of a WITH RECURSIVE query on the rows of the previous round, and repeats until a round adds none. SELECT DISTINCT ON keeps the first row of each group of equal values; which row is first is unpredictable without ORDER BY CITED 2026-12-04 https://www.postgresql.org/docs/18/queries-with.html and https://www.postgresql.org/docs/18/sql-select.html
L6 Held, M. and Karp, R. M. (1962), A Dynamic Programming Approach to Sequencing Problems, Journal of the Society for Industrial and Applied Mathematics 10(1), 196-210. Bellman, R. (1962), Dynamic Programming Treatment of the Travelling Salesman Problem, Journal of the ACM 9(1), 61-63 CITED 2026-12-04 (publication details only) https://doi.org/10.1137/0110015 and https://doi.org/10.1145/321105.321111
L7 PostgreSQL 18.7 rejects min() in the recursive half of a query: “aggregate functions are not allowed in a recursive query’s recursive term” MEASURED 2026-12-04 A small recursive query with min() and GROUP BY, run in the tutorial database
L8 sample-data/streets.csv.gz: 45,226 streets open to cars in and around Kota Bandung, selected from 64,865 OpenStreetMap ways of the classes motorway to living_street (Overpass API, data as of 2026-12-03 15:06 UTC, ODbL 1.0). In the download, 11,897 ways are marked motorcar=no, and 11,559 of these are living streets. No two different OpenStreetMap nodes in the download have the same position, so equal positions mean a shared node. SHA-256 of the file: 55ea6441d8085a29a65e5987bf84c454b30223cad9a16d0fe763cceccc4419f4 MEASURED 2026-12-04 sample-data/make_streets.py, run on the saved download; counts made from the same download
L9 In OpenStreetMap, oneway=yes follows the direction in which the way is drawn, and oneway=-1 means the opposite. junction=roundabout implies one-way traffic. junction=circular generally has one-way traffic and is drawn in the direction of traffic; two-way ones should be tagged oneway=no. A road split into two separated carriageways is drawn as two ways with oneway=yes CITED 2026-12-04 https://wiki.openstreetmap.org/wiki/Key:oneway, https://wiki.openstreetmap.org/wiki/Tag:junction%3Droundabout and https://wiki.openstreetmap.org/wiki/Tag:junction%3Dcircular
L10 pgRouting 4.0: pgr_strongComponents returns the groups of nodes that are all reachable from each other, and a negative reverse_cost means the edge does not exist in that direction. pgr_dijkstraCostMatrix uses Dijkstra’s algorithm and returns the cost for each pair of nodes, not the path. pgr_dijkstraVia returns the shortest route through a list of nodes in the given order CITED 2026-12-04 https://docs.pgrouting.org/4.0/en/pgr_strongComponents.html, https://docs.pgrouting.org/4.0/en/pgr_dijkstraCostMatrix.html and https://docs.pgrouting.org/4.0/en/pgr_dijkstraVia.html
L11 pgr_TSP in pgRouting 4.0 is an approximation for undirected graphs. Its tour is at most twice as long as the best one when the graph is undirected and fully connected, the costs are symmetric and obey the triangle inequality. Its manual recommends a cost matrix made with directed => false, gives no such guarantee for directed => true, and warns that results change depending on the input order. A start_id of 0 means any vertex CITED 2026-12-04 https://docs.pgrouting.org/4.0/en/pgr_TSP.html
L12 pgr_TSP (pgRouting 4.0.3) on the fifteen cafes of Chapter 2, start at stop 0, streets taken as two-way. Costs as computed: a loop of 66,087 m. The same costs rounded to whole metres: 60,378 m. In nine cases a stop lies on the shortest way between two others to within 1 mm. With the rounded costs, 50 sets of 200 numberings, each answer scored on the one-way costs in its better direction: 43 sets contain the exact shortest loop, and the best answer of the other seven is at most 0.41% longer. Of the 10,000 single answers, 1.1% are the exact loop and the median is 8.2% longer MEASURED 2026-12-04 Chapter 2, section 6, without round(); then the query of the two hundred tours, with '-' in md5() replaced by '-1-' to '-49-' for the other 49 sets
L13 The Boost library’s metric approximation for the Traveling Salesman Problem, which pgr_TSP uses according to its manual (the page in L11), builds a minimum spanning tree from the starting vertex and visits the vertices in a preorder walk of that tree CITED 2026-12-04 https://www.boost.org/doc/libs/1_85_0/libs/graph/doc/metric_tsp_approx.html
L14 In the conda-forge build of GRASS 8.5.0 for Windows, no tool can open an attribute table; the message is dbmi: db_open_database() not implemented. The cause is in builds made with Microsoft’s compiler. The fix was merged into the main branch on 2026-12-03 and is labelled “backport to 8.5”; the latest release on that day was 8.5.0. With the original SQLite and DBF drivers of that build, the import without attributes, v.net and v.net.salesman by length ran and gave the tour of Chapter 3, section 4, and the import with attributes stopped with that message. The outputs of Chapter 3 come from the same build with these two drivers repaired by the author CITED and MEASURED 2026-12-04 https://github.com/OSGeo/grass/issues/8291 and https://github.com/OSGeo/grass/pull/8312; the commands of sections 2 to 5 run with the original driver files
L15 v.net.salesman in GRASS 8.5 takes the cost of whole segments from attribute columns, with a separate column for the backward direction (marked experimental), and a cost of -1 closes a segment in that direction. Without a column it uses line lengths. The manual says that a heuristic is used and that the cycle “may be sub optimal”. v.net operation=connect adds points to a network, by default with a new line from the point to the closest line CITED 2026-12-04 https://grass.osgeo.org/grass85/manuals/v.net.salesman.html and https://grass.osgeo.org/grass85/manuals/v.net.html
L16 The network library of GRASS multiplies each cost by 1000 and stores it as a whole number, which drops the rest CITED 2026-12-04 Source code of GRASS 8.5, function Vect_net_build_graph: https://github.com/OSGeo/grass/blob/releasebranch_8_5/lib/vector/Vlib/net_build.c
L17 v.net.salesman starts with the two cities that have the largest cost between them. It then repeatedly takes the unused city with the largest cost to its nearest city in the cycle (with a backward column: forward and backward cost added) and inserts it where the cycle grows least. It does not improve the finished tour CITED 2026-12-04 Source code of GRASS 8.5: https://github.com/OSGeo/grass/blob/releasebranch_8_5/vector/v.net.salesman/main.c
L18 sample-data/cafe-pool.csv: positions of the 524 cafes with a name in OpenStreetMap in the area of streets.csv.gz (Overpass API, data as of 2026-12-03 15:08 UTC, ODbL 1.0). It includes the fifteen cafes of cafes.csv and branches of chains. SHA-256 of the file: 919846cf7609b5de7f49b4b1b5b4f8f4638dcfee6552aec93d2205a89cdc64c9 MEASURED 2026-12-04 sample-data/make_cafe_pool.py, run on the saved download
L19 The exact SQL query of Chapter 2, run on draws 1 to 20 of Chapter 4 by distance and by time: the cost of the best loop equals that of the NumPy function best_tour() in all 40 cases, to within 0.000001 metres or seconds MEASURED 2026-12-04 The query of Chapter 2, section 5, with SELECT i, j, cost FROM draw_leg WHERE draw = ... AND goal = ... as leg
L20 v.net.salesman (GRASS 8.5.0) run on draws 1 to 10 of Chapter 4 with one-way costs, by distance and by time, against the function farthest_insertion(): in 18 of 20 cases the same loop, in 2 cases (draws 5 and 9, by time) the same loop with two neighbouring stops swapped and the same total. On draws 4 to 10, the totals that GRASS reports are lower by at most 0.6 metres or seconds (see L16) MEASURED 2026-12-04 The GRASS project of Chapter 3, with the stops of each draw imported at full precision and connected with v.net operation=connect threshold=1
L21 Chapter 4 repeated on five further groups of 200 draws (201 to 1200), by distance and by time. In all ten cases the order of the seven methods by median is the same as in Chapter 4: pgr_TSP best of 20, one-way ignored, farthest insertion, straight lines, pgr_TSP one answer, best loop the wrong way, nearest next. Medians over all 1,000 sets, percent over the exact best: by distance 0.3, 0.6, 1.0, 2.1, 4.0, 6.5 and 16.3; by time 0.5, 1.0, 1.5, 3.9, 4.5, 8.5 and 14.8 MEASURED 2026-12-04 The steps of Chapter 4 with generate_series(201, 1200) as the draws
L22 sample-data/kecamatan.csv: 55 kecamatan in and around Kota Bandung from the boundary layer of Badan Informasi Geospasial (BIG), release 2026-06-01, borders simplified together with a tolerance of 20 m. All 524 cafes of L18 lie in the same kecamatan with the simplified borders as with the original ones. SHA-256 of the file: d54e56f5e280e651a1036f281a6b3c3e3a7dfb0e8f7c47afed1d85ff161e2444 MEASURED 2026-12-04 sample-data/make_kecamatan.py; the layer was prepared by the author from the BIG release, which BIG offers for download as BATASWILAYAH_KECAMATAN_20260601.gdb.zip: https://s.id/Fe6tI (leads to https://drive.big.go.id/s/pYLGpt5q9mEykxD). Portal: https://tanahair.indonesia.go.id/portal-web/
L23 Random sets of other sizes from the pool of Chapter 4, by distance. The exact SQL query took 1.4 s for 15 stops, 3.0 s for 16, 7.8 s for 17 and 18.9 s for 18 (one run each, on the author’s computer). Median percent over the exact best for pgr_TSP best of 20, farthest insertion, straight lines, pgr_TSP one answer, best loop the wrong way and nearest next: 8 stops 0, 0, 0.4, 0.8, 5.0, 8.8; 10 stops 0, 0.2, 1.3, 1.0, 5.8, 13.0; 12 stops 0.1, 0.5, 1.6, 2.2, 6.0, 12.8; 15 stops 0.2, 1.0, 1.9, 3.3, 6.1, 15.7; 17 stops 0.8, 1.4, 2.8, 4.8, 6.3, 16.6; 19 stops 0.5, 1.7, 2.9, 3.9, 6.2, 14.1. Number of sets: 100 for 8 to 15 stops, 60 for 17 and 12 for 19 MEASURED 2026-12-04 The functions and queries of Chapter 4 on sets drawn with a fixed NumPy seed
L24 PostGIS: a line is simple if it does not pass through the same point twice, except for its endpoints. A closed line whose only repeated point is its start is simple. ST_IsSimple tests for self-intersection and self-tangency CITED 2026-12-04 https://postgis.net/docs/using_postgis_dbmanagement.html and https://postgis.net/docs/ST_IsSimple.html
L25 sample-data/puskesmas.csv: the 48 sites with “puskesmas” in their name in the area of streets.csv.gz, out of 17,862 sites in the GeoJSON file for Indonesia that healthsites.io publishes on the Humanitarian Data Exchange (file of 2026-09-29, source OpenStreetMap contributors, ODbL). The position of a building is the centre of its bounding box. SHA-256 of the file: 2064eb78646272b468ebf75798640254fc3847c6fdf1edf362468e811a593197 MEASURED 2026-12-04 sample-data/make_puskesmas.py, run on the saved download of https://data.humdata.org/dataset/indonesia-healthsites
L26 There were 80 puskesmas in Kota Bandung in 2021, and every kecamatan had one CITED 2026-12-04 Dinas Kesehatan Kota Bandung, Profil Kesehatan Kota Bandung Tahun 2021, section on health facilities: https://dinkes.bandung.go.id/wp-content/uploads/2022/07/Profil-Kesehatan-Kota-Bandung-Tahun-2021-31102022.pdf
L27 The exact SQL query of Chapter 2 on the twenty stops of work order 1 in Chapter 5, by time: 91 s in one run and 94 s in another, on the author’s computer. It returns the same loop as HiGHS, with the same total to 0.000001 minutes MEASURED 2026-12-04 The query of Chapter 2, section 5, with the 380 costs of Chapter 5 as leg and 20 as the number of stops
L28 scipy.optimize.milp is a wrapper of HiGHS. It minimises a linear sum under linear constraints, and its variables can be required to be integers. It stops when the gap between its answer and the proven bound, relative to the answer, is at most mip_rel_gap, by default 0.0001. HiGHS is open-source software under the MIT licence CITED 2026-12-04 https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.milp.html and https://highs.dev/
L29 Dantzig, G., Fulkerson, R. and Johnson, S. (1954), Solution of a Large-Scale Traveling-Salesman Problem, Journal of the Operations Research Society of America 2(4), 393-410, shows that a certain tour of 49 cities has the shortest road distance. The method starts from a related problem with fewer constraints and adds constraints that all tours satisfy and the current answer does not CITED 2026-12-04 (publication details and abstract; the method from the second page) https://doi.org/10.1287/opre.2.4.393 and https://www.math.uwaterloo.ca/tsp/methods/dfj/index.html
L30 Presidential Regulation 21 of 2023: Indonesian government offices work five days a week, Monday to Friday (article 3), for 37 hours and 30 minutes without breaks, starting at 07:30 local time, with a break of 60 minutes, or 90 on Fridays (article 4). The details are set by each office (article 5), and other hours apply in Ramadan CITED 2026-12-04 https://peraturan.bpk.go.id/Details/247257/perpres-no-21-tahun-2023; text read at https://jdih.kemenkeu.go.id/download/9ba53f77-5b7a-48cb-ab32-6f575fd5da3e/2023perpres021.pdf
L31 The five chapters ran one after the other, from an empty database, in 20, 29, 106, 101 and 80 seconds (336 in all). The database tsp was then 142 MB. Windows 11, PostgreSQL 18.7, PostGIS 3.7.0, pgRouting 4.0.3, GRASS 8.5.0 with the table driver repaired (L14) MEASURED 2026-12-04 Time to run each notebook in id/ with nbclient on the author’s computer; SELECT pg_size_pretty(pg_database_size('tsp')); version() and pg_extension