zero capacity firm should also be removed from candidate list to prevent repeated request

This commit is contained in:
HaoYizhi 2023-07-02 15:08:02 +08:00
parent c348f3eb9c
commit 206dd2fbc0
1 changed files with 9 additions and 0 deletions

View File

@ -246,6 +246,15 @@ class FirmAgent(ap.Agent):
select_customer = \ select_customer = \
self.model.nprandom.choice(lst_firm_connect) self.model.nprandom.choice(lst_firm_connect)
self.accept_request(select_customer, product) self.accept_request(select_customer, product)
else:
for down_firm in lst_firm:
down_firm.dct_cand_alt_supp_up_prod_disrupted[
product].remove(self)
print(
f"{self.name} denied {product.code} request "
f"from {down_firm.name} for lack of capacity"
)
def accept_request(self, down_firm, product): def accept_request(self, down_firm, product):
# para product is the product that self is selling # para product is the product that self is selling