예제 #1
0
 def cal_mat_priority(self, now_time):
     # 计算 rest剩余未完成量、(now_time-last_time)距离上次plan_day修改时间、(仓库合理工作强度-当前车辆工作数)的softmax函数
     rest_list = list()
     time_list = list()
     cars_num_list = list()
     for warehouse in self.__warehouse_list:
         for mat in warehouse.get_mat_list():
             rest_list.append(mat.get_rest())
             time_list.append(
                 int((Tool.string_to_datetime(now_time) -
                      Tool.string_to_datetime(
                          mat.get_last_time())).total_seconds()))
             cars_num_list.append(warehouse.get_rea() - warehouse.get_act())
     rest = Tool.softmax(rest_list)
     last_time = Tool.softmax(time_list)
     cars_num = Tool.softmax(cars_num_list)
     # 计算优先级
     index = 0
     for i in range(len(self.__warehouse_list)):
         priority_list = list()
         for j in range(len(self.__warehouse_list[i].get_mat_list())):
             if cars_num[i] == 0:
                 priority_list.append(0)
             else:
                 priority_list.append(
                     (rest[index] * last_time[index]) / cars_num[index])
             index += 1
         self.__warehouse_list[i].set_mat_priority(priority_list)
         print(priority_list)
예제 #2
0
파일: Warehouse.py 프로젝트: CaiDog/queue
 def cars_init(self, cars_list):
     new_cars_list = cars_list
     for car in new_cars_list:
         car.set_finish_time(Tool.datetime_to_string(Tool.string_to_datetime(car.get_entry_time()) + datetime.timedelta(seconds=self.__unloadTime)))
         if car.get_finish_time() < '2019-10-25 00:00:00':
             car.set_finish_time('2019-10-25 00:00:00')
     return new_cars_list
예제 #3
0
 def ready_cars_init(self, cars_list):
     # 准备车辆也确定了进厂时间和离厂时间
     new_cars_list = cars_list
     for car in new_cars_list:
         for warehouse in self.__inFactory.get_warehouse():
             if car.get_target_warehouse() == warehouse.get_warehouse_code(
             ):
                 car.set_entry_time(
                     Tool.datetime_to_string(
                         Tool.string_to_datetime(car.get_notice_time()) +
                         datetime.timedelta(
                             seconds=warehouse.get_preTime())))
                 if car.get_entry_time() < '2019-10-25 00:00:00':
                     car.set_entry_time('2019-10-25 00:00:00')
                 car.set_finish_time(
                     Tool.datetime_to_string(
                         Tool.string_to_datetime(car.get_entry_time()) +
                         datetime.timedelta(
                             seconds=warehouse.get_unloadTime())))
     return new_cars_list
예제 #4
0
 def cal_cars_priority(self, now_time):
     time_list = list()
     mat_priority = list()
     # 计算每个车辆已等时间的softmax函数
     for car in self.__queue_cars:
         time_list.append(
             int((Tool.string_to_datetime(now_time) -
                  Tool.string_to_datetime(
                      car.get_queue_start_time())).total_seconds()))
     time_result = Tool.softmax(time_list)
     # 计算每个仓库中品种优先级的softmax函数
     for warehouse in self.__inFactory.get_warehouse():
         for mat in warehouse.get_mat_list():
             mat_priority.append(mat.get_priority())
     priority_result = Tool.softmax(mat_priority)
     # 计算每辆车得优先级
     for i in range(len(self.__queue_cars)):
         count = int()  # 用于保存多个仓库的优先级*权重之和
         # 遍历car的每个目的仓库
         for warehouse1 in self.__queue_cars[i].get_target_warehouse():
             index = 0
             # 遍历厂内所有仓库,目的是找出仓库内品种的优先级
             for warehouse2 in self.__inFactory.get_warehouse():
                 # 如果相等则匹配到了
                 if warehouse1 == warehouse2.get_warehouse_code():
                     # 遍历仓库内所有品种,目的是找出仓库内和车辆相同的品种
                     for mat in warehouse2.get_mat_list():
                         # 物料名和小品种要都相等才能确定
                         if mat == self.__queue_cars[i].get_mat_code() \
                                 and self.__queue_cars[i].get_sub_kind_name() == mat.get_sub_kind_name():
                             count += priority_result[index]
                             break
                         index += 1
                     break
                 else:
                     index += len(warehouse2.get_mat_list())
         x = time_result[i] * (
             count / len(self.__queue_cars[i].get_target_warehouse()))
         self.__queue_cars[i].set_priority(x)
         print(x)
예제 #5
0
def data_analyse4(data):
    result = list()
    hour = datetime.timedelta(hours=1)
    half_hour = datetime.timedelta(minutes=30)
    time = '2019-10-25 00:00:00'
    while time != '2019-11-29 00:00:00':
        for warehouse in warehouse_code:
            num = len(data[(data['WAREHOUSE_CODE'] == warehouse)
                           & (data['ENTRY_TIME'] < time)
                           & (data['FINISH_TIME'] > time)])
            warehouse_dict[warehouse].append(num)
            # print(warehouse, '在', time, '的时候有', num, '辆车')
        time = tool.datetime_to_string(tool.string_to_datetime(time) + hour)

    for warehouse in warehouse_code:
        j = 0
        for i in range(len(warehouse_dict[warehouse])):
            if warehouse_dict[warehouse][j] == 0:
                warehouse_dict[warehouse].pop(j)
            else:
                j += 1
        temp = list()
        temp.append(warehouse)
        temp.append(stats.mode(warehouse_dict[warehouse])[0][0])
        temp.append(max(warehouse_dict[warehouse]))
        # print(warehouse, '的众数是:', stats.mode(warehouse_dict[warehouse])[0][0])
        # print(warehouse, '的max是:', max(warehouse_dict[warehouse]))
        warehouse_dict[warehouse].sort(reverse=True)
        temp.append(
            int(
                np.mean(warehouse_dict[warehouse]
                        [0:len(warehouse_dict[warehouse]) // 3 + 1])))
        result.append(temp)
        # print(warehouse, '的较大值是:', np.mean(warehouse_dict[warehouse][0: len(warehouse_dict[warehouse]) // 3 + 1]))
    df = pd.DataFrame(result,
                      columns=['warehouse_code', 'mode', 'max', 'minorMax'])
    df.to_excel('warehouseLimit.xls', index=False)
예제 #6
0
파일: test.py 프로젝트: CaiDog/queue
# import pandas as pd
#
# import demo.setting.Data_acquisition as Data_acquisition
import demo.setting.Tools as Tool
# import ssl
# import demo.OutFactory as OutFactory
# import datetime
import numpy as np
import sklearn.preprocessing as preprocessing
import math

a = int((Tool.string_to_datetime('2019-10-25 11:00:00') -
         Tool.string_to_datetime('2019-10-25 10:00:00')).total_seconds())
print(a)
예제 #7
0
파일: Car.py 프로젝트: CaiDog/queue
 def get_wait_time(self):
     return Tool.string_to_datetime(self.__notice_time)-Tool.string_to_datetime(self.__entry_time)
예제 #8
0
    def call(self, time):
        car_list = list()  # 存储本次叫号的车辆
        pre_time = Tool.datetime_to_string(
            Tool.string_to_datetime(time) -
            datetime.timedelta(seconds=Tool.interval))
        # 选取上一个时间段的plan_day
        plan_day = self.plan_day[(self.plan_day['update_time'] >= pre_time)
                                 & (self.plan_day['update_time'] <= time)]
        # 更新每个仓库内的每个原料的更新时间和剩余未完成量
        for warehouse in self.__inFactory.get_warehouse():
            for mat in warehouse.get_mat_list():
                if mat.get_mat_code() == '11002000010000':
                    mat_plan_day = plan_day[
                        (plan_day['sub_kind_name'] == mat.get_sub_kind_name())
                        & (plan_day['warehouse_code'] == warehouse.
                           get_warehouse_code())]['add_weight'].tolist()
                else:
                    mat_plan_day = plan_day[
                        (plan_day['kind_code'] == mat.get_mat_code())
                        & (plan_day['warehouse_code'] == warehouse.
                           get_warehouse_code())]['add_weight'].tolist()
                if len(mat_plan_day) == 0:
                    continue
                add_weight = int(mat_plan_day[-1])
                mat.update(time, add_weight - mat.get_sum())
        self.__inFactory.cal_mat_priority(time)  # 计算每个原料的优先级
        self.cal_cars_priority(time)  # 计算每辆车的优先级
        self.__queue_cars.sort(key=lambda x: x.get_priority())

        # for car in self.__queue_cars:

        # for car in self.__queue_cars:
        #     # 外购废钢看小品名
        #     if car.get_mat_code() == '11002000010000':
        #         for warehouse in self.__inFactory.get_warehouse():
        #             for mat in warehouse.get_mat_list():
        #                 if mat.get_sub_kind_name() == car.get_sub_kind_name():
        #                     if mat.get_rest() > 0:
        #                         car.set_notice_time(time)
        #                         car.set_entry_time(Tool.datetime_to_string
        #                                            (Tool.string_to_datetime(car.get_notice_time()) + datetime.timedelta
        #                                            (seconds=warehouse.get_preTime())))
        #                         car.set_finish_time(Tool.datetime_to_string
        #                                             (Tool.string_to_datetime(car.get_entry_time)) + datetime.timedelta
        #                         (seconds=warehouse.get_unloadTime()))
        #                         mat.add_sum()
        #                         mat.sub_rest()
        #                         car_list.append(car)
        #     # 其他看物料名
        #     else:
        #         for warehouse in self.__inFactory.get_warehouse():
        #             for mat in warehouse.get_mat_list():
        #                 if mat.get_mat_code() == car.get_mat_code():
        #                     if mat.get_rest() > 0:
        #                         car.set_notice_time(time)
        #                         car.set_entry_time(Tool.datetime_to_string
        #                                            (Tool.string_to_datetime(car.get_notice_time()) + datetime.timedelta
        #                                            (seconds=warehouse.get_preTime())))
        #                         car.set_finish_time(Tool.datetime_to_string
        #                                             (Tool.string_to_datetime(car.get_entry_time)) + datetime.timedelta
        #                         (seconds=warehouse.get_unloadTime()))
        #                         mat.add_sum()
        #                         mat.sub_rest()
        #                         car_list.append(car)
        return car_list