accept order conditionally
This commit is contained in:
15
model.py
15
model.py
@@ -106,11 +106,20 @@ class Model(ap.Model):
|
||||
size / sum(list_revenue_log)
|
||||
for size in list_revenue_log
|
||||
]
|
||||
succ_firm = self.nprandom.choice(list_succ_firms,
|
||||
list_f_same_p = Firm['Code'][Firm[product_code] ==
|
||||
1].to_list()
|
||||
list_f_size_same_p = [
|
||||
G_Firm.nodes[f]['Revenue_Log']
|
||||
for f in list_f_same_p
|
||||
]
|
||||
share = G_Firm.nodes[node]['Revenue_Log'] / sum(list_f_size_same_p)
|
||||
num_succ_f = round(share * len(list_succ_firms)) if round(share * len(list_succ_firms)) > 0 else 1
|
||||
list_choose_firm = self.nprandom.choice(list_succ_firms, num_succ_f,
|
||||
p=list_prob)
|
||||
list_choose_firm = list(set(list_choose_firm))
|
||||
list_added_edges = [(node, succ_firm, {
|
||||
'Product': product_code
|
||||
})]
|
||||
}) for succ_firm in list_choose_firm]
|
||||
G_Firm.add_edges_from(list_added_edges)
|
||||
# print('-' * 20)
|
||||
|
||||
@@ -189,7 +198,7 @@ class Model(ap.Model):
|
||||
firm.a_list_product_removed.append(product)
|
||||
|
||||
# draw network
|
||||
self.draw_network()
|
||||
# self.draw_network()
|
||||
|
||||
def update(self):
|
||||
self.a_list_total_firms.clean_before_time_step()
|
||||
|
||||
Reference in New Issue
Block a user