From 206dd2fbc0b4ea27e95754e087bc5ccd23650179 Mon Sep 17 00:00:00 2001 From: HaoYizhi Date: Sun, 2 Jul 2023 15:08:02 +0800 Subject: [PATCH] zero capacity firm should also be removed from candidate list to prevent repeated request --- firm.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/firm.py b/firm.py index e7d97c8..9ba553f 100644 --- a/firm.py +++ b/firm.py @@ -246,6 +246,15 @@ class FirmAgent(ap.Agent): select_customer = \ self.model.nprandom.choice(lst_firm_connect) 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): # para product is the product that self is selling