first normal run
This commit is contained in:
54
model.py
54
model.py
@@ -107,7 +107,6 @@ class Model(ap.Model):
|
||||
for product in firm_agent.a_lst_product:
|
||||
firm_agent.dct_prod_capacity[product] = self.nprandom.integers(
|
||||
firm_agent.revenue_log / 5, firm_agent.revenue_log / 5 + 2)
|
||||
# print(firm_agent.name, firm_agent.dct_prod_capacity)
|
||||
|
||||
self.firm_network.add_agents([firm_agent], [ag_node])
|
||||
self.a_lst_total_firms = ap.AgentList(self, self.firm_network.agents)
|
||||
@@ -152,12 +151,12 @@ class Model(ap.Model):
|
||||
self.stop()
|
||||
|
||||
def step(self):
|
||||
print('\n', '=' * 20, 'step', self.t, '=' * 20)
|
||||
print(
|
||||
'dct_list_remove_firm_prod', {
|
||||
key.name: value.code
|
||||
for key, value in self.dct_lst_remove_firm_prod.items()
|
||||
})
|
||||
# print('\n', '=' * 20, 'step', self.t, '=' * 20)
|
||||
# print(
|
||||
# 'dct_list_remove_firm_prod', {
|
||||
# key.name: value.code
|
||||
# for key, value in self.dct_lst_remove_firm_prod.items()
|
||||
# })
|
||||
|
||||
# remove_edge_to_cus_and_cus_up_prod
|
||||
for firm, a_lst_product in self.dct_lst_remove_firm_prod.items():
|
||||
@@ -165,7 +164,7 @@ class Model(ap.Model):
|
||||
firm.remove_edge_to_cus_remove_cus_up_prod(product)
|
||||
|
||||
for n_trial in range(self.int_n_max_trial):
|
||||
print('=' * 10, 'trial', n_trial, '=' * 10)
|
||||
# print('=' * 10, 'trial', n_trial, '=' * 10)
|
||||
# seek_alt_supply
|
||||
# shuffle self.a_lst_total_firms
|
||||
self.a_lst_total_firms = self.a_lst_total_firms.shuffle()
|
||||
@@ -192,9 +191,9 @@ class Model(ap.Model):
|
||||
self.dct_lst_disrupt_firm_prod = {}
|
||||
for firm in self.a_lst_total_firms:
|
||||
if len(firm.a_lst_up_product_removed) > 0:
|
||||
print(firm.name, 'a_lst_up_product_removed', [
|
||||
product.code for product in firm.a_lst_up_product_removed
|
||||
])
|
||||
# print(firm.name, 'a_lst_up_product_removed', [
|
||||
# product.code for product in firm.a_lst_up_product_removed
|
||||
# ])
|
||||
for product in firm.a_lst_product:
|
||||
n_up_product_removed = 0
|
||||
for up_product_removed in firm.a_lst_up_product_removed:
|
||||
@@ -232,24 +231,24 @@ class Model(ap.Model):
|
||||
firm] = ap.AgentList(
|
||||
self.model, [product])
|
||||
|
||||
print(
|
||||
'dct_list_remove_firm_prod', {
|
||||
key.name: value.code
|
||||
for key, value in self.dct_lst_remove_firm_prod.items()
|
||||
})
|
||||
# print(
|
||||
# 'dct_list_remove_firm_prod', {
|
||||
# key.name: value.code
|
||||
# for key, value in self.dct_lst_remove_firm_prod.items()
|
||||
# })
|
||||
|
||||
def end(self):
|
||||
print('/' * 20, 'output', '/' * 20)
|
||||
print('dct_list_remove_firm_prod')
|
||||
for t, dct in self.lst_dct_lst_remove_firm_prod:
|
||||
for firm, a_lst_product in dct.items():
|
||||
for product in a_lst_product:
|
||||
print(t, firm.name, product.code)
|
||||
print('dct_lst_disrupt_firm_prod')
|
||||
for t, dct in self.lst_dct_lst_disrupt_firm_prod:
|
||||
for firm, a_lst_product in dct.items():
|
||||
for product in a_lst_product:
|
||||
print(t, firm.name, product.code)
|
||||
# print('/' * 20, 'output', '/' * 20)
|
||||
# print('dct_list_remove_firm_prod')
|
||||
# for t, dct in self.lst_dct_lst_remove_firm_prod:
|
||||
# for firm, a_lst_product in dct.items():
|
||||
# for product in a_lst_product:
|
||||
# print(t, firm.name, product.code)
|
||||
# print('dct_lst_disrupt_firm_prod')
|
||||
# for t, dct in self.lst_dct_lst_disrupt_firm_prod:
|
||||
# for firm, a_lst_product in dct.items():
|
||||
# for product in a_lst_product:
|
||||
# print(t, firm.name, product.code)
|
||||
|
||||
qry_result = db_session.query(Result).filter_by(s_id=self.sample.id)
|
||||
if qry_result.count() == 0:
|
||||
@@ -288,7 +287,6 @@ class Model(ap.Model):
|
||||
prog="twopi",
|
||||
args="")
|
||||
node_label = nx.get_node_attributes(self.firm_network.graph, 'Name')
|
||||
# print(node_label)
|
||||
node_degree = dict(self.firm_network.graph.out_degree())
|
||||
node_label = {
|
||||
key: f"{node_label[key]} {node_degree[key]}"
|
||||
|
||||
Reference in New Issue
Block a user