Open folterj opened 1 year ago
Hi,
could you give minimal working example? What does your matrix look like?
Hi @BraveDistribution No problem:
import numpy as np
from pytsp.lin_kerdighan_tsp import lin_kerdighan_tsp
distance_matrix = np.array([
[ np.inf, 0.316493 , 0.33081796, 0.26269698, 0.31504481, 0.27552974, 0.30164198, 0.32506585, 0.28196352, 0.3035948 ],
[0.316493 , np.inf, 0.2585015 , 0.27938199, 0.25343369, 0.26129902, 0.25567885, 0.27246096, 0.2726916 , 0.29304181],
[0.33081796, 0.2585015 , np.inf, 0.29488479, 0.28153239, 0.31080125, 0.28012469, 0.32240093, 0.34206161, 0.32961145],
[0.26269698, 0.27938199, 0.29488479, np.inf, 0.31083542, 0.2752112 , 0.28986822, 0.32170974, 0.28103724, 0.29275725],
[0.31504481, 0.25343369, 0.28153239, 0.31083542, np.inf, 0.26896711, 0.29635096, 0.28088729, 0.26179473, 0.28329585],
[0.27552974, 0.26129902, 0.31080125, 0.2752112 , 0.26896711, np.inf, 0.27898233, 0.33569306, 0.26398696, 0.28110992],
[0.30164198, 0.25567885, 0.28012469, 0.28986822, 0.29635096, 0.27898233, np.inf, 0.29100124, 0.33064719, 0.29014288],
[0.32506585, 0.27246096, 0.32240093, 0.32170974, 0.28088729, 0.33569306, 0.29100124, np.inf, 0.33081947, 0.29602109],
[0.28196352, 0.2726916 , 0.34206161, 0.28103724, 0.26179473, 0.26398696, 0.33064719, 0.33081947, np.inf, 0.29918839],
[0.3035948 , 0.29304181, 0.32961145, 0.29275725, 0.28329585, 0.28110992, 0.29014288, 0.29602109, 0.29918839, np.inf]
])
order = lin_kerdighan_tsp(distance_matrix)
I'm unable to get lin_kerdighan_tsp() working. e.g. lin_kerdighan_tsp(distance_matrix)
From the function arguments I'm assuming it is used the same as christofides_tsp() - this function works fine using the same distance_matrix. Reading the readme and ReadTheDocs.io pages seems to miss function usage.
Python version 3.8 Pytsp version 0.2.7