Fourier-basis constructive solver
A tour is a closed curve γ(s) = Σ c_k·e^{2πiks}; gradient descent shapes the curve, an argsort decodes it into a valid tour.
Every tour is drawn as a single closed curve in the plane, γ(s) = Σ c_k · e^{2πiks}, sampled at M points. A small set of complex coefficients c_k (here 2K+1 = 9 of them) is the entire search space — gradient descent only ever moves these 9 numbers.
To turn the curve into a tour, every city snaps to its nearest sample point on the loop (argsort decode, dashed line above). Because a sort can never produce duplicates or skip a city, the result is always a valid Hamiltonian tour — even before training finishes.
Try the other two tabs: Modes shows what each frequency contributes to the loop shape, and Train runs the actual coarse-to-fine gradient descent live in your browser.