def gilletMiller(self, runFromJson, input=None): runFromJson = True with open('request.json') as jsonFile: data = jsonFile.read() options = json.loads(data) if runFromJson == False: pass print("capacity_of_the_bus = ", options["capacity_of_the_bus"]) points = input["points"] if runFromJson != True else options["points"] full_distance_matrix = input[ "full_distance_matrix"] if runFromJson != True else options[ "full_distance_matrix"] full_distance_matrix = numpy.array(full_distance_matrix) for i in range(full_distance_matrix.shape[0]): for j in range(i, full_distance_matrix.shape[1]): full_distance_matrix[i, j] = full_distance_matrix[j, i] pupils_on_each_bus_stop = input[ "pupils_on_each_bus_stop"] if runFromJson != True else options[ "pupils_on_each_bus_stop"] capacity_of_the_bus = input[ "capacity_of_the_bus"] if runFromJson != True else options[ "capacity_of_the_bus"] constraint = input["CONSTRAINT"] minimize_number_of_buses = False loader = Loader("Running Heuristics...", "Heuristics Done!", 0.1).start() solution = gillet_miller_init(points=points, D=full_distance_matrix, d=pupils_on_each_bus_stop, C=capacity_of_the_bus, L=constraint, minimize_K=minimize_number_of_buses) loader.stop() ROUTES = [] loader.__init__("Preparing Response", "Response ready!!", timeout=0.1) loader.start() for route_idx, route in enumerate(sol2routes(solution)): print("Route #%d : %s" % (route_idx + 1, route)) ROUTES.append({"routeId": route_idx + 1, "stops": route}) loader.stop() with open("response.json", "w") as outfile: json.dump({"success": True, "data": {"routes": ROUTES}}, outfile) return ROUTES
def __init__(self): Interface.__init__(self) Loader.__init__(self) Resizer.__init__(self) Processor.__init__(self) Colorizer.__init__(self) Displayer.__init__(self) getattr(self, self.args.command)()
def __init__(self, x): # Check all streams have the same number of samples self.streams = x if len(np.unique([stream.num_samples for stream in self.streams])) > 1: raise ValueError( 'Multi-stream loader has different number of samples on each stream!' ) # Call parent constructor Loader.__init__(self, self.streams[0].num_samples)
def __init__(self, x): # Prepare streams and check each has the same number of samples self.data = [v for k, v in h5py.File(x).iteritems()] if len(np.unique([len(stream) for stream in self.data])) > 1: raise ValueError( 'The different streams specified in the h5py file have different number of samples!' ) # Initialize parent class Loader.__init__(self, len(self.data[0]))
def __init__(self, *args, **kwargs): """Initialize a new ShapeLoader object. See Loader.__init__ for argument documentation. """ Loader.__init__(self, *args, **kwargs)
def __init__(self, data_set_name): Loader.__init__(self, data_set_name)
def __init__(self): Loader.__init__(self) self.__data = [] self.__load_data()
def __init__(self): Loader.__init__(self)
def __init__(self, x): self.data = x Loader.__init__(self, len(self.data))