• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest May 22nd, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import datetime
2. import math
3.
4.
5. def czytanie_z_pliku(plik):
6.     mega_maszyna = []
7.
8.     file_handle = open(plik, 'r')
9.
11.
12.     zadania, maszyna = (int(val) for val in lines_list[0].split())
14.     globals()['maszyna'] = maszyna
15.
16.     mega_kursor = [0] * maszyna
17.     globals()['mega_kursor'] = mega_kursor
18.
19.     dane = [[int(val) for val in line.split()] for line in lines_list[1:]]
20.     globals()['dane'] = dane
21.
22.     for i in range(1, maszyna + 1):
23.         mini_maszyna = [0] * zadania
24.         globals()['M%s' % i] = [0] * zadania
25.         globals()['K%s' % i] = 0
26.         j = i
27.         for i in range(0, zadania):
28.             mini_maszyna[i] = dane[i][j - 1]
29.             globals()['M%s' % j][i] = dane[i][j - 1]
30.         mega_maszyna.append(mini_maszyna)
31.     globals()['mega_maszyna'] = mega_maszyna
32.
33.
34. def inicjalizacja():
35.     t = 0
36.     k = 0
37.     c_max = 0
38.     G = [];
40.     lista_pomocnicza = []
41.     pi = [0] * zadania
42.     r = mega_maszyna[0]
43.     p = mega_maszyna[1]
44.     q = mega_maszyna[2]
45.
46.     r_core = r[::]
47.     p_core = p[::]
48.     q_core = q[::]
49.
50.     q[0] = math.inf
51.     l = 0
52.
53.     globals()['r_core'] = r_core
54.     globals()['p_core'] = p_core
55.     globals()['q_core'] = q_core
56.     globals()['r'] = r
57.     globals()['k'] = k
58.     globals()['p'] = p
59.     globals()['q'] = q
60.     globals()['t'] = t
61.     globals()['l'] = l
62.     globals()['c_max'] = c_max
63.     globals()['G'] = G
64.     globals()['N'] = N
65.     globals()['lista_pomocnicza'] = lista_pomocnicza
66.     globals()['pi'] = pi
67.
68.
69. # --------------------------DEFINICJE--------------------------#
70.
71. start = datetime.datetime.now()
72. czytanie_z_pliku('data.txt')
73. inicjalizacja()
74. q_kopia = q[::]
75. Q = []
76.
77.
78. while ((G != []) or (N != [])):
79.
80.     while ((N != []) and (min(value for value in r if value != None) <= t)):
81.         e = min(value for value in r if value != None)
82.         e_arg = r.index(e)
83.
84.         G.append(e_arg)
85.         N.remove(e_arg)
86.
87.         if q[e_arg]>q[l]:
88.             p[l] = t - r[e_arg]
89.             t = r[e_arg]
90.             if p[l] > 0:
91.                 G.append(l)
92.
93.         r[e_arg] = None
94.
95.
96.         if q[0] == math.inf:
97.             q[0] = q_core[0]
98.
99.
100.     for i in range(0, len(G)):
101.         x = q[G[i]]
102.         Q.append(x)
103.
104.     if G == []:
105.         t = min(value for value in r if value != None)
106.
107.     else:
108.         e = max(value for value in Q if value != None)
109.
110.         eq = Q.index(e)
111.         e_arg = G[eq]
112.
113.         l = e_arg
114.         t = t + p[e_arg]
115.         c_max = max(c_max, t + q[e_arg])
116.
117.         G.remove(e_arg)
118.
119.     Q = []
120.     P = mega_maszyna[1]
121.
122. print('Czas wykonywania: ', c_max)
123.
124.
125. duration = datetime.datetime.now() - start
126. print(duration)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Not a member of Pastebin yet?