Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8041

Off topic discussion • Re: A bit of Raspberry with 144C/288T

$
0
0
Back from family weekend, I will respond to the mona-lisa100k.tsp related questions+comments later.
...
The code assumes that the vector is the longer diagonal.
It determines all possible integer coordinate points with at most ceil(sqrt(4^2+5^2))=7 euclidean distance to vector (from 0 to Z):
https://github.com/Hermann-SW/RR/blob/main/tsp/tst.cpp
tst.cpp.1st.png
tst.cpp.1st.png
Next I will determine all pairs of points, with
  • one above and one below the vector
  • with distance at most vector length (7 here)
  • with line between both points intersecting the fixed vector
For the identified valid pairs it is checked together with initial pair, whether TSP with crossing is shorter than simple polygon with nint(sqrt(...)) euc_2d().
I am done with that code:
https://github.com/Hermann-SW/RR/blob/main/tsp/tst.cpp

For @ejolson's example with points (0,0) and (4,5), there is a non-simple polygon optimal TSP with minimal distance between the four points of 3, and not 1 as in his example:
IMG_20250907_202759.15pc.jpg

With coordinates (0,0) and (50,38) different pairs of points with minimal euc_2d() distance between 28 and 31 get reported. One point always is very close to the line between mentioned two points. This is the only with distance greater than 1 to that line, and minimal distance between the 4 points of 29 (minimal distance for mona-lista100K.tsp is 28):

Code:

hermann@j4105:~/RR/tsp$ cpplint --filter=-legal/copyright,-runtime/references tst.cpp Done processing tst.cpphermann@j4105:~/RR/tsp$ cppcheck --enable=all --suppress=missingIncludeSystem tst.cpp Checking tst.cpp ...hermann@j4105:~/RR/tsp$ g++ -O3 -Wall -Wextra -pedantic -Wno-narrowing tst.cpp hermann@j4105:~/RR/tsp$ time ./a.out | grep ";1\."74,54 24,20  (29;1.40125,28.8444)real0m19,919suser0m19,638ssys0m0,277shermann@j4105:~/RR/tsp$ 

Code:

$ gp -q? round(sqrt(24^2+20^2))31? 
New 29.tsp example with those 4 coordinates demonstrates that simple polygon TSP tour is longer than non-simple polygon:

Code:

hermann@j4105:~/RR/tsp$ ./greedy 29 -m 0 -i 29.simple_polygon.tour -1           init_dist() [4us]183           global minimum184           local minimum found (0 greedy mutations; seed=1757270683)0           ms (only recreate)hermann@j4105:~/RR/tsp$ 

Statistics: Posted by HermannSW — Sun Sep 07, 2025 6:46 pm



Viewing all articles
Browse latest Browse all 8041

Trending Articles