Esempio n. 1
0
def bigSup_cycle_distance(bigSup):
    list5 = []  # 运来存放每个超级顾客内部的最长距离
    for j in range(len(bigSup)):
        list1 = []
        for l in range(len(bigSup[j]) - 1):
            for m in range(l, len(bigSup[j])):
                list1.append(cf.Point3Distance(bigSup[j][l], bigSup[j][m]))
        list1.sort()
        list1.reverse()
        if len(list1) == 0:  # 由于超级顾客在形成中产生了空超级顾客,所以有此判断;若不会形成空超级顾客,则可删除
            list5.append(0)
        else:
            list5.append(list1[0])
    cycle_distance = []
    for j in range(len(list5)):
        cycle_distance.append(0.71 *
                              ((list5[j]**2 / 2 * len(bigSup[j]))**(1 / 2)))
    return cycle_distance
Esempio n. 2
0
def get_big(i, table, bigSup, bigSupDistance, point3, bigSup_sizes):
    totalmoney = 0
    totalopen = 0
    m1 = 0
    m2 = 0
    m3 = 0
    m4 = 0
    m5 = 0
    allsizesize = 0
    x_location = []
    for j in range(cf.numOfPoint2):
        if any(table[j][k] == 1 for k in range(len(bigSup))):
            x_location.append(j)
    totalopen = len(x_location)
    totalmoney = totalopen * cf.fL
    m1 += totalopen * cf.fL
    for j in x_location:
        totalmoney += 2 * cf.point_12_distance[0][j] * 10
        m2 += 2 * cf.point_12_distance[0][j] * 10  # 一级到二级的运输成本

    final_size = 0
    for j in range(cf.numOfPoint3):
        for k in range(5 - i):
            for l in range(2):
                final_size += point3[j].P[5 - k][l]
    totalmoney += final_size * cf.moneyofProcessingExpress[i][3]
    m3 += final_size * cf.moneyofProcessingExpress[i][3]  # 二级点的处理成本
    list5 = []  # 运来存放每个超级顾客内部的最长距离
    for j in range(len(bigSup)):
        list1 = []
        for l in range(len(bigSup[j]) - 1):
            for m in range(l, len(bigSup[j])):
                list1.append([cf.Point3Distance(l, m), l, m])
        list1.sort()
        list1.reverse()
        if len(list1) == 0:  # 由于超级顾客在形成中产生了空超级顾客,所以有此判断;若不会形成空超级顾客,则可删除
            list5.append(0)
        else:
            list5.append(list1[0][0])
    cycle_distance = []
    for j in range(len(list5)):
        cycle_distance.append((list5[j]**2 / 2 * len(bigSup[j]))**(1 / 2))
    tt = 0  # 记录空超级顾客的数量
    distance = 0
    for j in range(len(cycle_distance)):
        if cycle_distance[j] == 0:
            tt += 1
    for j in x_location:
        for k in range(len(bigSup)):
            if table[j][k] == 1 and cycle_distance[k] != 0:
                distance += 2 * bigSupDistance[k][j]
    totaldistance = distance + sum(cycle_distance)
    totalmoney += 5 * totaldistance
    m4 += 5 * totaldistance
    '''for j in x_location:
            for k in range(len(bigSup)):
                if table[j][k] == 1:
                    if list5[k]==0:      #    由于超级顾客在形成中产生了空超级顾客,所以有此判断;若不会形成空超级顾客,则可删除
                        totaldistance=0
                    else:
                        totaldistance = ((list5[k] ** 2) / 2) * len(bigSup[k]) ** (1 / 2) + 2 * 0.71 * bigSupDistance[k][j]
                    print('totaldistance=',totaldistance)
                    totalmoney += 5 * totaldistance
                    m4 += 5 * totaldistance  # 二级点到超级顾客和超级顾客内部的运输成本'''
    '''for j in x_location:
        for k in range(len(bigSup)):
            list1 = []  # 用来存放已经开放的中转中心所服务的三级点之间的距离和编号
            if table[j][k] == 1:
                for l in range(len(bigSup[k])):
                    for m in range(l+1,len(bigSup[k])):
                        list1.append([cf.Point32Distance(l,m),l,m])
                list1.sort()
                list1.reverse()
                if len(list1)==0:
                    totaldistance=((((0/(2**(1/2)))**2)*len(bigSup[k]))**(1/2))*0.71+2*bigSupDistance[k][j]
                else:
                    totaldistance=((((list1[0][0]/(2**(1/2)))**2)*len(bigSup[k]))**(1/2))*0.71+2*bigSupDistance[k][j]
                totalmoney+=5*totaldistance
                m4+=5*totaldistance  #  二级点到超级顾客和超级顾客内部的运输成本'''
    final_size = 0
    for j in range(cf.numOfPoint3):
        for k in range(5 - i):
            for l in range(2):
                final_size += point3[j].P[5 - k][l]
    totalmoney += final_size * cf.moneyofProcessingExpress[i][2]
    m5 += final_size * cf.moneyofProcessingExpress[i][2]  #  三级点的处理成本
    return totalmoney, m1, m2 + m4, m3 + m5
Esempio n. 3
0
def superCustomer(i, point3):  #  生成两类超级顾客,为列表,每一个元素代表该超级顾客的顾客点的组成
    # 用来存放超级顾客信息
    smallSup = []
    bigSup = []

    # 根据该划分值求三级网点普通和大件的量
    for j in range(cf.numOfPoint3):
        # 求普通件的量
        sumnum = 0
        for t in range(i + 1):
            sumnum = sumnum + point3[j].P[t][0]
        point3[j].small = sumnum
        # 求大件的量
        sumnum = 0
        for t in range(5 - i):
            sumnum = sumnum + point3[j].P[5 - t][0]
        point3[j].big = sumnum
        # print("i=%d small=%d big=%d"%(j,point3[j].small,point3[j].big))
    # 生成普通件超级顾客,用V2进行运输
    pointleft = np.zeros(cf.numOfPoint3)  # 点被使用与否的标志,0表示未划分,1表示划分
    car = cf.car_loading[1][2 * i]
    ##开始模拟生成
    while (isAllUsed(pointleft) == 0):
        oneSuperCustomer = []  # 一个超级顾客成员
        wholeExpressNum = 0  # 一个超级顾客总运输量
        wholeTime = 0  # 一个超级顾客花费总时间
        lastPoint = -1  # 上一个待加入的点
        while (car > wholeExpressNum and wholeTime < 100):
            # 第一个点,顺序选择未加入的点加入
            if wholeTime == 0:
                nowPoint = -1  # 待加入的点
                for j in range(cf.numOfPoint3):
                    if pointleft[j] == 0:
                        nowPoint = j
                        stayTime = np.random.randint(15, 20)  # 每个点花费的时间
                        oneSuperCustomer.append(nowPoint)
                        pointleft[nowPoint] = 1
                        wholeExpressNum = wholeExpressNum + point3[
                            nowPoint].small
                        wholeTime = wholeTime + stayTime
                        lastPoint = nowPoint
                        break
            # 除第一个点按照距离最近的点加入
            else:
                distance = 1000  # 定义一个超长距离
                nowPoint = -1  # 定义待加入的点
                for j in range(cf.numOfPoint3):
                    if cf.Point3Distance(
                            lastPoint, j
                    ) < distance and lastPoint != j and pointleft[j] == 0:
                        distance = cf.Point3Distance(lastPoint, j)
                        nowPoint = j
                # 判断能不能加入这个点
                stayTime = np.random.randint(15, 20)  # 点花费的时间
                if wholeTime + stayTime > 100 or wholeExpressNum + point3[
                        nowPoint].small > car or nowPoint == -1:
                    break
                else:
                    oneSuperCustomer.append(nowPoint)
                    pointleft[nowPoint] = 1
                    wholeExpressNum = wholeExpressNum + point3[nowPoint].small
                    wholeTime = wholeTime + stayTime
                    lastPoint = nowPoint
        smallSup.append(oneSuperCustomer)

    # 生成大件超级顾客,用V3进行运输
    pointleft = np.zeros(cf.numOfPoint3)  # 点被使用与否的标志,0表示未划分,1表示划分
    car = cf.car_loading[2][2 * i + 1]
    ##开始模拟生成
    while (isAllUsed(pointleft) == 0):
        oneSuperCustomer = []  # 一个超级顾客成员
        wholeExpressNum = 0  # 一个超级顾客总运输量
        wholeTime = 0  # 一个超级顾客花费总时间
        lastPoint = -1  # 上一个待加入的点
        while (car > wholeExpressNum and wholeTime < 180):
            # 第一个点,顺序选择未加入的点加入
            if wholeTime == 0:
                nowPoint = -1  # 待加入的点
                for j in range(cf.numOfPoint3):
                    if pointleft[j] == 0:
                        nowPoint = j
                        stayTime = np.random.randint(15, 20)  # 每个点花费的时间
                        oneSuperCustomer.append(nowPoint)
                        pointleft[nowPoint] = 1
                        wholeExpressNum = wholeExpressNum + point3[nowPoint].big
                        wholeTime = wholeTime + stayTime
                        lastPoint = nowPoint
                        break
            # 除第一个点按照距离最近的点加入
            else:
                distance = 1000  # 定义一个超长距离
                nowPoint = -1  # 定义待加入的点
                for j in range(cf.numOfPoint3):
                    if cf.Point3Distance(
                            lastPoint, j
                    ) < distance and lastPoint != j and pointleft[j] == 0:
                        distance = cf.Point3Distance(lastPoint, j)
                        nowPoint = j
                # 判断能不能加入这个点
                stayTime = np.random.randint(15, 16)  # 点花费的时间
                if wholeTime + stayTime > 180 or wholeExpressNum + point3[
                        nowPoint].big > car or nowPoint == -1:
                    break
                else:
                    oneSuperCustomer.append(nowPoint)
                    pointleft[nowPoint] = 1
                    wholeExpressNum = wholeExpressNum + point3[nowPoint].big
                    wholeTime = wholeTime + stayTime
                    lastPoint = nowPoint
        bigSup.append(oneSuperCustomer)

    # 返回
    return smallSup, bigSup