天天看点

基于改进粒子群优化算法的柔性车间调度问题(Python代码实现)

💥1 概述

     针对以最大完工时间最小为优化目标的柔性作业车间调度问题(Flexible Job-shop Scheduling Problem,FJSP),采用改进的粒子群算法进行求解。该方法在选择算子时,通过加入轮盘赌策略,增加种群的多样性,提升了算法全局寻优能力。通过与传统粒子群方法进行算例实验对比,改进粒子群算法在全局寻优速度和求最小解方面均优于传统方法。

📚2 运行结果

基于改进粒子群优化算法的柔性车间调度问题(Python代码实现)

部分代码:

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      

🎉3 参考文献

​​🌈​​4 Python代码实现