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)
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)