connected firm no accept probability

This commit is contained in:
2023-07-27 12:50:52 +08:00
parent 924847db5d
commit 74d8798b1d
13 changed files with 58 additions and 9 deletions

View File

@@ -261,7 +261,14 @@ class FirmAgent(ap.Agent):
def accept_request(self, down_firm, product):
# para product is the product that self is selling
prod_accept = self.flt_diff_new_conn
# connected firm has no probability
node_self = self.get_firm_network_node()
node_d_firm = down_firm.get_firm_network_node()
if self.model.firm_network.graph.has_edge(node_self, node_d_firm) or \
self.model.firm_network.graph.has_edge(node_d_firm, node_self):
prod_accept = 1.0
else:
prod_accept = self.flt_diff_new_conn
if self.model.nprandom.choice([True, False],
p=[prod_accept, 1 - prod_accept]):
self.firm_network.graph.add_edges_from([