Skip to content

Commit 5213479

Browse files
committed
Hampir kelar non-delay
Hampir kelar non-delay
1 parent c30d4cb commit 5213479

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

src/Non_delay.py

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ def state_check(count):
100100
# e. Menentukan nilai cj terkecil, job dengan cj terkecil akan diproses duluan
101101
min_c = min(CJ)
102102

103+
temp_list = [] # temporary list
104+
103105
# f. Kalo misal ada lebih dari 1 yang punya nilai minimum itu, kita handle
104106
if CJ.count(min_c) > 1:
105107
print("adaberapa?",CJ.count(min_c))
@@ -109,7 +111,6 @@ def state_check(count):
109111

110112
# Cek nilai rj dan pilih yang mempunyai nilai rj terkecil
111113
# Prioritasin yang jumlah operasinya masih banyak
112-
temp_list = [] # temporary list
113114
machine_list = [] # machine list
114115

115116
# Isi list dengan semua data yang ada di index_c_in_cj
@@ -142,7 +143,7 @@ def state_check(count):
142143
index_job = [ST.index(i) for i in retval]
143144
index_mac = [i[2] - 1 for i in retval]
144145

145-
print(index_job, index_mac)
146+
print("idx_job, idx_mach",index_job, index_mac)
146147

147148
COPY_OF_ST = [i for i in ST]
148149

@@ -153,7 +154,7 @@ def state_check(count):
153154
MESIN[0][j] = RJ[i]
154155
try:
155156
# Updating cj
156-
CJ[i] += RJ[i]
157+
# CJ[i] = RJ[i]
157158
# Updating tj
158159
TJ[i] = PROCESSING_TIME[ST[i][0] - 1][ST[i][1]]
159160
# Updating st
@@ -163,19 +164,37 @@ def state_check(count):
163164
ST.pop(i - bias)
164165
CJ.pop(i - bias)
165166
bias += 1
166-
167-
print("cj updated", CJ)
167+
168+
print(len(ST))
169+
for i in range(len(ST)):
170+
if i in index_job:
171+
try:
172+
ready_time = MESIN[0][ST[i][2] - 1]
173+
recent_rjx = RJ[i]
174+
print("rd, rcnt",ready_time, recent_rjx)
175+
if COPY_OF_ST[i][1] != 3:
176+
if ready_time > recent_rjx:
177+
CJ[i] = ready_time
178+
else :
179+
CJ[i] = recent_rjx
180+
except:
181+
continue
182+
else :
183+
CJ[i] += 1
184+
185+
print("cj, st", CJ, ST)
168186

169187
# Updating cj kalo overdua
170188
# retval = [3, 1, 3] mewakili job3, yang1, mesin3
171189
""" print("strv2",retval,TEMP_ST)
172190
for i in range (len(retval)):
173191
if retval[i] != TEMP_ST and count + 1 == CJ[ST.index(value)]:
174192
CJ[i] += 1 """
175-
193+
194+
# Updating rj
176195
RJ = [0 for i in range(len(ST))]
177196
for i in range (len(ST)):
178-
RJ[i] = CJ[i] + TJ[i]
197+
RJ[i] = CJ[i] + TJ[i]
179198

180199
print("----------------------------")
181200

test/Mesin.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3, 1, 0
1+
0, 0, 0

0 commit comments

Comments
 (0)