Пример #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
Пример #3
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
def first_step(number_of_points, space_size, seed):
    points = create_points(number_of_points, space_size, seed)
    distance_mat = distance_matrix(points)
    ext = find_exterior_polygon(points, True)
    graph = [[] for j in range(len(points))]
    graph = add_polygon_to_graph(ext, graph)
    point_indices = [each for each in range(len(points))]
    new_points = eliminate_list(point_indices, ext)
    lenp = len(new_points)
    for _ in range(lenp):
        new_points, ext, graph = minimum_deviation_point_to_polygon(points, ext, distance_mat, new_points, graph)
        # pt.plot_graph(points, graph)
    graph = graph_balance(graph)
    return points, distance_mat, graph, ext
Пример #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
Пример #6
0
def method_1(number_of_points, space_size, seed):
    points = create_points(number_of_points, space_size, seed)
    distance_mat = distance_matrix(points)
    ext = find_exterior_polygon(points, True)
    graph = [[] for j in range(len(points))]
    graph = add_polygon_to_graph(ext, graph)
    new_points = eliminate_list([each for each in range(len(points))], ext)
    lenp = len(new_points)
    for _ in range(lenp):
        new_points, ext, graph = minimum_deviation_exterior_polygon(points, ext, distance_mat, new_points, graph)
    graph = graph_balance(graph)
    while len(ext) > 2:
        ext, graph = graph_correction(points, ext, graph, distance_mat)
        # plot_graph(points, graph)
    return ext, graph
Пример #7
0
def method_2(number_of_points, space_size, seed):
    points = create_points(number_of_points, space_size, seed)
    distance_mat = distance_matrix(points)
    graph = [[] for j in range(len(points))]
    exteriors = find_exterior_polygon(points, True)
    ext = exteriors[:2]
    exts = [ext]
    graph[exts[0][0]].append(exts[0][1])
    graph[exts[0][1]].append(exts[0][0])
    new_points = eliminate_list([each for each in range(len(points))], exts[0])
    lenx = len(new_points)
    for _ in range(lenx):
        exts, new_points, graph = asd(points, new_points, exts, exteriors, graph, distance_mat)
    print(exts)
    # graph = add_exterrior_polygon(points, graph)
    plot_graph(points, graph)
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