generate network based on size or not
This commit is contained in:
parent
6d43865f79
commit
48077189f0
Binary file not shown.
Binary file not shown.
Binary file not shown.
60
model.py
60
model.py
|
@ -20,9 +20,9 @@ class Model(ap.Model):
|
||||||
|
|
||||||
self.int_n_max_trial = int(self.p.n_max_trial)
|
self.int_n_max_trial = int(self.p.n_max_trial)
|
||||||
self.int_netw_sply_prf_n = int(self.p.netw_sply_prf_n)
|
self.int_netw_sply_prf_n = int(self.p.netw_sply_prf_n)
|
||||||
self.flt_netw_sply_prf_size = float(self.p.netw_sply_prf_size)
|
self.is_netw_sply_prf_size = bool(self.p.netw_sply_prf_size)
|
||||||
self.int_netw_cust_prf_n = int(self.p.netw_cust_prf_n)
|
self.int_netw_cust_prf_n = int(self.p.netw_cust_prf_n)
|
||||||
self.flt_netw_cust_prf_size = float(self.p.netw_cust_prf_size)
|
self.is_netw_cust_prf_size = bool(self.p.netw_cust_prf_size)
|
||||||
self.str_cap_limit_prob_type = str(self.p.cap_limit_prob_type)
|
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_cap_limit_level = float(self.p.cap_limit_level)
|
||||||
self.flt_diff_remove = float(self.p.diff_remove)
|
self.flt_diff_remove = float(self.p.diff_remove)
|
||||||
|
@ -80,21 +80,26 @@ class Model(ap.Model):
|
||||||
# get a list of firm producing this component
|
# get a list of firm producing this component
|
||||||
lst_pred_firm = \
|
lst_pred_firm = \
|
||||||
Firm['Code'][Firm[pred_product_code] == 1].to_list()
|
Firm['Code'][Firm[pred_product_code] == 1].to_list()
|
||||||
lst_pred_firm_size_damp = \
|
|
||||||
[G_Firm.nodes[pred_firm]['Revenue_Log'] **
|
|
||||||
self.flt_netw_sply_prf_size
|
|
||||||
for pred_firm in lst_pred_firm]
|
|
||||||
lst_prob = \
|
|
||||||
[size_damp / sum(lst_pred_firm_size_damp)
|
|
||||||
for size_damp in lst_pred_firm_size_damp]
|
|
||||||
# select multiple supplier (multi-sourcing)
|
# select multiple supplier (multi-sourcing)
|
||||||
n_pred_firm = self.int_netw_sply_prf_n
|
n_pred_firm = self.int_netw_sply_prf_n
|
||||||
if n_pred_firm > len(lst_pred_firm):
|
if n_pred_firm > len(lst_pred_firm):
|
||||||
n_pred_firm = len(lst_pred_firm)
|
n_pred_firm = len(lst_pred_firm)
|
||||||
lst_choose_firm = self.nprandom.choice(lst_pred_firm,
|
# based on size or not
|
||||||
n_pred_firm,
|
if self.is_netw_sply_prf_size:
|
||||||
replace=False,
|
lst_pred_firm_size = \
|
||||||
p=lst_prob)
|
[G_Firm.nodes[pred_firm]['Revenue_Log']
|
||||||
|
for pred_firm in lst_pred_firm]
|
||||||
|
lst_prob = \
|
||||||
|
[size / sum(lst_pred_firm_size)
|
||||||
|
for size in lst_pred_firm_size]
|
||||||
|
lst_choose_firm = self.nprandom.choice(lst_pred_firm,
|
||||||
|
n_pred_firm,
|
||||||
|
replace=False,
|
||||||
|
p=lst_prob)
|
||||||
|
else:
|
||||||
|
lst_choose_firm = self.nprandom.choice(lst_pred_firm,
|
||||||
|
n_pred_firm,
|
||||||
|
replace=False)
|
||||||
lst_add_edge = [(pred_firm, node,
|
lst_add_edge = [(pred_firm, node,
|
||||||
{'Product': pred_product_code})
|
{'Product': pred_product_code})
|
||||||
for pred_firm in lst_choose_firm]
|
for pred_firm in lst_choose_firm]
|
||||||
|
@ -141,21 +146,28 @@ class Model(ap.Model):
|
||||||
# get a list of firm producing this finished product
|
# get a list of firm producing this finished product
|
||||||
lst_succ_firm = Firm['Code'][
|
lst_succ_firm = Firm['Code'][
|
||||||
Firm[succ_product_code] == 1].to_list()
|
Firm[succ_product_code] == 1].to_list()
|
||||||
lst_succ_firm_size_damp = \
|
|
||||||
[G_Firm.nodes[succ_firm]['Revenue_Log'] **
|
|
||||||
self.flt_netw_cust_prf_size
|
|
||||||
for succ_firm in lst_succ_firm]
|
|
||||||
lst_prob = \
|
|
||||||
[size_damp / sum(lst_succ_firm_size_damp)
|
|
||||||
for size_damp in lst_succ_firm_size_damp]
|
|
||||||
# select multiple customer (multi-selling)
|
# select multiple customer (multi-selling)
|
||||||
n_succ_firm = self.int_netw_cust_prf_n
|
n_succ_firm = self.int_netw_cust_prf_n
|
||||||
if n_succ_firm > len(lst_succ_firm):
|
if n_succ_firm > len(lst_succ_firm):
|
||||||
n_succ_firm = len(lst_succ_firm)
|
n_succ_firm = len(lst_succ_firm)
|
||||||
lst_choose_firm = self.nprandom.choice(lst_succ_firm,
|
# based on size or not
|
||||||
n_succ_firm,
|
if self.is_netw_cust_prf_size:
|
||||||
replace=False,
|
lst_succ_firm_size = \
|
||||||
p=lst_prob)
|
[G_Firm.nodes[succ_firm]['Revenue_Log']
|
||||||
|
for succ_firm in lst_succ_firm]
|
||||||
|
lst_prob = \
|
||||||
|
[size / sum(lst_succ_firm_size)
|
||||||
|
for size in lst_succ_firm_size]
|
||||||
|
lst_choose_firm = \
|
||||||
|
self.nprandom.choice(lst_succ_firm,
|
||||||
|
n_succ_firm,
|
||||||
|
replace=False,
|
||||||
|
p=lst_prob)
|
||||||
|
else:
|
||||||
|
lst_choose_firm = \
|
||||||
|
self.nprandom.choice(lst_succ_firm,
|
||||||
|
n_succ_firm,
|
||||||
|
replace=False)
|
||||||
lst_add_edge = [(node, succ_firm,
|
lst_add_edge = [(node, succ_firm,
|
||||||
{'Product': product_code})
|
{'Product': product_code})
|
||||||
for succ_firm in lst_choose_firm]
|
for succ_firm in lst_choose_firm]
|
||||||
|
|
4
orm.py
4
orm.py
|
@ -61,9 +61,9 @@ class Experiment(Base):
|
||||||
firm_acc_prf_size = Column(DECIMAL(8, 4), nullable=False)
|
firm_acc_prf_size = Column(DECIMAL(8, 4), nullable=False)
|
||||||
firm_acc_prf_conn = Column(Boolean, nullable=False)
|
firm_acc_prf_conn = Column(Boolean, nullable=False)
|
||||||
netw_sply_prf_n = Column(Integer, nullable=False)
|
netw_sply_prf_n = Column(Integer, nullable=False)
|
||||||
netw_sply_prf_size = Column(DECIMAL(8, 4), nullable=False)
|
netw_sply_prf_size = Column(Boolean, nullable=False)
|
||||||
netw_cust_prf_n = Column(Integer, nullable=False)
|
netw_cust_prf_n = Column(Integer, nullable=False)
|
||||||
netw_cust_prf_size = Column(DECIMAL(8, 4), nullable=False)
|
netw_cust_prf_size = Column(Boolean, nullable=False)
|
||||||
cap_limit_prob_type = Column(String(16), nullable=False)
|
cap_limit_prob_type = Column(String(16), nullable=False)
|
||||||
cap_limit_level = Column(DECIMAL(8, 4), nullable=False)
|
cap_limit_level = Column(DECIMAL(8, 4), nullable=False)
|
||||||
diff_new_conn = Column(DECIMAL(8, 4), nullable=False)
|
diff_new_conn = Column(DECIMAL(8, 4), nullable=False)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
n_max_trial,crit_supplier,firm_req_prf_size,firm_req_prf_conn,firm_acc_prf_size,firm_acc_prf_conn,netw_sply_prf_n,netw_sply_prf_size,netw_cust_prf_n,netw_cust_prf_size,cap_limit_prob_type,cap_limit_level,diff_new_conn,diff_remove,proactive_ratio
|
n_max_trial,crit_supplier,firm_req_prf_size,firm_req_prf_conn,firm_acc_prf_size,firm_acc_prf_conn,netw_sply_prf_n,netw_sply_prf_size,netw_cust_prf_n,netw_cust_prf_size,cap_limit_prob_type,cap_limit_level,diff_new_conn,diff_remove,proactive_ratio
|
||||||
15,2,2,TRUE,2,TRUE,3,2,3,2,uniform,5,0.5,0.5,0.4
|
15,2,2,TRUE,2,TRUE,3,TRUE,3,TRUE,uniform,5,0.5,0.5,0.4
|
||||||
10,1,1,FALSE,1,FALSE,2,1,2,1,normal,10,1,1,0.6
|
10,1,1,FALSE,1,FALSE,2,FALSE,2,FALSE,normal,10,1,1,0.6
|
||||||
5,0.5,0.5,,0.5,,1,0.5,1,0.5,,15,2,2,0.8
|
5,0.5,0.5,,0.5,,1,,1,,,15,2,2,0.8
|
||||||
|
|
|
|
@ -1,2 +1,2 @@
|
||||||
n_max_trial,crit_supplier,firm_req_prf_size,firm_req_prf_conn,firm_acc_prf_size,firm_acc_prf_conn,netw_sply_prf_n,netw_sply_prf_size,netw_cust_prf_n,netw_cust_prf_size,cap_limit_prob_type,cap_limit_level,diff_new_conn,diff_remove,proactive_ratio
|
n_max_trial,crit_supplier,firm_req_prf_size,firm_req_prf_conn,firm_acc_prf_size,firm_acc_prf_conn,netw_sply_prf_n,netw_sply_prf_size,netw_cust_prf_n,netw_cust_prf_size,cap_limit_prob_type,cap_limit_level,diff_new_conn,diff_remove,proactive_ratio
|
||||||
10,1,1,TRUE,1,TRUE,2,1,2,1,uniform,10,1,1,0.9
|
10,1,1,TRUE,1,TRUE,2,TRUE,2,TRUE,uniform,10,1,1,0.9
|
||||||
|
|
|
Loading…
Reference in New Issue