Пример #1
0
def inspect_ga_performance():
    from solver.meta_heur import AngularGeneticMinSumSolver, AngularGeneticLocalMinSumSolver
    from instance_generation import create_random_celest_graph
    dh = DataHolder(DataFrame())
    graphs = []
    ga_lms = AngularGeneticLocalMinSumSolver(cb=dh)
    ga_ms = AngularGeneticMinSumSolver(cb=dh)
    for n in range(15, 25):
        for m in range(5):
            graph = create_random_celest_graph(n)
            graphs.append(graph)
            dh.graph = graph

            ga_lms.solve(graph)
            ga_ms.solve(graph)

    df_graphs = DataFrame([{
        "graph_name": g.name ,
        "vert_amount": g.vert_amount,
        "edge_amount": g.edge_amount
    } for g in graphs])
    
    print(dh.dataFrame)
    dh.dataFrame.to_pickle("GA_comparison.pk")
    df_graphs.to_pickle("GA_comparison_graphs.pk")
def main():
    config = _load_config()
    session = get_session(config.url_path)
    graphs = []
    if config.seed is None:
        seed = int(np.random.default_rng(None).integers(np.array([2**63]))[0])
        config.seed = seed
    else:
        seed = int(config.seed)
        
    gen = np.random.default_rng(seed)
    counter = 0
    assert len(config.vertex_shape) % 2 == 0
    shapes = np.array(config.vertex_shape).reshape(round(len(config.vertex_shape)/2), 2)
    l_shapes = len(shapes)
    for n in range(config.min_n, config.max_n):
        size = config.cel_min
        while size <= config.cel_max:
            for i in range(config.repetitions):
                graphs.append(create_random_celest_graph(n,vertex_shape=shapes[counter % l_shapes], celest_bounds=(size,size+config.cel_range), seed=gen))
                counter += 1
            size += config.cel_step
    task = Task(name=config.name, task_type="CelestialGraphInstances", status=Task.STATUS_OPTIONS.FINISHED)
    # Convert the namespace config into database config
    task_config_holder = ConfigHolder.fromNamespace(config, task=task, ignored_attributes=["url_path", "name", "config"])
    task.jobs = [TaskJobs(graph=graph, task=task) for graph in graphs]
    
    
    session.add(task)
    session.commit()
    print(counter, "instances were created. Corresponding task is", task.id)
Пример #3
0
def create_graph():
    d1 = get_distance(9, 3)
    d2 = get_distance(9, 2)
    d = d1 + np.random.default_rng().random() * (d2 - d1)
    body = CelestialBody((0, 0), d, None)
    g = create_circle_n_k(9, 4)
    graph = CelestialGraph([body], g.vertices, g.edges)
    visualize_graph_2d(graph)
    for i in range(10):
        rand_g = create_random_celest_graph(9, celest_bounds=(0.4, 0.6))
        visualize_graph_2d(rand_g)
Пример #4
0
def create_graph():
    d1 = get_distance(9,3)
    d2 = get_distance(9,2)
    d = d1 + np.random.default_rng().random() * (d2-d1)
    body = CelestialBody((0,0), d, None)
    g = create_circle_n_k(9,4)
    graph = CelestialGraph([body], g.vertices, g.edges)
    visualize_graph_2d(graph)
    for i in range(10):
        for j in range(3):
            rand_c = create_random_celest_graph(9+i,celest_bounds=(0.4,0.6))
            rand_g = create_random_instance(9+i, edge_chance=random.uniform(0.3, 1))
            visualize_graph_2d(rand_g, savePath=f"instance_vis/rand_e{9+i}_{j}.pdf")
            visualize_graph_2d(rand_c, savePath=f"instance_vis/cel_e{9+i}_{j}.pdf")
Пример #5
0
def main():
    solution_example_intro()
    #color_solver_check()
    #correct_msc_instances()
    #visualize_solutions_overview()
    #visualize_geo_solutions_overview()
    #visualize_solutions_overview_second_batch()
    #bnb_sols()
    #vis_full_circle_solutions()
    return

    graphs = [
        create_random_celest_graph(i,
                                   celest_bounds=(j * 0.1 + 0.1,
                                                  j * 0.1 + 0.1),
                                   seed=None) for i in range(5, 8)
        for j in range(5)
    ]
Пример #6
0
def main():
    #solution_example_intro()
    #color_solver_check()
    #correct_msc_instances()
    #visualize_solutions_overview()
    #visualize_geo_solutions_overview()
    #visualize_solutions_overview_second_batch()
    #bnb_sols()
    #vis_full_circle_solutions()
    create_graph()

    #test_makespan_bipartite()
    #general_instances_test()
    #inspect_ga_performance()
    #_use_test()
    
    return

    graphs = [create_random_celest_graph(i, celest_bounds=(j*0.1+0.1, j*0.1+0.1), seed=None) for i in range(5, 8) for j in range(5)]