diff --git a/examples/example_large.py b/examples/example_large.py index 0ec4112..a16cb5b 100644 --- a/examples/example_large.py +++ b/examples/example_large.py @@ -1,16 +1,15 @@ # 12 AGVs 7 zones d_max = 40 - - -from src import utils -from src.linear_solver import print_ILP_size, LinearAGV -from src.quadratic_solver import QuadraticAGV -from src.qubo_solver import annealing, constrained_solver, hybrid_anneal import pickle import time import os -from src.LinearProg import LinearProg -from src.process_results import print_results +from src import create_stations_list, create_agv_list, create_graph, create_same_way_dict, agv_routes_as_edges +from src import print_ILP_size, LinearAGV +from src import QuadraticAGV +from src import annealing, constrained_solver, hybrid_anneal + + + cwd = os.getcwd() @@ -47,15 +46,15 @@ #14: ("s5", "s6") } -stations = utils.create_stations_list(tracks) -J = utils.create_agv_list(agv_routes) -agv_routes_as_edges = utils.agv_routes_as_edges(agv_routes) -all_same_way = utils.create_same_way_dict(agv_routes) +stations = create_stations_list(tracks) +J = create_agv_list(agv_routes) +agv_routes_as_e = agv_routes_as_edges(agv_routes) +all_same_way = create_same_way_dict(agv_routes) -graph = utils.create_graph(tracks, agv_routes) +graph = create_graph(tracks, agv_routes) d_max = {i: 40 for i in J} -tau_pass = {(j, s, sp): tracks_len[(s, sp)] for j in J for s, sp in agv_routes_as_edges[j]} +tau_pass = {(j, s, sp): tracks_len[(s, sp)] for j in J for s, sp in agv_routes_as_e[j]} tau_headway = {(j, jp, s, sp): 2 if (s, sp) != ("s2", "s3") and (s, sp) != ("s3", "s2") else 0 for (j, jp) in all_same_way.keys() for (s, sp) in all_same_way[(j, jp)]} diff --git a/examples/example_largest.py b/examples/example_largest.py index bfd0aeb..e853fcc 100644 --- a/examples/example_largest.py +++ b/examples/example_largest.py @@ -1,14 +1,15 @@ # 15 AGVs 7 zones d_max = 40 - -from src import utils -from src.linear_solver import print_ILP_size, LinearAGV -from src.quadratic_solver import QuadraticAGV -from src.qubo_solver import annealing, constrained_solver, hybrid_anneal import pickle import time import os + +from src import create_stations_list, create_agv_list, create_graph, create_same_way_dict, agv_routes_as_edges +from src import print_ILP_size, LinearAGV +from src import QuadraticAGV +from src import annealing, constrained_solver, hybrid_anneal + from src.LinearProg import LinearProg -from src.process_results import print_results + cwd = os.getcwd() @@ -45,15 +46,14 @@ 14: ("s5", "s6") } -stations = utils.create_stations_list(tracks) -J = utils.create_agv_list(agv_routes) -agv_routes_as_edges = utils.agv_routes_as_edges(agv_routes) -all_same_way = utils.create_same_way_dict(agv_routes) - -graph = utils.create_graph(tracks, agv_routes) +stations = create_stations_list(tracks) +J = create_agv_list(agv_routes) +agv_routes_as_e = agv_routes_as_edges(agv_routes) +all_same_way = create_same_way_dict(agv_routes) +graph = create_graph(tracks, agv_routes) d_max = {i: 40 for i in J} -tau_pass = {(j, s, sp): tracks_len[(s, sp)] for j in J for s, sp in agv_routes_as_edges[j]} +tau_pass = {(j, s, sp): tracks_len[(s, sp)] for j in J for s, sp in agv_routes_as_e[j]} tau_headway = {(j, jp, s, sp): 2 if (s, sp) != ("s2", "s3") and (s, sp) != ("s3", "s2") else 0 for (j, jp) in all_same_way.keys() for (s, sp) in all_same_way[(j, jp)]} diff --git a/examples/example_medium.py b/examples/example_medium.py index 893427b..96513f8 100644 --- a/examples/example_medium.py +++ b/examples/example_medium.py @@ -1,18 +1,15 @@ # 7 AGVs 7 zones d_max = 40 - -from src import utils -from src import train_diagram -from src.qubo_solver import annealing, constrained_solver, hybrid_anneal -from src.linear_solver import print_ILP_size, LinearAGV -from src.quadratic_solver import QuadraticAGV -import numpy as np import pickle import time import os -from pathlib import Path -from src.LinearProg import LinearProg -from src.process_results import print_results +from src import create_stations_list, create_agv_list, create_graph, create_same_way_dict, agv_routes_as_edges +from src import plot_train_diagram +from src import annealing, constrained_solver, hybrid_anneal +from src import print_ILP_size, LinearAGV +from src import QuadraticAGV + + cwd = os.getcwd() @@ -40,15 +37,15 @@ 5: ("s6", "s5", "s4", "s3"), 6: ("s5", "s6")} -stations = utils.create_stations_list(tracks) -J = utils.create_agv_list(agv_routes) -agv_routes_as_edges = utils.agv_routes_as_edges(agv_routes) -all_same_way = utils.create_same_way_dict(agv_routes) +stations = create_stations_list(tracks) +J = create_agv_list(agv_routes) +agv_routes_as_e = agv_routes_as_edges(agv_routes) +all_same_way = create_same_way_dict(agv_routes) -graph = utils.create_graph(tracks, agv_routes) +graph = create_graph(tracks, agv_routes) d_max = {i: 40 for i in J} -tau_pass = {(j, s, sp): tracks_len[(s, sp)] for j in J for s, sp in agv_routes_as_edges[j]} +tau_pass = {(j, s, sp): tracks_len[(s, sp)] for j in J for s, sp in agv_routes_as_e[j]} tau_headway = {(j, jp, s, sp): 2 if (s, sp) != ("s2", "s3") and (s, sp) != ("s3", "s2") else 0 for (j, jp) in all_same_way.keys() for (s, sp) in all_same_way[(j, jp)]} @@ -106,7 +103,7 @@ model.print_solution(print_zeros=True) # AGV.nice_print(model, sol) <- WIP if args.train_diagram: - train_diagram.plot_train_diagram(sol, agv_routes, tracks_len, 7) + plot_train_diagram(sol, agv_routes, tracks_len, 7) if solve_quadratic: hybrid = "bqm" # select hybrid solver bqm or cqm diff --git a/examples/example_medium_small.py b/examples/example_medium_small.py index 3281e8a..08e157d 100644 --- a/examples/example_medium_small.py +++ b/examples/example_medium_small.py @@ -1,17 +1,14 @@ # 6 AGVs 7 zones d_max = 40 - -from src import utils -from src import train_diagram -from src.qubo_solver import annealing, constrained_solver, hybrid_anneal -from src.linear_solver import print_ILP_size, LinearAGV -from src.quadratic_solver import QuadraticAGV import pickle import time import os +from src import create_stations_list, create_agv_list, create_graph, create_same_way_dict, agv_routes_as_edges +from src import plot_train_diagram +from src import annealing, constrained_solver, hybrid_anneal +from src import print_ILP_size, LinearAGV +from src import QuadraticAGV -from src.LinearProg import LinearProg -from src.process_results import print_results M = 50 @@ -37,15 +34,15 @@ 4: ("s6", "s5", "s4", "s3"), 5: ("s5", "s6")} -stations = utils.create_stations_list(tracks) -J = utils.create_agv_list(agv_routes) -agv_routes_as_edges = utils.agv_routes_as_edges(agv_routes) -all_same_way = utils.create_same_way_dict(agv_routes) +stations = create_stations_list(tracks) +J = create_agv_list(agv_routes) +agv_routes_as_e = agv_routes_as_edges(agv_routes) +all_same_way = create_same_way_dict(agv_routes) -graph = utils.create_graph(tracks, agv_routes) +graph = create_graph(tracks, agv_routes) d_max = {i: 40 for i in J} -tau_pass = {(j, s, sp): tracks_len[(s, sp)] for j in J for s, sp in agv_routes_as_edges[j]} +tau_pass = {(j, s, sp): tracks_len[(s, sp)] for j in J for s, sp in agv_routes_as_e[j]} tau_headway = {(j, jp, s, sp): 2 if (s, sp) != ("s2", "s3") and (s, sp) != ("s3", "s2") else 0 for (j, jp) in all_same_way.keys() for (s, sp) in all_same_way[(j, jp)]} @@ -98,7 +95,7 @@ model.print_solution(print_zeros=True) # AGV.nice_print(model, sol) <- WIP if args.train_diagram: - train_diagram.plot_train_diagram(sol, agv_routes, tracks_len, 7) + plot_train_diagram(sol, agv_routes, tracks_len, 7) if solve_quadratic: hybrid = "bqm" # select hybrid solver bqm or cqm diff --git a/examples/example_small.py b/examples/example_small.py index 5cc8473..8721763 100644 --- a/examples/example_small.py +++ b/examples/example_small.py @@ -1,20 +1,14 @@ # 4 AGV 5 zoneas d_max = 10 example - -from src import utils -from src import train_diagram -from src.linear_solver import print_ILP_size, LinearAGV -from src.quadratic_solver import QuadraticAGV -from src.qubo_solver import annealing, constrained_solver, hybrid_anneal -import numpy as np import pickle import time import os +from src import create_stations_list, create_agv_list, create_graph, create_same_way_dict, agv_routes_as_edges +from src import plot_train_diagram +from src import print_ILP_size, LinearAGV +from src import QuadraticAGV +from src import annealing, constrained_solver, hybrid_anneal -from scipy.optimize import linprog -from src.LinearProg import LinearProg -from src.process_results import get_results, load_results, print_results, store_result -from math import sqrt cwd = os.getcwd() @@ -37,15 +31,15 @@ 4: ("s2", "s3") } -stations = utils.create_stations_list(tracks) -J = utils.create_agv_list(agv_routes) -agv_routes_as_edges = utils.agv_routes_as_edges(agv_routes) -all_same_way = utils.create_same_way_dict(agv_routes) +stations = create_stations_list(tracks) +J = create_agv_list(agv_routes) +agv_routes_as_e = agv_routes_as_edges(agv_routes) +all_same_way = create_same_way_dict(agv_routes) -graph = utils.create_graph(tracks, agv_routes) +graph = create_graph(tracks, agv_routes) d_max = {i: 10 for i in J} -tau_pass = {(j, s, sp): tracks_len[(s, sp)] for j in J for s, sp in agv_routes_as_edges[j]} +tau_pass = {(j, s, sp): tracks_len[(s, sp)] for j in J for s, sp in agv_routes_as_e[j]} tau_headway = {(j, jp, s, sp): 2 if (s, sp) != ("s2", "s3") and (s, sp) != ("s3", "s2") else 0 for (j, jp) in all_same_way.keys() for (s, sp) in all_same_way[(j, jp)]} @@ -97,7 +91,7 @@ model.print_solution(print_zeros=True) # AGV.nice_print(model, sol) <- WIP if args.train_diagram: - train_diagram.plot_train_diagram(sol, agv_routes, tracks_len, 5) + plot_train_diagram(sol, agv_routes, tracks_len, 5) if solve_quadratic: hybrid = "bqm" # select hybrid solver bqm or cqm diff --git a/examples/example_smallest.py b/examples/example_smallest.py index 644b0e0..fe85aee 100644 --- a/examples/example_smallest.py +++ b/examples/example_smallest.py @@ -1,22 +1,15 @@ # 2 AGV and 4 zones d_max = 10 import dimod - -from src import utils -from src import train_diagram -from src.linear_solver import print_ILP_size, LinearAGV -from src.quadratic_solver import QuadraticAGV -from src.qubo_solver import annealing, constrained_solver, hybrid_anneal -from pathlib import Path -import numpy as np import pickle -import csv import time import os +from src import create_stations_list, create_agv_list, create_graph, create_same_way_dict, agv_routes_as_edges +from src import plot_train_diagram +from src import print_ILP_size, LinearAGV +from src import QuadraticAGV +from src import annealing, constrained_solver, hybrid_anneal -from src.LinearProg import LinearProg -from src.process_results import print_results -from math import sqrt, log10 M = 20 tracks = [("s0", "s1"), ("s1", "s0"), @@ -34,15 +27,15 @@ 1: ("s0", "s1", "s2") } -stations = utils.create_stations_list(tracks) -J = utils.create_agv_list(agv_routes) -agv_routes_as_edges = utils.agv_routes_as_edges(agv_routes) -all_same_way = utils.create_same_way_dict(agv_routes) +stations = create_stations_list(tracks) +J = create_agv_list(agv_routes) +agv_routes_as_e = agv_routes_as_edges(agv_routes) +all_same_way = create_same_way_dict(agv_routes) -graph = utils.create_graph(tracks, agv_routes) +graph = create_graph(tracks, agv_routes) d_max = {i: 10 for i in J} -tau_pass = {(j, s, sp): tracks_len[(s, sp)] for j in J for s, sp in agv_routes_as_edges[j]} +tau_pass = {(j, s, sp): tracks_len[(s, sp)] for j in J for s, sp in agv_routes_as_e[j]} tau_headway = {(j, jp, s, sp): 2 if (s, sp) != ("s2", "s3") and (s, sp) != ("s3", "s2") else 0 for (j, jp) in all_same_way.keys() for (s, sp) in all_same_way[(j, jp)]} @@ -95,7 +88,7 @@ model.print_solution(print_zeros=True) # AGV.nice_print(model, sol) <- WIP if args.train_diagram: - train_diagram.plot_train_diagram(sol, agv_routes, tracks_len, 4) + plot_train_diagram(sol, agv_routes, tracks_len, 4) if solve_quadratic: hybrid = "bqm" # select hybrid solver bqm or cqm diff --git a/examples/example_tiny.py b/examples/example_tiny.py index 89e80fb..cf3f8fa 100644 --- a/examples/example_tiny.py +++ b/examples/example_tiny.py @@ -3,24 +3,14 @@ import dimod import minorminer from dwave.system import DWaveSampler -from src import utils -from src.linear_solver import print_ILP_size, LinearAGV -from src.quadratic_solver import QuadraticAGV -from src.qubo_solver import annealing -import numpy as np -import pickle -import csv import time import os -import json - -from math import sqrt -from src.LinearProg import LinearProg -from src.process_results import print_results -from src.quadratic_solver_CPLEX import quadratic_solve_qubo, check_solution, save_results -from src.utils import check_solution_list -from src import train_diagram +from src import create_stations_list, create_agv_list, create_graph, create_same_way_dict +from src import print_ILP_size, LinearAGV +from src import QuadraticAGV +from src import agv_routes_as_edges +from src import plot_train_diagram cwd = os.getcwd() @@ -37,15 +27,14 @@ agv_routes = {0: ("s0", "s1"), 1: ("s1", "s2")} -stations = utils.create_stations_list(tracks) -J = utils.create_agv_list(agv_routes) -agv_routes_as_edges = utils.agv_routes_as_edges(agv_routes) -all_same_way = utils.create_same_way_dict(agv_routes) - -graph = utils.create_graph(tracks, agv_routes) +stations = create_stations_list(tracks) +J = create_agv_list(agv_routes) +agv_routes_as_e = agv_routes_as_edges(agv_routes) +all_same_way = create_same_way_dict(agv_routes) +graph = create_graph(tracks, agv_routes) d_max = {i: 1 for i in J} -tau_pass = {(j, s, sp): tracks_len[(s, sp)] for j in J for s, sp in agv_routes_as_edges[j]} +tau_pass = {(j, s, sp): tracks_len[(s, sp)] for j in J for s, sp in agv_routes_as_e[j]} tau_headway = {(j, jp, s, sp): 2 for (j, jp) in all_same_way.keys() for (s, sp) in all_same_way[(j, jp)]} tau_operation = {(agv, station): 2 for agv in J for station in stations} @@ -97,7 +86,7 @@ model.print_solution(print_zeros=True) # AGV.nice_print(model, sol) <- WIP if args.train_diagram: - train_diagram.plot_train_diagram(sol, agv_routes, tracks_len, 3) + plot_train_diagram(sol, agv_routes, tracks_len, 3) if solve_quadratic: diff --git a/src/__init__.py b/src/__init__.py index 982e678..fefe25c 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -1,10 +1,10 @@ from src.process_results import ( - get_results, load_results, store_result + get_results, load_results, store_result, print_results ) from src.quadratic_solver_CPLEX import ( - load_linear_prog_object, process_result + load_linear_prog_object, process_result, quadratic_solve_qubo ) @@ -19,9 +19,12 @@ LinearAGV, print_ILP_size ) +from src.quadratic_solver import QuadraticAGV from src.qubo_solver import ( - sim_anneal, annealing + sim_anneal, annealing, constrained_solver, hybrid_anneal ) +from src.train_diagram import plot_train_diagram +