什么是关键工序
在FJSP问题中,从源点到终点的最长时间的路径,以下面的析取图和甘特图为例进行具体说明:
从甘特图来看,最大完工时间是工序O33,它的其中一条关键路径为:O33,O13,O12,O11,O21;在这个甘特图中只有一条关键路径,但现实中关键路径不止一条。
寻找甘特图的python代码如下:
def VNS(self,CHS):
Chromo=self.Chromosome_decoding(CHS)
Start_time=Chromo[0]
End_time=Chromo[1]
Fit=Chromo[2]
#找出一条关键路径
Key_Process=[]
Current_Machine=None
Current_Site=None
for i in range(len(End_time)):
Max_time=np.max(End_time[i])
if Max_time==Fit:
E=list(End_time[i])
Maxtime_site=E.index(Max_time)
Key_Process.append(Maxtime_site)
Current_Site=Maxtime_site
Current_Machine=i
break
Start_Otime=Start_time[Current_Machine][Current_Site]
while Start_Otime!=0 :
try:
E_1=list(End_time[Current_Machine])
Current_Site=E_1.index(Start_Otime)
Start_Otime=Start_time[Current_Machine][Current_Site]
except:
if Current_Site%self.Max_O_len!=0:
Current_Site=Current_Site-1
for j in range(len(End_time)):
if End_time[j][Current_Site]!=0:
Current_Machine=j
Start_Otime=Start_time[j][Current_Site]
break
finally:
Key_Process.append(Current_Site)
CHS_O=[]
CHS_M=[]
for site in Key_Process:
S=int(site/self.Max_O_len)+1
M=site%self.Max_O_len+1
CHS_O.append(S)
CHS_M.append(M)
print(CHS_O)
print(CHS_M)
以上代码仅为部分代码,不能运行,对我自己的结果可以看到
我的甘特图如下:
输出结果如下
关键工序为:O24, O23, O22, O83, O13, O53, O52, O51, O81
注:以上结果仅找了一条关键路径,以此为变领域搜索作准备