solver
This commit is contained in:
parent
573bc9a38f
commit
37803af2de
2 changed files with 9 additions and 3 deletions
2
run.py
2
run.py
|
@ -19,8 +19,8 @@ def run(show_plots=False, verbose=False):
|
|||
instance.plot_data()
|
||||
|
||||
for init in initializers:
|
||||
solver = Solver_TSP(init)
|
||||
for improve in improvements:
|
||||
solver = Solver_TSP(init)
|
||||
solver.bind(improve)
|
||||
solver(instance, return_value=False, verbose=verbose)
|
||||
|
||||
|
|
|
@ -32,14 +32,20 @@ class Solver_TSP:
|
|||
# "best_nn": self.best_nn, "multi_fragment": self.mf}
|
||||
self.initializer = initializer
|
||||
self.methods = [initializer]
|
||||
self.name_method = "initialize with " + initializer
|
||||
self.name_method = "initialized with " + initializer
|
||||
self.solved = False
|
||||
assert initializer in self.available_initializers, f"the {initializer} initializer is not available currently."
|
||||
|
||||
def bind(self, local_or_meta):
|
||||
assert local_or_meta in self.available_improvements, f"the {local_or_meta} method is not available currently."
|
||||
self.methods.append(local_or_meta)
|
||||
self.name_method += ", improve with " + local_or_meta
|
||||
self.name_method += ", improved with " + local_or_meta
|
||||
'
|
||||
|
||||
def pop(self):
|
||||
self.methods.pop()
|
||||
self.name_method = self.name_method[::-1][self.name_method[::-1].find("improved"[::-1]) + len("improved") + 1:][
|
||||
::-1]
|
||||
|
||||
def __call__(self, instance_, verbose=True, return_value=True):
|
||||
self.instance = instance_
|
||||
|
|
Reference in a new issue