firm request and accept preference to 2 level
This commit is contained in:
parent
daab7af6ee
commit
67aa573154
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
66
firm.py
66
firm.py
|
@ -24,9 +24,9 @@ class FirmAgent(ap.Agent):
|
|||
|
||||
# para
|
||||
self.flt_crit_supplier = float(self.p.crit_supplier)
|
||||
self.flt_firm_req_prf_size = float(self.p.firm_req_prf_size)
|
||||
self.is_firm_req_prf_size = bool(self.p.firm_req_prf_size)
|
||||
self.is_firm_req_prf_conn = bool(self.p.firm_req_prf_conn)
|
||||
self.flt_firm_acc_prf_size = float(self.p.firm_acc_prf_size)
|
||||
self.is_firm_acc_prf_size = bool(self.p.firm_acc_prf_size)
|
||||
self.is_firm_acc_prf_conn = bool(self.p.firm_acc_prf_conn)
|
||||
self.flt_diff_new_conn = float(self.p.diff_new_conn)
|
||||
|
||||
|
@ -97,27 +97,34 @@ class FirmAgent(ap.Agent):
|
|||
if self.code in lst_adj_firm:
|
||||
lst_firm_connect.append(firm)
|
||||
if len(lst_firm_connect) == 0:
|
||||
# select based on size
|
||||
lst_size_damp = \
|
||||
[size ** self.flt_firm_req_prf_size for size in
|
||||
# select based on size or not
|
||||
if self.is_firm_req_prf_size:
|
||||
lst_size = \
|
||||
[size for size in
|
||||
self.dct_cand_alt_supply_up_prod_removed[
|
||||
product].revenue_log]
|
||||
lst_prob = [size_damp / sum(lst_size_damp)
|
||||
for size_damp in lst_size_damp]
|
||||
lst_prob = [size / sum(lst_size)
|
||||
for size in lst_size]
|
||||
select_alt_supply = self.model.nprandom.choice(
|
||||
self.dct_cand_alt_supply_up_prod_removed[product],
|
||||
p=lst_prob)
|
||||
else:
|
||||
select_alt_supply = self.model.nprandom.choice(
|
||||
self.dct_cand_alt_supply_up_prod_removed[product])
|
||||
elif len(lst_firm_connect) > 0:
|
||||
# select based on size of firm that has connection
|
||||
lst_firm_size_damp = \
|
||||
[firm.revenue_log ** self.flt_firm_acc_prf_size
|
||||
for firm in lst_firm_connect]
|
||||
# select based on size of connected firm or not
|
||||
if self.is_firm_req_prf_size:
|
||||
lst_firm_size = \
|
||||
[firm.revenue_log for firm in lst_firm_connect]
|
||||
lst_prob = \
|
||||
[size_damp / sum(lst_firm_size_damp)
|
||||
for size_damp in lst_firm_size_damp]
|
||||
[size / sum(lst_firm_size)
|
||||
for size in lst_firm_size]
|
||||
select_alt_supply = \
|
||||
self.model.nprandom.choice(lst_firm_connect,
|
||||
p=lst_prob)
|
||||
else:
|
||||
select_alt_supply = \
|
||||
self.model.nprandom.choice(lst_firm_connect)
|
||||
# print(
|
||||
# f"{self.name} selct alt supply for {product.code} "
|
||||
# f"from {select_alt_supply.name}"
|
||||
|
@ -174,27 +181,34 @@ class FirmAgent(ap.Agent):
|
|||
if self.code in lst_adj_firm:
|
||||
lst_firm_connect.append(firm)
|
||||
if len(lst_firm_connect) == 0:
|
||||
# handling based on size
|
||||
lst_firm_size_damp = \
|
||||
[firm.revenue_log ** self.flt_firm_acc_prf_size
|
||||
for firm in lst_firm]
|
||||
# handling based on size or not
|
||||
if self.is_firm_acc_prf_size:
|
||||
lst_firm_size = \
|
||||
[firm.revenue_log for firm in lst_firm]
|
||||
lst_prob = \
|
||||
[size_damp / sum(lst_firm_size_damp)
|
||||
for size_damp in lst_firm_size_damp]
|
||||
[size / sum(lst_firm_size)
|
||||
for size in lst_firm_size]
|
||||
select_customer = \
|
||||
self.model.nprandom.choice(lst_firm, p=lst_prob)
|
||||
self.model.nprandom.choice(lst_firm,
|
||||
p=lst_prob)
|
||||
else:
|
||||
select_customer = \
|
||||
self.model.nprandom.choice(lst_firm)
|
||||
self.accept_request(select_customer, product)
|
||||
elif len(lst_firm_connect) > 0:
|
||||
# handling based on size of firm that has connection
|
||||
lst_firm_size_damp = \
|
||||
[firm.revenue_log ** self.flt_firm_acc_prf_size
|
||||
for firm in lst_firm_connect]
|
||||
# handling based on size of connected firm or not
|
||||
if self.is_firm_acc_prf_size:
|
||||
lst_firm_size = \
|
||||
[firm.revenue_log for firm in lst_firm_connect]
|
||||
lst_prob = \
|
||||
[size_damp / sum(lst_firm_size_damp)
|
||||
for size_damp in lst_firm_size_damp]
|
||||
[size / sum(lst_firm_size)
|
||||
for size in lst_firm_size]
|
||||
select_customer = \
|
||||
self.model.nprandom.choice(lst_firm_connect,
|
||||
p=lst_prob)
|
||||
else:
|
||||
select_customer = \
|
||||
self.model.nprandom.choice(lst_firm_connect)
|
||||
self.accept_request(select_customer, product)
|
||||
|
||||
def accept_request(self, down_firm, product):
|
||||
|
|
4
orm.py
4
orm.py
|
@ -55,11 +55,11 @@ class Experiment(Base):
|
|||
g_bom = Column(Text(4294000000), nullable=False)
|
||||
|
||||
n_max_trial = Column(Integer, nullable=False)
|
||||
firm_req_prf_size = Column(DECIMAL(8, 4), nullable=False)
|
||||
firm_req_prf_size = Column(Boolean, nullable=False)
|
||||
firm_req_prf_conn = Column(Boolean, nullable=False)
|
||||
cap_limit_prob_type = Column(String(16), nullable=False)
|
||||
cap_limit_level = Column(DECIMAL(8, 4), nullable=False)
|
||||
firm_acc_prf_size = Column(DECIMAL(8, 4), nullable=False)
|
||||
firm_acc_prf_size = Column(Boolean, nullable=False)
|
||||
firm_acc_prf_conn = Column(Boolean, nullable=False)
|
||||
diff_new_conn = Column(DECIMAL(8, 4), nullable=False)
|
||||
crit_supplier = Column(DECIMAL(8, 4), nullable=False)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
n_max_trial,firm_req_prf_size,firm_req_prf_conn,cap_limit_prob_type,cap_limit_level,firm_acc_prf_size,firm_acc_prf_conn,diff_new_conn,crit_supplier,diff_remove,proactive_ratio,netw_sply_prf_n,netw_sply_prf_size,netw_cust_prf_n,netw_cust_prf_size
|
||||
15,2,TRUE,uniform,5,2,TRUE,0.3,2,0.5,0.4,3,TRUE,3,TRUE
|
||||
10,1,FALSE,normal,10,1,FALSE,0.5,1,1,0.6,2,FALSE,2,FALSE
|
||||
5,0.5,,,15,0.5,,0.7,0.5,2,0.8,1,,1,
|
||||
15,TRUE,TRUE,uniform,5,TRUE,TRUE,0.3,2,0.5,0.4,3,TRUE,3,TRUE
|
||||
10,FALSE,FALSE,normal,10,FALSE,FALSE,0.5,1,1,0.6,2,FALSE,2,FALSE
|
||||
5,,,,15,,,0.7,0.5,2,0.8,1,,1,
|
||||
|
|
|
|
@ -1,20 +1,2 @@
|
|||
n_max_trial,firm_req_prf_size,firm_req_prf_conn,cap_limit_prob_type,cap_limit_level,firm_acc_prf_size,firm_acc_prf_conn,diff_new_conn,crit_supplier,diff_remove,proactive_ratio,netw_sply_prf_n,netw_sply_prf_size,netw_cust_prf_n,netw_cust_prf_size
|
||||
10,1,TRUE,uniform,10,1,TRUE,0.7,1,1,0.9,2,TRUE,2,TRUE
|
||||
,,,,,,,,,,,,,,
|
||||
,,,,,,,,,,,,,,
|
||||
,,,,,,,,,,,,,,
|
||||
n_max_trial,,,,,,,,,,,,,,
|
||||
firm_req_prf_size,,,,,,,,,,,,,,
|
||||
firm_req_prf_conn,,,,,,,,,,,,,,
|
||||
cap_limit_prob_type,,,,,,,,,,,,,,
|
||||
cap_limit_level,,,,,,,,,,,,,,
|
||||
firm_acc_prf_size,,,,,,,,,,,,,,
|
||||
firm_acc_prf_conn,,,,,,,,,,,,,,
|
||||
diff_new_conn,,,,,,,,,,,,,,
|
||||
crit_supplier,,,,,,,,,,,,,,
|
||||
diff_remove,,,,,,,,,,,,,,
|
||||
proactive_ratio,,,,,,,,,,,,,,
|
||||
netw_sply_prf_n,,,,,,,,,,,,,,
|
||||
netw_sply_prf_size,,,,,,,,,,,,,,
|
||||
netw_cust_prf_n,,,,,,,,,,,,,,
|
||||
netw_cust_prf_size,,,,,,,,,,,,,,
|
||||
10,TRUE,TRUE,uniform,10,TRUE,TRUE,0.7,1,1,0.9,2,TRUE,2,TRUE
|
||||
|
|
|
Loading…
Reference in New Issue