Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- from pprint import pprint
- clients = np.random.normal(loc = 30.0, scale = 5, size=500) #[czas_obslugi] Jako, ΕΌe klient jest zawsze pierwszy, nie potrzeba clientID
- tables = [np.arange(40), np.zeros(40)] #[tableID, used_time]
- index = 0 #index kolejnego klienta w kolejce / liczba obsluzonych stolikow
- time = 0
- # wypelnianie pierwszych 40 stolikow
- for i in range(len(tables[0])):
- tables[1][i] += clients[index]
- index += 1 #bierzemy kolejnego klienta
- #obsluga reszty kolejki do konca czasu albo konca kolejki
- while time < 300 and index < 500:
- temp = min(tables[1])
- ind_min = np.where(tables[1] == temp) #index gdzie czas obslugi jest najkrotszy
- for i in range(len(tables[0])): #przepisanie caΕej tablicy (odejmowanie najmniejszego czasu od reszty)
- tables[1][i] = tables[1][i] - temp
- ind_table = np.where(tables[1] == 0) #index stolika ktory jest pusty
- tables[1][ind_table] = clients[index]
- index += 1
- time += temp
- pprint(tables)
- print(index)
- print(time)
Advertisement
Add Comment
Please, Sign In to add comment