change the way to find connected firm
This commit is contained in:
parent
74d8798b1d
commit
921f03fc44
Binary file not shown.
40
firm.py
40
firm.py
|
@ -120,18 +120,12 @@ class FirmAgent(ap.Agent):
|
||||||
if self.is_prf_conn:
|
if self.is_prf_conn:
|
||||||
for firm in \
|
for firm in \
|
||||||
self.dct_cand_alt_supp_up_prod_disrupted[product]:
|
self.dct_cand_alt_supp_up_prod_disrupted[product]:
|
||||||
out_edges = self.model.firm_network.graph.out_edges(
|
node_self = self.get_firm_network_node()
|
||||||
self.model.firm_network.positions[firm], keys=True)
|
node_firm = firm.get_firm_network_node()
|
||||||
in_edges = self.model.firm_network.graph.in_edges(
|
if self.model.firm_network.graph.\
|
||||||
self.model.firm_network.positions[firm], keys=True)
|
has_edge(node_self, node_firm) or \
|
||||||
lst_adj_firm = []
|
self.model.firm_network.graph.\
|
||||||
lst_adj_firm += \
|
has_edge(node_firm, node_self):
|
||||||
[ap.AgentIter(self.model, edge[1]).to_list()[
|
|
||||||
0].code for edge in out_edges]
|
|
||||||
lst_adj_firm += \
|
|
||||||
[ap.AgentIter(self.model, edge[0]).to_list()[
|
|
||||||
0].code for edge in in_edges]
|
|
||||||
if self.code in lst_adj_firm:
|
|
||||||
lst_firm_connect.append(firm)
|
lst_firm_connect.append(firm)
|
||||||
if len(lst_firm_connect) == 0:
|
if len(lst_firm_connect) == 0:
|
||||||
# select based on size or not
|
# select based on size or not
|
||||||
|
@ -201,22 +195,12 @@ class FirmAgent(ap.Agent):
|
||||||
lst_firm_connect = []
|
lst_firm_connect = []
|
||||||
if self.is_prf_conn:
|
if self.is_prf_conn:
|
||||||
for firm in lst_firm:
|
for firm in lst_firm:
|
||||||
out_edges = \
|
node_self = self.get_firm_network_node()
|
||||||
self.model.firm_network.graph.out_edges(
|
node_firm = firm.get_firm_network_node()
|
||||||
self.model.firm_network.positions[firm],
|
if self.model.firm_network.graph.\
|
||||||
keys=True)
|
has_edge(node_self, node_firm) or \
|
||||||
in_edges = \
|
self.model.firm_network.graph.\
|
||||||
self.model.firm_network.graph.in_edges(
|
has_edge(node_firm, node_self):
|
||||||
self.model.firm_network.positions[firm],
|
|
||||||
keys=True)
|
|
||||||
lst_adj_firm = []
|
|
||||||
lst_adj_firm += \
|
|
||||||
[ap.AgentIter(self.model, edge[1]).to_list()[
|
|
||||||
0].code for edge in out_edges]
|
|
||||||
lst_adj_firm += \
|
|
||||||
[ap.AgentIter(self.model, edge[0]).to_list()[
|
|
||||||
0].code for edge in in_edges]
|
|
||||||
if self.code in lst_adj_firm:
|
|
||||||
lst_firm_connect.append(firm)
|
lst_firm_connect.append(firm)
|
||||||
if len(lst_firm_connect) == 0:
|
if len(lst_firm_connect) == 0:
|
||||||
# handling based on size or not
|
# handling based on size or not
|
||||||
|
|
Loading…
Reference in New Issue