def test_random_grasp(): # Full random, even worst solutions alpha = 1.0 tsp_solver = base_grasp.GraspConstruct(tsp_instance, alpha=alpha, solution_factory=tsp_solution_factory, grasp_move=TSPGraspMove) task = tsp_solver.solve() assert task.is_feasible is True assert task.solution.objective == 43 # TODO no magic numbers pls
def test_greedy_grasp(): # Full greedy, bad solutions alpha = 0.0 tsp_solver = base_grasp.GraspConstruct(tsp_instance, alpha=alpha, solution_factory=tsp_solution_factory, grasp_move=TSPGraspMove) task = tsp_solver.solve() assert task.is_feasible is True assert task.solution.objective == 34 # TODO no magic numbers pls
def compute_grasp_solution(): tsp_solver = base_grasp.GraspConstruct( tsp_instance, alpha=0.0, solution_factory=tsp_solution_factory, grasp_move=TSPGraspMove) task = tsp_solver.solve() return task.solution
def compute_grasp_solution(): tsp_solution_factory = TSPSolution.as_factory(tsp.initial_city) tsp_solver = base_grasp.GraspConstruct( tsp, alpha=0.0, solution_factory=tsp_solution_factory, grasp_move=TSPGraspMove) task = tsp_solver.solve() return task.solution