Exemple #1
0
def brute_force_method(num_point, space_size, seed, plot=False):
    points = create_points(num_point, space_size, seed)
    distance_mat = distance_matrix(points)
    minimum_distance, minimum_permutation = minumum_permutation_calculation(
        points, distance_mat)
    if plot:
        plot_polygon_with_index(points,
                                minimum_permutation,
                                title=minimum_distance)
    return minimum_distance, minimum_permutation
def brute_force_improved_multiprocessing(num_point, space_size, seed, plot=False):
    if __name__ == '__main__':
        points = create_points(num_point, space_size, seed)
        distance_mat = distance_matrix(points)
        res = minumum_permutation_calculation(distance_mat, num_point)
        res = sorted(res)
        minimum_distance, minimum_permutation = res[0]
        if plot:
            plot_polygon_with_index(points, minimum_permutation, title=minimum_distance)
        return minimum_distance, minimum_permutation
def triangulation_method(number_of_points, space_size, seed, plot=False):
    points, distance_mat, graph, ext = first_step(number_of_points, space_size, seed)
    # pt.plot_graph(points, graph)
    while len(ext) > 3:
        graph, ext = second_step(points, graph, ext, distance_mat)
        # pt.plot_graph(points, graph)
    graph_sol = graph_search(graph)
    dist, route = main_route(points, graph_sol, distance_mat)
    if plot:
        plot_polygon_with_index(points, route)
    return dist
Exemple #4
0
def angle_elimination_method(number_of_points, space_size, seed, plot=False):
    angle_of_interest = 60
    points = create_points(number_of_points, space_size, seed)
    distance_mat = mesure.distance_matrix(points)
    angle_mat = mesure.angle_matrix(points)
    graph = elemination_with_certain_angle(points, angle_mat, angle_of_interest)
    graph = add_polygon_to_graph(points, graph)
    graph = graph_balance(graph)
    graph_sol = graph_search(graph, number_of_points)
    dist, route = main_route(points, graph_sol, distance_mat)
    if plot:
        pt.plot_polygon_with_index(points, route)
    return dist
Exemple #5
0
def mean_angle_elemination_method(number_of_points, space_size, seed, plot=False):
    points = create_points(number_of_points, space_size, seed)
    angle_mat = angle_matrix(points)
    distance_mat = distance_matrix(points)
    angle_sep = angle_seperation(points, angle_mat)
    seperation = harmonic_mean_angle_seperation(angle_sep)
    new_graph = elemination_with_nearst(points, seperation, distance_mat)
    new_graph = graph_balance(new_graph)
    graph_sol = graph_search(new_graph)
    dist, route = main_route(points, graph_sol, distance_mat)
    # pt.plot_graph(points, new_graph)
    if plot:
        plot_polygon_with_index(points, route)
    return dist
def new_angle_elimination_method(number_of_points,
                                 space_size,
                                 seed,
                                 plot=False):
    angle_of_interest = 60
    points = create_points(number_of_points, space_size, seed)
    distance_mat = distance_matrix(points)
    angle_mat = angle_matrix(points)
    graph = deviation_angle_calculation(points, angle_of_interest, angle_mat,
                                        distance_mat)
    exterior = find_exterior_polygon(points, with_indices=True)
    graph = add_polygon_to_graph(exterior, graph)
    graph = graph_balance(graph)
    graph_sol = graph_search(graph)
    dist, route = main_route(points, graph_sol, distance_mat)
    if plot:
        plot_polygon_with_index(points, route)
    return dist