Exemple #1
0
def GetOUTPUTDATA(ind,
                  M_max=4,
                  c_op=c_op,
                  t_convey=t_convey,
                  t_pack=t_pack,
                  c_od=c_od,
                  lm=lm):
    """
        ind:例如[0,3,19,8,7,0,10,6,4,14,12,9,16,0,13,11,18,20,2,0,17,1,15,5,0]
        M_max:分区数
        """
    batch, batch_item = getBatch(ind)
    batch_Quantity = [len(i) for i in batch_item]
    data = getBatchPicktime(batch_item)
    batch_packingtime = [t_pack * i for i in batch_Quantity]

    ODtime = ODtimeTable(np.array(batch))  #每个客户点交付时间
    ODtime = [i[-1] * 10 for i in ODtime]  #每个批次最后一个客户点交付时间*10
    op_duetime = [(lm - i) for i in ODtime]
    """求解BSP"""
    N_max = data.shape[1]
    index = list(range(1, N_max + 1))
    #SPT
    data1 = data[1:, :].sum(axis=0)
    tup = list(zip(index, data1))
    tup.sort(key=lambda x: x[1])
    Seq_SPT = np.array([i[0] for i in tup])
    data_best_all_SPT = data[:, Seq_SPT - 1]
    TPicktime_SPT = makespan(data_best_all_SPT)[-1, :].sum()
    #LDT
    tup = list(zip(index, ODtime))
    tup.sort(key=lambda x: x[1], reverse=0)
    Seq_LDT = np.array([i[0] for i in tup])
    data_best_all_LDT = data[:, Seq_LDT - 1]
    TPicktime_LDT = makespan(data_best_all_LDT)[-1, :].sum()
    #择优
    if TPicktime_SPT <= TPicktime_LDT:
        Seq = Seq_SPT
        data_best_all = data_best_all_SPT
    else:
        Seq = Seq_LDT
        data_best_all = data_best_all_LDT
    order = np.array(data_best_all[0, :]) - 1

    return Seq, data_best_all, batch_packingtime, order, op_duetime, ODtime
Exemple #2
0
    def fitness(self, pop, c_op, op_duetime, c_od, batch_packingtime,
                t_convey):
        fitness = np.zeros([self.pop_size, 1])
        for i in range(self.pop_size):
            # fitness[i] = 1 / makespan_value(self.data[:, pop[i]]) #最大完成时间

            # fitness[i] = 1 / sum(makespan(self.data[:, pop[i]])[-1, :]) #合计完成时间
            # fitness[i] = 1 / (sum(makespan(self.data[:, pop[i]])[-1, :])*c_op)  # 合计完成时间*单位成本

            ######目标:合计订单拣选成本+违约成本##########
            #各批次订单抵达后台时间
            batch_arrive_time = np.array([
                i + t_convey
                for i in (makespan(self.data[:, pop[i]], t_convey)[-1, :])
            ])
            order = pop[i]
            # 各批次订单开始配送时间
            batch_delivery_start_time = batch_arrive_time + np.array(
                [batch_packingtime[i] for i in order])
            #违约时间
            batch_over_duetime = []
            for j in list(
                    np.array(batch_delivery_start_time) -
                    np.array([op_duetime[i] for i in order])):
                if j < 0:
                    batch_over_duetime.append(0)
                else:
                    batch_over_duetime.append(j)
            # 总订单拣选成本+违约成本=合计订单开始配送时间*单位时间成本+合计违约时间*单位违约时间成本
            TC = ((sum(batch_delivery_start_time) / 10 * c_op) +
                  sum(batch_over_duetime) / 10 * c_od)
            fitness[i] = 1 / (TC)

            ######合计加权时间##########
            # W=np.array([1,1,1,1]) #各工件权重
            # Value_all=np.array(makespan(self.data[:, pop[i]])[-1, :])
            # Seq_temp=makespan(self.data[:, pop[i]])[0,:]
            # W_new=W[Seq_temp-1] #工件权重调整
            # fitness[i] = 1 / sum(np.multiply(Value_all, W_new)) #加权合计完成时间
            ################################
        return fitness
Exemple #3
0
def calOPCost(ind,
              M_max=4,
              c_op=c_op,
              t_convey=t_convey,
              t_pack=t_pack,
              c_od=c_od,
              lm=lm):
    """
    ind:例如[0,3,19,8,7,0,10,6,4,14,12,9,16,0,13,11,18,20,2,0,17,1,15,5,0]
    M_max:分区数
    """
    batch, batch_item = getBatch(ind)
    batch_Quantity = [len(i) for i in batch_item]
    data = getBatchPicktime(batch_item)
    batch_packingtime = [t_pack * i for i in batch_Quantity]  #b属于B

    ODtime = ODtimeTable(np.array(batch))
    ODtime = [i[-1] * 10 for i in ODtime]  #每个批次最后一个客户点交付时间*10
    op_duetime = [(lm - i) for i in ODtime]
    """求解BSP"""
    N_max = data.shape[1]
    index = list(range(1, N_max + 1))
    #SPT
    data1 = data[1:, :].sum(axis=0)
    tup = list(zip(index, data1))
    tup.sort(key=lambda x: x[1])
    Seq_SPT = np.array([i[0] for i in tup])
    data_best_all_SPT = data[:, Seq_SPT - 1]
    TPicktime_SPT = makespan(data_best_all_SPT)[-1, :].sum()
    #LDT
    tup = list(zip(index, op_duetime))
    tup.sort(key=lambda x: x[1])
    Seq_LDT = np.array([i[0] for i in tup])
    data_best_all_LDT = data[:, Seq_LDT - 1]
    TPicktime_LDT = makespan(data_best_all_LDT)[-1, :].sum()

    #择优
    if TPicktime_SPT <= TPicktime_LDT:
        Seq = Seq_SPT
        data_best_all = data_best_all_SPT
    else:
        Seq = Seq_LDT
        data_best_all = data_best_all_LDT
    order = np.array(data_best_all[0, :]) - 1
    """时间类"""
    #各分区订单抵达后台时间
    batch_arrive_time = np.array([
        i + t_convey for i in (makespan(data_best_all, t_convey)[-1, :])
    ])  #b 属于pi,拣货顺序批次
    # 批次订单开始配送时间=抵达后台时间+打包分类时间
    batch_delivery_start_time = batch_arrive_time + np.array(
        [batch_packingtime[i] for i in order])
    #批次订单违约时间
    batch_over_duetime = []
    for j in list(
            np.array(batch_delivery_start_time) -
            np.array([op_duetime[i] for i in order])):
        if j < 0:
            batch_over_duetime.append(0)
        else:
            batch_over_duetime.append(j)
    """成本类:将时间/10"""
    #各批次订单拣选成本
    batch_op_cost = np.array(batch_delivery_start_time) / 10 * c_op
    #各批次订单违约成本
    batch_overduetime_cost = np.array(batch_over_duetime) / 10 * c_od
    #订单总拣选成本+违约成本
    TC = batch_op_cost.sum() + batch_overduetime_cost.sum()

    return TC
Exemple #4
0
    ]
    # 如果最迟到达时间大于实际到达客户的时间,则延迟为0,否则延迟设为实际到达时间与最迟到达时间之差
    timeDelay = [
        max(timeArrangement[i] - desiredTime[i], 0)
        for i in range(len(bestInd))
    ]
    C_od_d = sum(timeDelay) * c_od_d
    """计算订单拣选延迟时间及成本"""
    Seq, data_best_all, batch_packingtime, order, op_duetime, ODtime = GetOUTPUTDATA(
        bestInd)

    #拣货开始时间
    op_start_time = makespan_left(data_best_all)
    #各分区订单抵达后台时间
    batch_arrive_time = np.array([
        i + t_convey for i in (makespan(data_best_all, t_convey)[-1, :])
    ])  #b 属于pi,拣货顺序批次
    # 批次订单开始配送时间=抵达后台时间+打包分类时间
    batch_delivery_start_time = batch_arrive_time + np.array(
        [batch_packingtime[i] for i in order])
    #批次订单违约时间
    batch_over_duetime = []
    for j in list(
            np.array(batch_delivery_start_time) -
            np.array([op_duetime[i] for i in order])):
        if j < 0:
            batch_over_duetime.append(0)
        else:
            batch_over_duetime.append(j)
    C_od_op = sum(batch_over_duetime) / 10 * c_od
Exemple #5
0
    def evaluation(self, df):
        size = len(df.index)
        for i in range(size):
            df.loc[i, 'makespans'] = tool.makespan(np.array(self.span), df['jobs'][i])

        return df
Exemple #6
0
    print("Best Seq:", Seq)

data_best_all = data[:, Seq - 1]
order = array(data_best_all[0, :]) - 1
"""绘制甘特图"""
Draw = 0
if Draw == 1:
    plt.figure()
    gatt(data_best_all, t_convey)
    plt.show()
"""计算各指标"""
"""时间类"""
#拣货开始时间
op_start_time = makespan_left(data_best_all)
#拣货完成时间
makespan_time = makespan(data_best_all)
#各分区订单抵达后台时间
batch_arrive_time = array(
    [i + t_convey for i in (makespan(data_best_all)[-1, :])])
#批次订单开始配送时间=抵达后台时间+打包分类时间
batch_delivery_start_time = batch_arrive_time + array(
    [batch_packingtime[i] for i in order])

#批次订单违约时间
batch_over_duetime = []
for j in list(
        array(batch_delivery_start_time) -
        array([op_duetime[i] for i in order])):
    if j < 0:
        batch_over_duetime.append(0)
    else:
Exemple #7
0
batch_Quantity=[len(i) for i in batch_item]
data=getBatchPicktime(batch_item)
batch_packingtime=[t_pack*i for i in batch_Quantity]
op_duetime=[lm-i for i in ODtime]


"""bsp"""
N_max=data.shape[1]
index=list(range(1,N_max+1))


data1=data[1:,:].sum(axis=0)
tup=list(zip(index,data1))
tup.sort(key=lambda x:x[1])
Seq_SPT=array([i[0] for i in tup])
data_best_all=data[:,Seq_SPT-1]
TPicktime_SPT=makespan(data_best_all)[-1,:].sum()

tup=list(zip(index,C_d_Bat))
tup.sort(key=lambda x:x[1],reverse=True)
Seq_LDT=array([i[0] for i in tup])
data_best_all=data[:,Seq_LDT-1]
TPicktime_LDT=makespan(data_best_all)[-1,:].sum()

if TPicktime_SPT<=TPicktime_LDT:
    Seq=Seq_SPT
else:
    Seq=Seq_LDT