def main(): """Solve the CVRP problem.""" if len(sys.argv) != 7: print( 'Should be called as follows: python comparison_solver_gurobi_fixedstops.py [number of waypoints] [number of drones] [range of drone] [velocity of drone] [velocity of truck] [number of fixed depots for comparison]' ) return numnodes = int(sys.argv[1]) numdrones = int(sys.argv[2]) dronerange = math.ceil(float(sys.argv[3])) dronevel = float(sys.argv[4]) truckvel = float(sys.argv[5]) numdepots = int(sys.argv[6]) bound_length = 1000 #max number of vehicles is just one per node lol, vrp solver takes care of the rest numvehicles = numnodes x, y = np.random.randint(low=0, high=bound_length, size=(2, (numnodes))) x = x.tolist() y = y.tolist() vrpdata, truckdata = efficient_singledepotroad.solve_singledepotroad_fromdata( numnodes, numvehicles, dronerange, x, y) data = vrpdata['data'] manager = vrpdata['manager'] routing = vrpdata['routing'] solution = vrpdata['solution'] routedistances = truckdata['routedistances'] usednodecoords = truckdata['usednodecoords'] print("\nROUTEDISTANCES LENGTH:", len(routedistances)) print("\nUSEDNODECOORDS LENGTH:", len(usednodecoords)) depart_times, wait_times, deployments, route_times, objective, xc, yc, visit_order = truck_gurobi.tsp_truck( routedistances, usednodecoords, numdrones, dronevel, truckvel) usednodecoords = [0] + usednodecoords combined_route_times = sum(route_times.values()) print("\n--------------------") print("\nOPTIMIZED DRONE DEPLOYMENT TIME:", objective) print("LOWER BOUND TIME:", combined_route_times / float(numdrones)) complete_solver_gurobi.graph_solution(data, manager, routing, solution, depart_times, wait_times, deployments, route_times, objective, xc, yc, visit_order, usednodecoords) comparison_vrp_fixedstops.multi_fixed_depot_comparison( numnodes, numdrones, numdepots, dronerange, x, y, dronevel, truckvel)
combined_route_times = sum(route_times.values()) print("\n--------------------") print("\nOPTIMIZED DRONE DEPLOYMENT TIME:", objective) filename = "ortools_solution" complete_solver_gurobi.graph_solution(data, manager, routing, solution, depart_times, wait_times, deployments, route_times, objective, xc, yc, visit_order, usednodecoords, filename, True) usednodecoords.pop(0) else: depart_times, wait_times, deployments, route_times, objective, xc, yc, visit_order = truck_gurobi.tsp_truck( routedistances, usednodecoords, numdrones, dronevel, truckvel) usednodecoords = [0] + usednodecoords combined_route_times = sum(route_times.values()) print("\n--------------------") print("\nOPTIMIZED DRONE DEPLOYMENT TIME:", objective) filename = "gurobi_solution" complete_solver_gurobi.graph_solution(data, manager, routing, solution, depart_times, wait_times, deployments, route_times, objective, xc, yc, visit_order, usednodecoords, filename, True)
def main(): """Solve the CVRP problem.""" if len(sys.argv) != 4: print( 'Should be called as follows: python comparison_numdrones_complete.py [number of waypoints] [range of drone] [number of drones]' ) return numnodes = int(sys.argv[1]) dronerange = math.ceil(float(sys.argv[2])) numdrones = int(sys.argv[3]) bound_length = 1000 dronevel = 15 truckvels = np.logspace(-1, 3, 10) #max number of vehicles is just one per node lol, vrp solver takes care of the rest numvehicles = numnodes x, y = np.random.randint(low=0, high=bound_length, size=(2, (numnodes))) x = x.tolist() y = y.tolist() vrpdata, truckdata = efficient_singledepotroad.solve_singledepotroad_fromdata( numnodes, numvehicles, dronerange, x, y) data = vrpdata['data'] manager = vrpdata['manager'] routing = vrpdata['routing'] solution = vrpdata['solution'] routedistances = truckdata['routedistances'] usednodecoords = truckdata['usednodecoords'] print("\nROUTEDISTANCES LENGTH:", len(routedistances)) print("\nUSEDNODECOORDS LENGTH:", len(usednodecoords)) finalObjectives = [] for i in range(len(truckvels)): print("starting truck velocity ", truckvels[i], "solution") depart_times, wait_times, deployments, route_times, objective, xc, yc, visit_order = truck_gurobi.tsp_truck( routedistances, usednodecoords, numdrones, dronevel, truckvels[i]) usednodecoords = [0] + usednodecoords combined_route_times = sum(route_times.values()) print("\n--------------------") print("\nOPTIMIZED DRONE DEPLOYMENT TIME:", objective) print("LOWER BOUND TIME:", combined_route_times / float(i)) finalObjectives.append(objective) filename = str( i) + "_index_truck_velocity_solution_complete_comparison" """ to_graph = True if(truckvels[i]/dronevel < 0.05): to_graph = False """ complete_solver_gurobi.graph_solution(data, manager, routing, solution, depart_times, wait_times, deployments, route_times, objective, xc, yc, visit_order, usednodecoords, filename, False) usednodecoords.pop(0) print("TRUCK VELS: ", truckvels) print("FINAL OBJECTIVES: ", finalObjectives)
def main(): """Solve the CVRP problem.""" if len(sys.argv) != 3: print( 'Should be called as follows: python comparison_numdrones_complete.py [number of waypoints] [range of drone]' ) return numnodes = int(sys.argv[1]) dronerange = math.ceil(float(sys.argv[2])) bound_length = 1000 #max number of vehicles is just one per node lol, vrp solver takes care of the rest numvehicles = numnodes dronevel = 15 truckvel = 5 #overallObjectives = [] #for k in range(3): """ if(k == 0): truckvel = 5 if(k == 1): truckvel = 15 if(k == 2): truckvel = 45 """ velocityObjectives = [] for j in range(10): x, y = np.random.randint(low=0, high=bound_length, size=(2, (numnodes))) x = x.tolist() y = y.tolist() vrpdata, truckdata = efficient_singledepotroad.solve_singledepotroad_fromdata( numnodes, numvehicles, dronerange, x, y) data = vrpdata['data'] manager = vrpdata['manager'] routing = vrpdata['routing'] solution = vrpdata['solution'] routedistances = truckdata['routedistances'] usednodecoords = truckdata['usednodecoords'] print("\nROUTEDISTANCES LENGTH:", len(routedistances)) print("\nUSEDNODECOORDS LENGTH:", len(usednodecoords)) if (len(routedistances) > 10): x, y = np.random.randint(low=0, high=bound_length, size=(2, (numnodes))) x = x.tolist() y = y.tolist() vrpdata, truckdata = efficient_singledepotroad.solve_singledepotroad_fromdata( numnodes, numvehicles, dronerange, x, y) data = vrpdata['data'] manager = vrpdata['manager'] routing = vrpdata['routing'] solution = vrpdata['solution'] routedistances = truckdata['routedistances'] usednodecoords = truckdata['usednodecoords'] print("\nROUTEDISTANCES LENGTH:", len(routedistances)) print("\nUSEDNODECOORDS LENGTH:", len(usednodecoords)) finalObjectives = [] for i in range(1, len(routedistances) + 2): print("starting ", i, " drone solution") depart_times, wait_times, deployments, route_times, objective, xc, yc, visit_order = truck_gurobi.tsp_truck( routedistances, usednodecoords, i, dronevel, truckvel) usednodecoords = [0] + usednodecoords combined_route_times = sum(route_times.values()) print("\n--------------------") print("\nOPTIMIZED DRONE DEPLOYMENT TIME:", objective) print("LOWER BOUND TIME:", combined_route_times / float(i)) finalObjectives.append(objective) filename = str( i) + "_drone_solution_complete_comparison_truckvel_" + str( int(truckvel)) + "_iter_" + str(j) + "_numroutes_" + str( len(routedistances)) if (j == 0): complete_solver_gurobi.graph_solution( data, manager, routing, solution, depart_times, wait_times, deployments, route_times, objective, xc, yc, visit_order, usednodecoords, filename, True) else: complete_solver_gurobi.graph_solution( data, manager, routing, solution, depart_times, wait_times, deployments, route_times, objective, xc, yc, visit_order, usednodecoords, filename, False) usednodecoords.pop(0) velocityObjectives.append(finalObjectives) print("FINAL OBJECTIVES: ", finalObjectives) #overallObjectives.append(velocityObjectives) print("VELOCITY OBJECTIVES: ", velocityObjectives)