Template Function ADS::twoOpt

Function Documentation

template<class T>
Nodes ADS::twoOpt(const std::vector<std::vector<T>> &D, Nodes pi, std::vector<T> *trace = nullptr)

the local search on I2 from pi, for the symmetric distances D, taking the best circuit of the neighbourhood while it improves; the costs of the circuits visited go to *trace, if given

Pre:

D is square and symmetric, and pi a permutation

Post:

a permutation of the cities