forked from Aihong-Sun/ACO_for_FJSP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Machines.py
54 lines (51 loc) · 2.1 KB
/
Machines.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class Machine_Time_window:
def __init__(self,Machine_index):
self.Machine_index=Machine_index
self.assigned_task = []
self.worker_for_task=[]
self.O_start = []
self.O_end = []
self.End_time=0
#机器的哪些时间窗是空的,此处只考虑内部封闭的时间窗
def Empty_time_window(self):
time_window_start = []
time_window_end = []
len_time_window=[]
if self.O_end is None:
pass
elif len(self.O_end)==1:
if self.O_start[0]!=0:
time_window_start=[0]
time_window_end=[self.O_start[0]]
elif len(self.O_end)>1:
if self.O_start[0] !=0:
time_window_start.append(0)
time_window_end.append(self.O_start[0])
time_window_start.extend(self.O_end[:-1]) #因为使用时间窗的结束点就是空时间窗的开始点
time_window_end.extend(self.O_start[1:])
if time_window_end is not None:
len_time_window=[time_window_end[i]-time_window_start[i] for i in range(len(time_window_end))]
return time_window_start,time_window_end,len_time_window
def Machine_Burden(self):
if len(self.O_start)==0:
burden=0
else:
processing_time=[self.O_end[i]-self.O_start[i] for i in range(len(self.O_start))]
burden=sum(processing_time)
return burden
def _Input(self,Job,M_Ealiest,P_t,O_num):
if self.O_end!=[]:
if self.O_start[-1]>M_Ealiest:
for i in range(len(self.O_end)):
if self.O_start[i]>=M_Ealiest:
self.assigned_task.insert(i,[Job + 1, O_num + 1])
break
else:
self.assigned_task.append([Job+1,O_num+1])
else:
self.assigned_task.append([Job+1,O_num+1])
self.O_start.append(M_Ealiest)
self.O_start.sort()
self.O_end.append(M_Ealiest+P_t)
self.O_end.sort()
self.End_time=self.O_end[-1]