Guest User

Untitled

a guest
Jan 8th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. import numpy as np
  2. from pprint import pprint
  3.  
  4. clients = np.random.normal(loc = 30.0, scale = 5, size=500) #[czas_obslugi] Jako, ΕΌe klient jest zawsze pierwszy, nie potrzeba clientID
  5. tables = [np.arange(40), np.zeros(40)] #[tableID, used_time]
  6.  
  7. index = 0 #index kolejnego klienta w kolejce / liczba obsluzonych stolikow
  8. time = 0
  9.  
  10. # wypelnianie pierwszych 40 stolikow
  11. for i in range(len(tables[0])):
  12.     tables[1][i] += clients[index]
  13.     index += 1 #bierzemy kolejnego klienta
  14.    
  15. #obsluga reszty kolejki do konca czasu albo konca kolejki
  16. while time < 300 and index < 500:
  17.     temp = min(tables[1])
  18.     ind_min = np.where(tables[1] == temp) #index gdzie czas obslugi jest najkrotszy
  19.    
  20.     for i in range(len(tables[0])): #przepisanie caΕ‚ej tablicy (odejmowanie najmniejszego czasu od reszty)
  21.         tables[1][i] = tables[1][i] - temp
  22.        
  23.     ind_table = np.where(tables[1] == 0) #index stolika ktory jest pusty
  24.     tables[1][ind_table] = clients[index]
  25.     index += 1
  26.     time += temp
  27.    
  28. pprint(tables)
  29. print(index)
  30. print(time)
Advertisement
Add Comment
Please, Sign In to add comment