2023-07-24 15:07:19 +08:00
|
|
|
import agentpy as ap
|
|
|
|
import random
|
|
|
|
import numpy as np
|
|
|
|
from numpy import random
|
|
|
|
import pandas as pd
|
|
|
|
|
|
|
|
|
|
|
|
class Order(ap.Agent):
|
2023-07-25 21:32:08 +08:00
|
|
|
xv_time_created: int # 订单创建时间
|
|
|
|
xv_time_circle: int # 随机生成的交货周期
|
|
|
|
xv_dlv_t: int # 客户希望的交货时间
|
|
|
|
ev_actual_dlv_t: int # 实际交付时间
|
2023-07-24 15:07:19 +08:00
|
|
|
|
2023-07-25 21:32:08 +08:00
|
|
|
ev_is_delivered: bool # 订单是否已交付
|
|
|
|
ev_is_accepted: bool # 订单是否被接受
|
|
|
|
ev_int_delay_time: int # 订单延迟交付时间
|
2023-07-24 15:07:19 +08:00
|
|
|
|
|
|
|
xv_ary_dlv_product: np.ndarray
|
|
|
|
ev_ary_dlv_product: np.ndarray
|
|
|
|
|
|
|
|
def setup(self, time_created):
|
2023-07-25 21:32:08 +08:00
|
|
|
self.xv_time_created = time_created # 订单创建时间
|
2023-07-24 15:07:19 +08:00
|
|
|
# read the demand of 23 productions
|
2023-07-25 21:32:08 +08:00
|
|
|
self.xv_ary_dlv_product = pd.read_excel("demand23.xlsx").to_numpy() # 接神经网络结果
|
|
|
|
self.ev_ary_dlv_product = pd.read_excel("demand23.xlsx").to_numpy()[:, 1] # 23x1 把产品的顺序按照xv_ary_product_id重新排列!!!
|
2023-07-24 15:07:19 +08:00
|
|
|
self.xv_time_circle = np.random.randint(7, 11, 1)
|
2023-07-25 21:32:08 +08:00
|
|
|
self.xv_dlv_t = self.xv_time_created + self.xv_time_circle # 随机生成期望交付时间
|
2023-07-24 15:07:19 +08:00
|
|
|
self.ev_actual_dlv_t = self.xv_dlv_t
|
2023-07-25 21:32:08 +08:00
|
|
|
self.ev_int_delay_time = 0
|
2023-07-24 15:07:19 +08:00
|
|
|
|
|
|
|
# Set the initial status of order to be undelivered, accepted
|
|
|
|
self.ev_is_delivered = False
|
|
|
|
self.ev_is_accepted = False
|