db_name_prefix with or without exp

This commit is contained in:
HaoYizhi 2023-06-11 20:28:51 +08:00
parent dbbdbc935a
commit c367252da2
9 changed files with 36 additions and 31 deletions

2
.vscode/launch.json vendored
View File

@ -14,7 +14,7 @@
"args": [ "args": [
"--exp", "without_exp", "--exp", "without_exp",
"--reset_db", "True", "--reset_db", "True",
"--job", "30" "--job", "24"
] ]
} }
] ]

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
db_name_prefix: test db_name_prefix: without_exp

View File

@ -46,31 +46,36 @@ class ControllerDB:
Firm.fillna(0, inplace=True) Firm.fillna(0, inplace=True)
# fill dct_lst_init_remove_firm_prod # fill dct_lst_init_remove_firm_prod
# list_dct = [] assert self.db_name_prefix in ['test', 'without_exp', 'with_exp'], \
# for _, row in Firm.iterrows(): "db name not in test, without_exp, with_exp"
# code = row['Code']
# row = row['1':] list_dct = []
# for product_code in row.index[row == 1].to_list(): if self.db_name_prefix in ['test', 'without_exp']:
# dct = {code: [product_code]} for _, row in Firm.iterrows():
# list_dct.append(dct) code = row['Code']
str_sql = "select e_id, count, max_max_ts, " \ row = row['1':]
"dct_lst_init_remove_firm_prod from " \ for product_code in row.index[row == 1].to_list():
"iiabmdb.without_exp_experiment as a " \ dct = {code: [product_code]}
"inner join " \ list_dct.append(dct)
"(select e_id, count(id) as count, max(max_ts) as max_max_ts " \ elif self.db_name_prefix in ['with_exp']:
"from iiabmdb.without_exp_sample as a " \ str_sql = "select e_id, count, max_max_ts, " \
"inner join (select s_id, max(ts) as max_ts from " \ "dct_lst_init_remove_firm_prod from " \
"iiabmdb.without_exp_result where ts > 0 group by s_id) as b " \ "iiabmdb.without_exp_experiment as a " \
"on a.id = b.s_id " \ "inner join " \
"group by e_id) as b " \ "(select e_id, count(id) as count, max(max_ts) as max_max_ts "\
"on a.id = b.e_id " \ "from iiabmdb.without_exp_sample as a " \
"order by count desc;" "inner join (select s_id, max(ts) as max_ts from " \
result = pd.read_sql(sql=str_sql, con=engine) "iiabmdb.without_exp_result where ts > 0 group by s_id) as b "\
result['dct_lst_init_remove_firm_prod'] = \ "on a.id = b.s_id " \
result['dct_lst_init_remove_firm_prod'].apply( "group by e_id) as b " \
lambda x: pickle.loads(x)) "on a.id = b.e_id " \
list_dct = result.loc[result['count'] >= 9, "order by count desc;"
'dct_lst_init_remove_firm_prod'].to_list() result = pd.read_sql(sql=str_sql, con=engine)
result['dct_lst_init_remove_firm_prod'] = \
result['dct_lst_init_remove_firm_prod'].apply(
lambda x: pickle.loads(x))
list_dct = result.loc[result['count'] >= 9,
'dct_lst_init_remove_firm_prod'].to_list()
# list_dct = [{'140': ['1.4.5.1']}] # list_dct = [{'140': ['1.4.5.1']}]
# list_dct = [{'133': ['1.4.4.1']}] # list_dct = [{'133': ['1.4.4.1']}]
# list_dct = [{'2': ['1.1.3']}] # list_dct = [{'2': ['1.1.3']}]

View File

@ -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 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,TRUE,TRUE,uniform,5,TRUE,TRUE,0.3,2,0.5,0.4,3,TRUE,3,TRUE 15,TRUE,TRUE,uniform,5,TRUE,TRUE,0.3,2,0.5,0.3,3,TRUE,3,TRUE
10,FALSE,FALSE,normal,10,FALSE,FALSE,0.5,1,1,0.6,2,FALSE,2,FALSE 10,FALSE,FALSE,normal,10,FALSE,FALSE,0.5,1,1,0.5,2,FALSE,2,FALSE
5,,,,15,,,0.7,0.5,2,0.8,1,,1, 5,,,,15,,,0.7,0.5,2,0.7,1,,1,

1 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
2 15 TRUE TRUE uniform 5 TRUE TRUE 0.3 2 0.5 0.4 0.3 3 TRUE 3 TRUE
3 10 FALSE FALSE normal 10 FALSE FALSE 0.5 1 1 0.6 0.5 2 FALSE 2 FALSE
4 5 15 0.7 0.5 2 0.8 0.7 1 1

View File

@ -1,2 +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 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 10,TRUE,TRUE,uniform,10,TRUE,TRUE,0.5,1,1,0,2,TRUE,2,TRUE

1 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
2 10 TRUE TRUE uniform 10 TRUE TRUE 0.7 0.5 1 1 0.9 0 2 TRUE 2 TRUE