need a final check and should be done

This commit is contained in:
Dario Mantegazza 2020-09-28 11:56:36 +02:00
parent d3d41d5923
commit c75ecc3d5b
2 changed files with 14 additions and 13 deletions

8
run.py
View file

@ -1,3 +1,4 @@
import glob
import pandas as pd
from src.io_tsp import ProblemInstance
from src.TSP_solver import SolverTSP, available_improvers, available_solvers
@ -22,8 +23,8 @@ def use_solver_to_compute_solution(solver, improve, index, results, name, verbos
def run(show_plots=False, verbose=False):
# problems = glob.glob('./problems/*.tsp')
problems = ["./problems/eil76.tsp"]
problems = glob.glob('./problems/*.tsp')
# problems = ["./problems/eil76.tsp"]
solvers_names = available_solvers.keys()
improvers_names = available_improvers.keys()
results = []
@ -52,8 +53,7 @@ def run(show_plots=False, verbose=False):
if prob_instance.exist_opt and show_plots:
solver = SolverTSP("optimal", prob_instance)
# solver.name_method = "optimal" # TODO ask umberto details
solver.solved = True
solver.solution = np.concatenate([prob_instance.optimal_tour, [prob_instance.optimal_tour[0]]])
solver.plot_solution()

View file

@ -15,9 +15,9 @@ class ProblemInstance:
points: ndarray
def __init__(self, name_tsp):
self.read_instance(name_tsp)
self.exist_opt = False # TODO determine default value
self.exist_opt = False
self.optimal_tour = None
self.read_instance(name_tsp)
def read_instance(self, name_tsp):
# read raw data
@ -57,6 +57,7 @@ class ProblemInstance:
print('name: ' + self.name)
print('nPoints: ' + str(self.nPoints))
print('best_sol: ' + str(self.best_sol))
print('exist optimal: ' + str(self.exist_opt))
def plot_data(self):
plt.figure(figsize=(8, 8))