Ejemplo n.º 1
0
def test_remove_random(alns, solution):
    #pytest.set_trace()
    noise = False
    solution_manual = {0: [6, 8], 1: [7, 9]}
    repair_heuristic = alns.repair_heuristics[1]
    repair_heuristic(solution, noise)
    destroy_heuristic = destroy_factory.produce_remove_random(3)
    destroy_heuristic(solution)
    found_solution = {0: solution.routes[0].route, 1: solution.routes[1].route}
    assert (found_solution == solution_manual)
Ejemplo n.º 2
0
def test_destroy_and_repair5_1(alns, solution):
    alns._reset_algorithm()
    alns._noise = False
    repair_heuristic = alns.repair_heuristics[1]
    repair_heuristic(solution, alns._noise)
    alns._solution = solution
    alns._destroy_heuristic = destroy_factory.produce_remove_random(3)
    alns._repair_heuristic = alns.repair_heuristics[2]
    solution_manual = {0: [6, 1, 2, 0, 4, 5, 3, 8], 1: [7, 9]}
    found_solution = {0: alns._solution.routes[0].route,
                      1: alns._solution.routes[1].route}
    alns._destroy_and_repair()
    assert (found_solution == solution_manual)
Ejemplo n.º 3
0
def test_remove_random3(alns, solution):
    #pytest.set_trace()
    noise = False
    solution_manual1 = {0: [6, 2, 0, 5, 3, 8], 1: [7, 9]}
    solution_manual2 = {0: [6, 1, 0, 4, 3, 8], 1: [7, 9]}
    solution_manual3 = {0: [6, 1, 2, 4, 5, 8], 1: [7, 9]}
    repair_heuristic = alns.repair_heuristics[1]
    repair_heuristic(solution, noise)
    destroy_heuristic = destroy_factory.produce_remove_random(1)
    destroy_heuristic(solution)
    found_solution = {0: solution.routes[0].route, 1: solution.routes[1].route}
    assert (found_solution == solution_manual1
            or found_solution == solution_manual2
            or found_solution == solution_manual3)
Ejemplo n.º 4
0
def test_destroy_and_repair5_2(alns, solution):
    alns._reset_algorithm()
    alns._noise = False
    repair_heuristic = alns.repair_heuristics[1]
    repair_heuristic(solution, alns._noise)
    alns._solution = solution
    alns._destroy_heuristic = destroy_factory.produce_remove_random(1)
    alns._repair_heuristic = alns.repair_heuristics[2]
    possible_solution1 = {0: [6, 1, 2, 0, 4, 5, 3, 8], 1: [7, 9]}
    possible_solution2 = {0: [6, 1, 0, 2, 4, 5, 3, 8], 1: [7, 9]}
    possible_solution3 = {0: [6, 2, 0, 1, 4, 5, 3, 8], 1: [7, 9]}
    found_solution = {0: alns._solution.routes[0].route,
                      1: alns._solution.routes[1].route}
    alns._destroy_and_repair()
    assert (found_solution == possible_solution1
            or found_solution == possible_solution2
            or found_solution == possible_solution3)