capacity init network
This commit is contained in:
21
firm.py
21
firm.py
@@ -29,12 +29,23 @@ class FirmAgent(ap.Agent):
|
||||
# remove edge
|
||||
# print(n1, n2, key, product_code)
|
||||
self.firm_network.graph.remove_edge(n1, n2, key)
|
||||
# remove customer up product
|
||||
# remove customer up product if does not have alternative
|
||||
customer = ap.AgentIter(self.model, n2).to_list()[0]
|
||||
if remove_product not in customer.a_list_up_product_removed:
|
||||
customer.a_list_up_product_removed.append(remove_product)
|
||||
customer.dct_num_trial_up_product_removed[
|
||||
remove_product] = 0
|
||||
list_in_edges = list(
|
||||
self.firm_network.graph.in_edges(n2,
|
||||
keys=True,
|
||||
data='Product'))
|
||||
select_edges = [
|
||||
edge for edge in list_in_edges
|
||||
if edge[-1] == remove_product.code
|
||||
]
|
||||
if len(select_edges) == 0:
|
||||
if remove_product not in \
|
||||
customer.a_list_up_product_removed:
|
||||
customer.a_list_up_product_removed.append(
|
||||
remove_product)
|
||||
customer.dct_num_trial_up_product_removed[
|
||||
remove_product] = 0
|
||||
|
||||
# # disrupt customer
|
||||
# customer = ap.AgentIter(self.model, n2).to_list()[0]
|
||||
|
||||
Reference in New Issue
Block a user