def customer(self): custom = Customers() custom.passers() self.old = custom.old self.normal = custom.normal self.jogger = custom.jogger self.customers = custom.custom
def main(): taxi1 = Taxi('Kia') dr1 = Driver('Armen', 1) dr2 = Driver('Karen', 2, 'Free') dr3 = Driver('Aram', 3, 'Busy') dr_list = Drivers() dr_list.addDriver(dr1) dr_list.addDriver(dr2) dr_list.addDriver(dr3) cus1 = Customer('Mari', 1) cus2 = Customer('Ani', 2) cus_list = Customers() cus_list.addCustomer(cus1) cus_list.addCustomer(cus2) print(cus_list.customers) dis = Dispatcher(dr_list) taxi1.drivers = dr_list taxi1.customers = cus_list.customers taxi1.dispatcher = dis print(taxi1.customers) cus1.request_taxi() ride1 = taxi1.start_ride() print(ride1.created_at)
def main(): np.random.seed(7890) # recebendo instâncias r = ReadingDatas("dat/p01") r.readFile() # adicionando clientes Customers.addCustomers(r) # for cst in Customers.get_customersList().values(): # print(cst) # adicionando depósitos Depots.addDepots(r) # print("\n\n\n\") # for dpt in Depots.get_depotsList().values(): # print(dpt) # cálculo das distâncias Distances.euclidianDistanceAll(Customers.get_customersList(), Depots.get_depotsList()) # for cst in Customers.get_customersList(): # print(cst) # print(Customers.get_customersList()[cst].get_depotsDistances()) # print("\n\n\n") # for cst in Customers.get_customersList(): # print(cst) # print(Customers.get_customersList()[cst].get_neighborsDistances()) ga = GA() ga.GA()
def test_add_customer(self): customers = Customers() customer_1 = Customer("001","jack", 0, []) customer_2 = Customer("002","jack2", 0, []) customers.add_customer(customer_1) customers.add_customer(customer_2) self.assertEqual(len(customers.dictionary), 2)
def test_get_customer_info(self): customers = Customers() customer_1 = Customer("001","jack", 0, []) customers.add_customer(customer_1) self.assertEqual(customers.dictionary, {'001': ['jack', 0, []]}) self.assertEqual(customers.get_customer_rented("001"), 0) self.assertEqual(customers.get_customer_rentedArray("001"), [])
def main(): DBconnection() db = DBconnection.getInstance().connection while True: print("Acciones a realizar: \n \ 1. Cliente\n \ 2. Categorías de item\n \ 3. Items\n \ 4. Factura\n \ 5. Salir") action = input("Ingrese el número de la acción que desea realizar: ") if action == "1": customer = Customers(db) elif action == "2": category = ItemCategories(db) elif action == "3": item = Items(db) elif action == "4": bill = Bills(db) elif action == "5": exit() else: print("Ingrese un número válido")
def main(SEED, POP, DESC, PROB_MUT, PROB_LS_POP, PROB_LS, PROB_LSB, PROB_LSBP, GEN_ILS, GEN_ILSA, DATFILE, INSTANCE): # redefinindo variáveis conforme Package Irace # config.FRAC_MAX_DISTRIBUTION = FRAC config.SIZE_POP = POP config.SIZE_DESC = DESC config.PROB_MUTATION = PROB_MUT config.PROB_LS_POP = PROB_LS_POP config.PROB_LS = PROB_LS config.PROB_LS_BEST = PROB_LSB config.PROB_LS_BEST_P = PROB_LSBP config.GEN_ILS = GEN_ILS config.GEN_ILSA = GEN_ILSA seed = SEED timeIni = time.time() # exit(0) # recebendo instâncias r = ReadingDatas(INSTANCE) r.readFile() # adicionando clientes Customers.addCustomers(r) # adicionando depósitos Depots.addDepots(r) # cálculo das distâncias Distances.euclidianDistanceAll(Customers.get_customersList(), Depots.get_depotsList()) ga = GA() best = ga.GA(seed) cost = best.get_cost() timeEnd = (time.time() - timeIni) / 60.0 logging.debug("Melhor indivíduo: %s" % best) logging.debug("tempo total: " + str(timeEnd) + " minutos.") logging.debug("------------fim algoritmo genético-----------") with open(DATFILE, 'w') as f: f.write(str(cost))
class Rent: while True: customer = Customers(name=input('Enter your name: ')) customer_car = addCustomer(customer) print(customer.get_customer_name()) calculatePrice(customer_car) customer.clear_cars() if input( "If you want to add another customer insert 'yes' or 'no' (default 'no')" ) == "yes": continue break
def definePopulation(self, size): LS = ls() # Heurística do vizinho mais próximo customers = list(csts.get_customersList().values()) cst0 = customers[np.random.randint(len(customers)-1)] tour = NearestNeighbor.nearestNeighbor(cst0) cluster = SplitDepots.splitByDepot(tour) # criação de rotas por depósitos, individual é um Solution individual = split.splitLinear(cluster) # print(individual) # print(individual.get_routes()) rand = np.random.random() if rand < config.PROB_LS_POP: individual = LS.LS(individual) self.addIndividual(individual) # print(individual) # exit(1) # print(individual.get_routes()) # exit(1) # “cluster first and then route” cluster = SplitDepots.GilletJohnson() # divisão por depósitos # criação de rotas por depósitos, individual é um Solution individual = split.splitLinear(cluster) # print(individual) # print(individual.get_routes()) rand = np.random.random() if rand < config.PROB_LS_POP: individual = LS.LS(individual) # print(individual) # print(individual.get_routes()) if individual is not None and self.is_different(individual): self.addIndividual(individual) # for i in self._population: # print(i) # self.verifyNodes(i) # exit(1) # formação de rotas aleatórias self.formRandomPopulation(size) self.sortPopulation() # for i in self._population: # print(i) print(len(self._population)) return self._population
def GilletJohnson(): SplitDepots._individual = Solution() SplitDepots._availableDepots = [] customersList = copy.deepcopy(csts.get_customersList()) # dicionário for dpt in dpts.get_depotsList(): SplitDepots._availableDepots.append( [dpt, dpts.get_depotsList()[dpt].get_loadTotal(), 0.0, 0] ) # depósito, carga totaL,demanda total atendida,clientes alocados unallocatedCustomers = SplitDepots.GilletJohnsonProcedure( customersList, len(SplitDepots._availableDepots)) # print("verificando") # print(SplitDepots._individual) return SplitDepots._individual
def __init__(self, username=None, password=None, timeout=TIMEOUT, url=DEFAULT_URL): self.general = General(self) self.model = Model(self) self.actions = Actions(self) self.groups = Groups(self) self.customers = Customers(self) self.segments = Segments(self) self.integrations = Integrations(self) self.timeout = timeout self._url = url if username and password: self.general.login(username, password)
user3 = User(person3.name, person3.document_type, person3.id_crn, person3.phone, person3.address, "Jen", "*****@*****.**", 323) toy_store.add_new_user(user3) # b) Adding new warehouse staff employee1 = Warehousestaff(user1.name, user1.document_type, user1.id_crn, user1.phone, user1.address, user1.username, user1.email, user1.password, "role1", 12, 30000.90) toy_store.add_new_warehousestaff(employee1) # c) Adding new customers customer1 = Customers(user2.name, user2.document_type, user2.id_crn, user2.phone, user2.address, user2.username, user2.email, user2.password, " ") toy_store.add_new_customer(customer1) # d) Adding new sellers seller1 = Marketplace(user3.name, user3.document_type, user3.id_crn, user3.phone, user3.address, user3.username, user3.email, user3.password, "Paul", 123244354, "", 0, 323, True, 30) toy_store.add_new_marketplace_vendor(seller1) # e) Adding new website products website_product1 = Website_Products("Barbie Bee", 345, "Dolls", 20.00, True, 3,
def definePopulation(self, size): LS = ls() # Heurística do vizinho mais próximo for cst in csts.get_customersList(): tour = NearestNeighbor.nearestNeighbor( csts.get_customersList()[cst]) break cluster = SplitDepots.splitByDepot(tour) # criação de rotas por depósitos, individual é um Solution individual = split.splitLinear(cluster) # print(individual) # print(individual.get_routes()) rand = np.random.random() if rand < config.PROB_LS_POP: individual = LS.LS(individual) self.addIndividual(individual) # print(individual) # exit(1) # print(individual.get_routes()) # exit(1) # “cluster first and then route” cluster = SplitDepots.GilletJohnson() # divisão por depósitos # criação de rotas por depósitos, individual é um Solution individual = split.splitLinear(cluster) # print(individual) # print(individual.get_routes()) rand = np.random.random() if rand < config.PROB_LS_POP: individual = LS.LS(individual) # print(individual) # print(individual.get_routes()) if individual is not None and self.is_different(individual): self.addIndividual(individual) # formação de rotas aleatórias for i in range(2 * size): if len(self._population) >= size: break seed = i + int(500 * np.random.random()) cluster = SplitDepots.randomDistribution(seed) # criação de rotas por depósitos, individual é um Solution individual = split.splitLinear(cluster) # print(individual) # print(individual.get_routes()) rand = np.random.random() if rand < config.PROB_LS_POP: individual = LS.LS(individual) if individual is not None and self.is_different(individual): self.addIndividual(individual) # print(individual) # print(individual.get_routes()) # exit(1) # exit(1) self.sortPopulation() # for i in self._population: # print(i) # self.verifyNodes(i) print(len(self._population)) return self._population
def definePopulation(self, size): timeI = time.time() LS = ls() split = splitAlg() # Heurística do vizinho mais próximo customers = list(csts.get_customersList().values()) cst0 = customers[np.random.randint(len(customers) - 1)] # cst0 = customers[0] tour = NearestNeighbor.nearestNeighbor(cst0) cluster = SplitDepots.splitByDepot(tour) # criação de rotas por depósitos, individual é um Solution individual = split.splitLinear(cluster, True) # individual = split.mountRoutes(cluster) # print(individual) # print(individual.get_routes()) # rand = np.random.random_sample() # if rand < config.PROB_LS_POP: # individual = LS.LS(individual) individual = self.localSearch(individual, timeI) self.addIndividual(individual) # print(individual) # exit(1) # print(individual.get_routes()) # exit(1) # “cluster first and then route” cluster = SplitDepots.GilletJohnson() # divisão por depósitos # criação de rotas por depósitos, individual é um Solution individual = split.splitLinear(cluster, True) # individual = split.mountRoutes(cluster) # print(individual) # print(individual.get_routes()) # rand = np.random.random_sample() # if rand < config.PROB_LS_POP: # individual = LS.LS(individual) individual = self.localSearch(individual, timeI) # print(individual) # print(individual.get_routes()) if individual is not None and self.is_different(individual): self.addIndividual(individual) # for i in self._population: # print(i) # self.verifyNodes(i) # exit(1) # formação de rotas aleatórias self.formRandomPopulation(size, timeI) # individual = np.random.choice(self._population, 1)[0] # individual = self.localSearch(individual, timeI) self.sortPopulation() # print(self.showBestSolution()) # individual = self.localSearch(self.showBestSolution(), timeI) # self._population[len(self._population)-1] = individual # print(self.showBestSolution()) # self.sortPopulation() # for i in self._population: # print(i) # print(i.get_routes()) # print(i.get_cost()) # print(i.get_nRoutesByDepot()) # print(self.showBestSolution().get_routes()) # print(self.showBestSolution().get_cost()) # print(self.showBestSolution().get_nRoutesByDepot()) # self.test(self.showBestSolution()) # exit(1) # print(len(self._population)) print("Tempo população: {} minutos".format((time.time() - timeI) / 60)) return self._population
import tornado.ioloop import tornado.web from customers import Customers from addhandler import AddHandler from delhandler import DelHandler from gethandler import GetHandler customers = Customers() class MainHandler(tornado.web.RequestHandler): def get(self): self.write("Customers Microservice v1") def make_app(): return tornado.web.Application([ (r"/v1", MainHandler), (r"/v1/addcust", AddHandler, dict(customers = customers)), (r"/v1/delcust", DelHandler, dict(customers = customers)), (r"/v1/getcust", GetHandler, dict(customers = customers)), ]) if __name__ == "__main__": app = make_app() app.listen(8888) tornado.ioloop.IOLoop.current().start()