This commit is contained in:
2023-03-07 12:29:27 +08:00
parent b291578889
commit 586272c923
5 changed files with 70 additions and 5 deletions

View File

@@ -8,9 +8,15 @@ from product import ProductAgent
sample = 0
seed = 0
n_iter = 3
n_iter = 10
# dct_list_init_remove_firm_prod = {133: ['1.4.4.1'], 2: ['1.1.3']}
# dct_list_init_remove_firm_prod = {
# 135: ['1.3.2.1'],
# 133: ['1.4.4.1'],
# 2: ['1.1.3']
# }
dct_list_init_remove_firm_prod = {
140: ['1.4.5.1'],
135: ['1.3.2.1'],
133: ['1.4.4.1'],
2: ['1.1.3']
@@ -177,6 +183,7 @@ class Model(ap.Model):
self.draw_network()
def update(self):
self.a_list_total_firms.clean_before_time_step()
# stop simulation if reached terminal number of iteration
if self.t == self.int_n_iter or len(
self.dct_list_remove_firm_prod) == 0:
@@ -232,6 +239,7 @@ class Model(ap.Model):
self.dct_list_remove_firm_prod = {}
for firm in self.a_list_total_firms:
if len(firm.a_list_up_product_removed) > 0:
print(firm.name, 'a_list_up_product_removed', [product.code for product in firm.a_list_up_product_removed])
for product in firm.a_list_product:
n_up_product_removed = 0
for up_product_removed in firm.a_list_up_product_removed:
@@ -251,8 +259,9 @@ class Model(ap.Model):
1) / (max(list_revenue_log) -
min(list_revenue_log) + 1)
p_remove = 1 - std_size * (1 - lost_percent)
flag = self.nprandom.choice([1, 0],
p=[p_remove, 1 - p_remove])
# flag = self.nprandom.choice([1, 0],
# p=[p_remove, 1 - p_remove])
flag = 1
if flag == 1:
firm.a_list_product_removed.append(product)
# if firm in