HTSim/Order.py

37 lines
1.2 KiB
Python

import agentpy as ap
import random
import numpy as np
from numpy import random
import pandas as pd
class Order(ap.Agent):
xv_time_created: int # 订单创建时间
xv_time_circle: int # 随机生成的交货周期
xv_dlv_t: int # 客户希望的交货时间
ev_actual_dlv_t: int # 实际交付时间
ev_is_delivered: bool # 订单是否已交付
ev_is_accepted: bool # 订单是否被接受
ev_int_delay_time: int # total delay time
xv_ary_dlv_product: np.ndarray
ev_ary_dlv_product: np.ndarray
def setup(self, time_created):
self.xv_time_created = time_created
# read the demand of 23 productions
df = pd.read_excel("demand23.xlsx")
self.xv_ary_dlv_product = df.to_numpy()
df = df.iloc[:, 1]
self.ev_ary_dlv_product = df.to_numpy()
self.xv_time_circle = np.random.randint(7, 11, 1)
self.xv_dlv_t = self.xv_time_created + self.xv_time_circle
self.ev_actual_dlv_t = self.xv_dlv_t
self.ev_int_delay_time = self.ev_actual_dlv_t - self.xv_dlv_t
# Set the initial status of order to be undelivered, accepted
self.ev_is_delivered = False
self.ev_is_accepted = False