💥1 概述
針對以最大完工時間最小為優化目标的柔性作業工廠中的房間排程問題(Flexible Job-shop Scheduling Problem,FJSP),采用改進的粒子群算法進行求解。該方法在選擇算子時,通過加入輪盤賭政策,增加種群的多樣性,提升了算法全局尋優能力。通過與傳統粒子群方法進行算例實驗對比,改進粒子群算法在全局尋優速度和求最小解方面均優于傳統方法。
📚2 運作結果
部分代碼:
def calculate(x):
# 輸入:粒子位置,輸出:粒子适應度值
Tm = np.zeros(machine) #每個機器上的完工時間
Te = np.zeros((workpiece, process)) #每個工序的完成時間
array = handle(x) #經過處理後的工序部分
for i in range(total_process):
machine_index = int(x[total_process+(array[i][0]-1)*process+(array[i][1]-1)])-1 #contents數組中的縱坐标
process_index = (array[i][0]-1)*process + (array[i][1]-1) #contents數組中的橫坐标
process_time = int(contents[process_index][machine_index])
if array[i][1] == 1:
Tm[machine_index] += process_time
Te[array[i][0]-1][array[i][1]-1] = Tm[machine_index]
else:
Tm[machine_index] = max(Te[array[i][0]-1][array[i][1]-2], Tm[machine_index]) + process_time
Te[array[i][0]-1][array[i][1]-1] = Tm[machine_index]
return max(Tm)
def getinitbest(fitness,pop):
# 群體最優的粒子位置及其适應度值
gbestpop,gbestfitness = pop[fitness.argmin()].copy(),fitness.min()
#個體最優的粒子位置及其适應度值,使用copy()使得對pop的改變不影響pbestpop,pbestfitness類似
pbestpop,pbestfitness = pop.copy(),fitness.copy()
return gbestpop,gbestfitness,pbestpop,pbestfitness