PYME.Analysis.points.traveling_salesperson.two_opt_utils module

PYME.Analysis.points.traveling_salesperson.two_opt_utils.two_opt_test(route, i, k, distances, k_max)

Test to see what distance change we’d get doing a two_opt_swap. Take everything the same up to i, then reverse i:k, then take k: normally.

Parameters
route: ndarray

Path to swap postions in

i: int

first swap index

k: int

second swap index

distances: NxN matrix of float

distances between points

k_max: pre-computed maximum value of k == distances.shape[0] -1
Returns
distance change on swap