from tspy import TSP import matplotlib.pyplot as plt from tspy.solvers import TwoOpt_solver from tspy.lower_bounds import Held_Karp from tspy.lower_bounds import Connected_LP_bound import numpy as np a = TSP() N = 100 a.read_data(np.random.rand(N, 2)) sol = TwoOpt_solver('NN') a.get_approx_solution(sol) plt.figure(figsize=(5, 5)) a.plot_solution('TwoOpt_solver') a.get_lower_bound(Connected_LP_bound()) a.get_lower_bound( Held_Karp(n_iter=1000, batch_size=50, alp_factor=1, start_alp=0.001))
from tspy import TSP from tspy.lower_bounds import Simple_LP_bound from tspy.lower_bounds import Connected_LP_bound from tspy.lower_bounds import MinCut_LP_bound from tspy.solvers import TwoOpt_solver from tspy.solvers import NN_solver import numpy as np a = TSP() N = 20 print(N) a.read_data(np.random.rand(N, 2)) a.get_approx_solution(TwoOpt_solver('NN')) a.get_approx_solution(NN_solver()) bounds = [Simple_LP_bound(), Connected_LP_bound(), MinCut_LP_bound()] for b in bounds: a.get_lower_bound(b) print(a.lower_bounds) a.get_best_solution() a.get_best_lower_bound()