This commit is contained in:
Yofuria 2023-07-25 23:48:53 +08:00
parent 382efa2139
commit a16b352f10
5 changed files with 16 additions and 7 deletions

View File

@ -1 +1 @@
OrderSystem.py
Order.py

View File

@ -84,7 +84,7 @@ class FMSEnv(ap.Model):
self.stop()
else:
print(f"running the {self.t} step")
print(self.the_firm.the_os.ev_ave_delay_time)
print("当期延误时长为:{}".format(self.the_firm.the_os.ev_ave_delay_time))
# Record data after each simulation
def update(self): # ?
@ -111,7 +111,7 @@ class FMSEnv(ap.Model):
if __name__ == '__main__':
dct_para = {
'time': 60, # 进行总时间数
'time': 300, # 进行总时间数
# 'xv_int_max_order': random.randint(30, 50),
# 'xv_dlv_product_para': tuple([(30, 100), (30, 50)]),
# 'xv_dlv_product_para': tuple([30,40,30,20]), # 读取生产率 np.read.

View File

@ -21,7 +21,7 @@ class Order(ap.Agent):
def setup(self, time_created):
self.xv_time_created = time_created # 订单创建时间
# read the demand of 23 productions
self.xv_ary_dlv_product = np.asarray(pd.read_excel("demand23.xlsx").to_records(index=False)) # 接神经网络结果
self.xv_ary_dlv_product = np.asarray(tuple([tuple(x) for x in pd.read_excel("demand23.xlsx").values])) # 接神经网络结果
self.ev_ary_dlv_product = np.asarray(tuple(pd.read_excel("demand23.xlsx").iloc[:, 1])) # 23x1 把产品的顺序按照xv_ary_product_id重新排列!!!
self.xv_time_circle = np.random.randint(7, 11, 1)
self.xv_dlv_t = self.xv_time_created + self.xv_time_circle # 随机生成期望交付时间

View File

@ -55,6 +55,7 @@ class OrderSystem(ap.Agent):
sorted_indices = np.argsort(self.ev_ary_product_to_produce)[::-1]
sorted_data = self.xv_ary_product[sorted_indices] # gap从大到小的产品id
gap_sorted = self.ev_ary_product_to_produce[sorted_indices]
# print(gap_sorted)
if gap_sorted[0] > 0: # 判断是否存在库存不足
pass
else:
@ -65,6 +66,7 @@ class OrderSystem(ap.Agent):
sorted_indices = np.argsort(option[:, 3])[::-1]
sorted_data = option[sorted_indices]
self.ev_int_produce_type = sorted_data[0, 0]
# print(option)
# return self.ev_int_produce_type
def do_shipment(self, ev_ary_current_product):
@ -76,8 +78,13 @@ class OrderSystem(ap.Agent):
# Make shipments based on ranked order list
self.ev_ave_delay_time = 0
self.ev_changed_product = np.array([float(x) for x in ev_ary_current_product[:, 1]]) # 23x1 ndarray 存储本次库存的改变
# print(ev_ary_current_product)
print(self.a_lst_order[0].ev_ary_dlv_product)
if len(self.a_lst_order) > 1:
print(self.a_lst_order[1].ev_ary_dlv_product)
for order in self.a_lst_order:
if order.xv_dlv_t == self.model.t: # 第一次交付
# print(order.xv_dlv_t[0], self.model.t)
if order.xv_dlv_t[0] == self.model.t: # 第一次交付
# Check and make shipment
order.ev_is_delivered = True
for i in range(self.xv_product_num):
@ -86,7 +93,9 @@ class OrderSystem(ap.Agent):
order.ev_ary_dlv_product[i] = 0
else:
order.ev_is_delivered = False
elif order.xv_dlv_t < self.model.t and order.ev_is_delivered == False: # 第二次交付
if order.ev_is_delivered:
print('hhh')
elif order.xv_dlv_t[0] < self.model.t and order.ev_is_delivered == False: # 第二次交付
order.ev_is_delivered = True
for i in range(self.xv_product_num):
if order.ev_ary_dlv_product[i] > self.ev_changed_product[i]: # 先判断能不能一次性交付
@ -98,7 +107,7 @@ class OrderSystem(ap.Agent):
order.ev_ary_dlv_product = np.zeros((self.xv_product_num,))
order.ev_actual_dlv_t = self.model.t
order.ev_int_delay_time = order.ev_actual_dlv_t - order.xv_dlv_t
order.ev_int_delay_time = order.ev_actual_dlv_t - order.xv_dlv_t[0]
self.ev_ave_delay_time += order.ev_int_delay_time * delay_num / 10000

Binary file not shown.