rename variable
This commit is contained in:
parent
a8259fdc7d
commit
313870bcc3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -112,9 +112,9 @@ class ControllerDB:
|
|||
|
||||
def add_experiment_1(self, idx_scenario, idx_init_removal,
|
||||
dct_lst_init_remove_firm_prod, g_bom,
|
||||
n_max_trial, crit_supplier, firm_pref_request,
|
||||
firm_pref_accept, netw_pref_supp_n,
|
||||
netw_pref_supp_size, cap_limit, diff_new_conn,
|
||||
n_max_trial, crit_supplier, firm_req_prf_size,
|
||||
firm_acc_prf_size, netw_sply_prf_n,
|
||||
netw_sply_prf_size, cap_limit, diff_new_conn,
|
||||
diff_remove, proactive_ratio):
|
||||
e = Experiment(
|
||||
idx_scenario=idx_scenario,
|
||||
|
@ -125,10 +125,10 @@ class ControllerDB:
|
|||
g_bom=g_bom,
|
||||
n_max_trial=n_max_trial,
|
||||
crit_supplier=crit_supplier,
|
||||
firm_pref_request=firm_pref_request,
|
||||
firm_pref_accept=firm_pref_accept,
|
||||
netw_pref_supp_n=netw_pref_supp_n,
|
||||
netw_pref_supp_size=netw_pref_supp_size,
|
||||
firm_req_prf_size=firm_req_prf_size,
|
||||
firm_acc_prf_size=firm_acc_prf_size,
|
||||
netw_sply_prf_n=netw_sply_prf_n,
|
||||
netw_sply_prf_size=netw_sply_prf_size,
|
||||
cap_limit=cap_limit,
|
||||
diff_new_conn=diff_new_conn,
|
||||
diff_remove=diff_remove,
|
||||
|
@ -262,33 +262,3 @@ class ControllerDB:
|
|||
def lock_the_sample(sample: Sample):
|
||||
sample.is_done_flag, sample.computer_name = 0, platform.node()
|
||||
db_session.commit()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# pprint.pprint(dct_exp_config)
|
||||
# pprint.pprint(dct_conf_problem)
|
||||
db = ControllerDB('first')
|
||||
ratio = db_session.execute(
|
||||
'SELECT COUNT(*) / 332750 FROM first_sample s WHERE s.is_done_flag = 1'
|
||||
).scalar()
|
||||
print(ratio)
|
||||
# db.fill_experiment_table()
|
||||
# print(db.dct_parameter)
|
||||
# db.init_tables()
|
||||
# db.fill_sample_table()
|
||||
# pprint.pprint(dct_conf_exp)
|
||||
# db.update_bi()
|
||||
# db.reset_db(force_drop=True)
|
||||
# db.prepare_list_sample()
|
||||
#
|
||||
# for i in range(1000):
|
||||
# if i % 10 == 0:
|
||||
# print(i)
|
||||
# print(len(db.lst_saved_s_id_1_2), len(db.lst_saved_s_id_3))
|
||||
# r = db.fetch_a_sample()
|
||||
# if i % 10 == 0:
|
||||
# print(len(db.lst_saved_s_id_1_2), len(db.lst_saved_s_id_3))
|
||||
# print(r, r.experiment.idx_exp)
|
||||
# if i == 400:
|
||||
# print()
|
||||
# pass
|
||||
|
|
12
firm.py
12
firm.py
|
@ -24,8 +24,8 @@ class FirmAgent(ap.Agent):
|
|||
|
||||
# para
|
||||
self.flt_crit_supplier = float(self.p.crit_supplier)
|
||||
self.flt_firm_pref_request = float(self.p.firm_pref_request)
|
||||
self.flt_firm_pref_accept = float(self.p.firm_pref_accept)
|
||||
self.flt_firm_req_prf_size = float(self.p.firm_req_prf_size)
|
||||
self.flt_firm_acc_prf_size = float(self.p.firm_acc_prf_size)
|
||||
self.flt_diff_new_conn = float(self.p.diff_new_conn)
|
||||
|
||||
def remove_edge_to_cus_remove_cus_up_prod(self, remove_product):
|
||||
|
@ -95,7 +95,7 @@ class FirmAgent(ap.Agent):
|
|||
if len(lst_firm_connect) == 0:
|
||||
# select based on size
|
||||
lst_size_damp = \
|
||||
[size ** self.flt_firm_pref_request for size in
|
||||
[size ** self.flt_firm_req_prf_size for size in
|
||||
self.dct_cand_alt_supply_up_prod_removed[
|
||||
product].revenue_log]
|
||||
lst_prob = [size_damp / sum(lst_size_damp)
|
||||
|
@ -106,7 +106,7 @@ class FirmAgent(ap.Agent):
|
|||
elif len(lst_firm_connect) > 0:
|
||||
# select based on size of firm that has connection
|
||||
lst_firm_size_damp = \
|
||||
[size ** self.flt_firm_pref_accept
|
||||
[size ** self.flt_firm_acc_prf_size
|
||||
for size in lst_firm_connect.revenue_log]
|
||||
lst_prob = \
|
||||
[size_damp / sum(lst_firm_size_damp)
|
||||
|
@ -167,7 +167,7 @@ class FirmAgent(ap.Agent):
|
|||
if len(lst_firm_connect) == 0:
|
||||
# handling based on size
|
||||
lst_firm_size_damp = \
|
||||
[size ** self.flt_firm_pref_accept
|
||||
[size ** self.flt_firm_acc_prf_size
|
||||
for size in lst_firm.revenue_log]
|
||||
lst_prob = \
|
||||
[size_damp / sum(lst_firm_size_damp)
|
||||
|
@ -178,7 +178,7 @@ class FirmAgent(ap.Agent):
|
|||
elif len(lst_firm_connect) > 0:
|
||||
# handling based on size of firm that has connection
|
||||
lst_firm_size_damp = \
|
||||
[size ** self.flt_firm_pref_accept
|
||||
[size ** self.flt_firm_acc_prf_size
|
||||
for size in lst_firm_connect.revenue_log]
|
||||
lst_prob = \
|
||||
[size_damp / sum(lst_firm_size_damp)
|
||||
|
|
8
model.py
8
model.py
|
@ -19,8 +19,8 @@ class Model(ap.Model):
|
|||
self.dct_lst_remove_firm_prod = self.p.dct_lst_init_remove_firm_prod
|
||||
|
||||
self.int_n_max_trial = int(self.p.n_max_trial)
|
||||
self.flt_netw_pref_supp_n = float(self.p.netw_pref_supp_n)
|
||||
self.flt_netw_pref_supp_size = float(self.p.netw_pref_supp_size)
|
||||
self.flt_netw_sply_prf_n = float(self.p.netw_sply_prf_n)
|
||||
self.flt_netw_sply_prf_size = float(self.p.netw_sply_prf_size)
|
||||
self.flt_cap_limit = int(self.p.cap_limit)
|
||||
self.flt_diff_remove = float(self.p.diff_remove)
|
||||
self.proactive_ratio = float(self.p.proactive_ratio)
|
||||
|
@ -76,7 +76,7 @@ class Model(ap.Model):
|
|||
1].to_list()
|
||||
lst_pred_firm_size_damp = \
|
||||
[G_Firm.nodes[pred_firm]['Revenue_Log'] **
|
||||
self.flt_netw_pref_supp_size
|
||||
self.flt_netw_sply_prf_size
|
||||
for pred_firm in lst_pred_firm
|
||||
]
|
||||
lst_prob = \
|
||||
|
@ -94,7 +94,7 @@ class Model(ap.Model):
|
|||
share = G_Firm.nodes[node]['Revenue_Log'] / sum(
|
||||
lst_same_prod_firm_size)
|
||||
# damp share
|
||||
share = share ** self.flt_netw_pref_supp_n
|
||||
share = share ** self.flt_netw_sply_prf_n
|
||||
n_pred_firm = round(share * len(lst_pred_firm)) if round(
|
||||
share * len(lst_pred_firm)) > 0 else 1 # at least one
|
||||
lst_choose_firm = self.nprandom.choice(lst_pred_firm,
|
||||
|
|
8
orm.py
8
orm.py
|
@ -56,10 +56,10 @@ class Experiment(Base):
|
|||
|
||||
n_max_trial = Column(Integer, nullable=False)
|
||||
crit_supplier = Column(DECIMAL(8, 4), nullable=False)
|
||||
firm_pref_request = Column(DECIMAL(8, 4), nullable=False)
|
||||
firm_pref_accept = Column(DECIMAL(8, 4), nullable=False)
|
||||
netw_pref_supp_n = Column(DECIMAL(8, 4), nullable=False)
|
||||
netw_pref_supp_size = Column(DECIMAL(8, 4), nullable=False)
|
||||
firm_req_prf_size = Column(DECIMAL(8, 4), nullable=False)
|
||||
firm_acc_prf_size = Column(DECIMAL(8, 4), nullable=False)
|
||||
netw_sply_prf_n = Column(DECIMAL(8, 4), nullable=False)
|
||||
netw_sply_prf_size = Column(DECIMAL(8, 4), nullable=False)
|
||||
cap_limit = Column(Integer, nullable=False)
|
||||
diff_new_conn = Column(DECIMAL(8, 4), nullable=False)
|
||||
diff_remove = Column(DECIMAL(8, 4), nullable=False)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
n_max_trial,crit_supplier,firm_pref_request,firm_pref_accept,netw_pref_supp_n,netw_pref_supp_size,cap_limit,diff_new_conn,diff_remove,proactive_ratio
|
||||
n_max_trial,crit_supplier,firm_req_prf_size,firm_acc_prf_size,netw_sply_prf_size,netw_pref_supp_size,cap_limit,diff_new_conn,diff_remove,proactive_ratio
|
||||
15,2,2,2,0.5,2,4,0.5,0.5,0.4
|
||||
10,1,1,1,1,1,2,1,1,0.6
|
||||
5,0.5,0.5,0.5,2,0.5,1,2,2,0.8
|
||||
|
|
|
|
@ -1,2 +1,2 @@
|
|||
n_max_trial,crit_supplier,firm_pref_request,firm_pref_accept,netw_pref_supp_n,netw_pref_supp_size,cap_limit,diff_new_conn,diff_remove,proactive_ratio
|
||||
n_max_trial,crit_supplier,firm_req_prf_size,firm_acc_prf_size,netw_sply_prf_n,netw_sply_prf_size,cap_limit,diff_new_conn,diff_remove,proactive_ratio
|
||||
10,1,1,1,1,1,2,1,1,0.8
|
||||
|
|
|
Loading…
Reference in New Issue