init extra capacity in firm.py
This commit is contained in:
25
firm.py
25
firm.py
@@ -12,7 +12,7 @@ class FirmAgent(ap.Agent):
|
||||
self.type_region = type_region
|
||||
self.revenue_log = revenue_log
|
||||
self.a_lst_product = a_lst_product
|
||||
self.dct_prod_capacity = dict.fromkeys(self.a_lst_product)
|
||||
self.dct_prod_capacity = {}
|
||||
|
||||
# self.a_lst_up_product_removed = ap.AgentList(self.model, [])
|
||||
# self.a_lst_product_disrupted = ap.AgentList(self.model, [])
|
||||
@@ -35,9 +35,32 @@ class FirmAgent(ap.Agent):
|
||||
# para
|
||||
self.is_prf_size = self.model.is_prf_size
|
||||
self.is_prf_conn = bool(self.p.prf_conn)
|
||||
self.str_cap_limit_prob_type = str(self.p.cap_limit_prob_type)
|
||||
self.flt_cap_limit_level = float(self.p.cap_limit_level)
|
||||
self.flt_diff_new_conn = float(self.p.diff_new_conn)
|
||||
self.flt_crit_supplier = float(self.p.crit_supplier)
|
||||
|
||||
# init extra capacity
|
||||
for product in self.a_lst_product:
|
||||
# init extra capacity based on discrete uniform distribution
|
||||
assert self.str_cap_limit_prob_type in ['uniform', 'normal'], \
|
||||
"cap_limit_prob_type other than uniform, normal"
|
||||
if self.str_cap_limit_prob_type == 'uniform':
|
||||
extra_cap_mean = \
|
||||
self.revenue_log / self.flt_cap_limit_level
|
||||
extra_cap = self.model.nprandom.integers(extra_cap_mean-2,
|
||||
extra_cap_mean+2)
|
||||
extra_cap = 0 if round(extra_cap) < 0 else round(extra_cap)
|
||||
# print(firm_agent.name, extra_cap)
|
||||
self.dct_prod_capacity[product] = extra_cap
|
||||
elif self.str_cap_limit_prob_type == 'normal':
|
||||
extra_cap_mean = \
|
||||
self.revenue_log / self.flt_cap_limit_level
|
||||
extra_cap = self.model.nprandom.normal(extra_cap_mean, 1)
|
||||
extra_cap = 0 if round(extra_cap) < 0 else round(extra_cap)
|
||||
# print(firm_agent.name, extra_cap)
|
||||
self.dct_prod_capacity[product] = extra_cap
|
||||
|
||||
def remove_edge_to_cus_remove_cus_up_prod(self, remove_product):
|
||||
lst_out_edge = list(
|
||||
self.firm_network.graph.out_edges(
|
||||
|
||||
Reference in New Issue
Block a user