accept order conditionally
This commit is contained in:
7
firm.py
7
firm.py
@@ -31,7 +31,7 @@ class FirmAgent(ap.Agent):
|
||||
# print(n1, n2, key, product_code)
|
||||
self.firm_network.graph.remove_edge(n1, n2, key)
|
||||
|
||||
# remove customer up product if does not have alternative / con
|
||||
# remove customer up product conditionally
|
||||
customer = ap.AgentIter(self.model, n2).to_list()[0]
|
||||
list_in_edges = list(
|
||||
self.firm_network.graph.in_edges(n2,
|
||||
@@ -126,7 +126,10 @@ class FirmAgent(ap.Agent):
|
||||
# print(product.code, [firm.name for firm in list_firm])
|
||||
|
||||
def accept_request(self, down_firm, product):
|
||||
if self.model.nprandom.choice([True, False], p=[0.1, 0.9]):
|
||||
# if self.model.nprandom.choice([True, False], p=[0.1, 0.9]):
|
||||
lst_f_s = [firm.revenue_log for firm in self.model.a_list_total_firms if product in firm.a_list_product]
|
||||
p_accept = self.revenue_log / sum(lst_f_s)
|
||||
if self.model.nprandom.choice([True, False], p=[p_accept, 1-p_accept]):
|
||||
self.firm_network.graph.add_edges_from([
|
||||
(self.firm_network.positions[self],
|
||||
self.firm_network.positions[down_firm], {
|
||||
|
||||
Reference in New Issue
Block a user