Good that I took the time needed to investigate this.With the last commits I introduced a slowdown of the recreates, which I am debugging.
In this posting I confirmed @ejolson's claims that using dist(CC[a],CC[b]) is faster than using D[a][b]:
viewtopic.php?t=390765&sid=ae2a4d8bc77b ... 5#p2335207
For AMD 7950X CPU single threaded (with >5.5GHz) all_.cpp is 76293824 / 45356407 = 1.68× faster
For Xeon 2680v4 CPU single threaded all_.cpp is 274323815 / 158094868 = 1.74× faster
My previous posting statement was related to execution of ./validate which does run greedy with seed 670 for pcb442 problem. Indeed for those (small, only 442 cities) TSP each individual recreate got slower, here seen for RR_all:
Code:
pi@raspberrypi5:~/RR/tsp/comp $ grep RR_all * | sed "s/ [ ]*/ /g;s/\x9*//g"____7950x.txt:0: 58136 RR_all() [210us] |0: 58136 RR_all() [628us]E5-2680v4.txt:0: 58136 RR_all() [485us] |0: 58136 RR_all() [1168us]_x3950-X6.txt:0: 58136 RR_all() [969us] |0: 58136 RR_all() [1489us]pi@raspberrypi5:~/RR/tsp/comp $Running mona-lisa100K.tsp on 7950X CPU PC is not possible, as it uses more than its 32GB RAM.
So I used usa13509.tsp that uses slightly less than 1GB RAM.
With "git checkout 570b6cc" and running
Code:
time ./greedy -m 0 -s 1234 ../data/tsp/usa13509 2>&1 | sed "s/\xd/\n/g"Code:
-1 init_dist() [6468346us]...0: 22715332 RR_all() [868496us]...real0m7.409sCode:
-1 init_dist() [15482648us]...0: 22715332 RR_all() [2704676us]...real0m18.318sCode:
time ./greedy -m 0 -s 1234 ../data/tsp/usa13509 2>&1 | sed "s/\xd/\n/g"Code:
-1 init_dist() [25140208us]...0: 22715332 RR_all() [456642us]...real0m25.637sCode:
-1 init_dist() [49077715us]...0: 22715332 RR_all() [1861007us]...real0m51.019sSo the RR_all got better after removing the distance matrix!
Code:
868496us -> 456642us 2704676us -> 1861007usReason is the runtime for init_dist(), something is really wrong there
(performance wise, ./validate verified that no execution changes for the complete pcb442 TSP happened) ...
P.S:
init_dist() time is getting much slower, although no initializing of the distance matrix D happens.
Statistics: Posted by HermannSW — Fri Sep 12, 2025 6:45 pm