diff --git a/.vscode/launch.json b/.vscode/launch.json index 8e969cf..80f4077 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -14,7 +14,7 @@ "args": [ "--exp", "without_exp", "--reset_db", "True", - "--job", "30" + "--job", "24" ] } ] diff --git a/__pycache__/controller_db.cpython-38.pyc b/__pycache__/controller_db.cpython-38.pyc index 5c25c25..4125943 100644 Binary files a/__pycache__/controller_db.cpython-38.pyc and b/__pycache__/controller_db.cpython-38.pyc differ diff --git a/__pycache__/model.cpython-38.pyc b/__pycache__/model.cpython-38.pyc index aeb2b87..0559496 100644 Binary files a/__pycache__/model.cpython-38.pyc and b/__pycache__/model.cpython-38.pyc differ diff --git a/__pycache__/orm.cpython-38.pyc b/__pycache__/orm.cpython-38.pyc index 4c7a771..ed5e1b5 100644 Binary files a/__pycache__/orm.cpython-38.pyc and b/__pycache__/orm.cpython-38.pyc differ diff --git a/__pycache__/product.cpython-38.pyc b/__pycache__/product.cpython-38.pyc index 5a8864c..72ed28c 100644 Binary files a/__pycache__/product.cpython-38.pyc and b/__pycache__/product.cpython-38.pyc differ diff --git a/conf_db_prefix.yaml b/conf_db_prefix.yaml index 42cedea..0e48fd8 100644 --- a/conf_db_prefix.yaml +++ b/conf_db_prefix.yaml @@ -1 +1 @@ -db_name_prefix: test +db_name_prefix: without_exp diff --git a/controller_db.py b/controller_db.py index 24c7e30..93a7841 100644 --- a/controller_db.py +++ b/controller_db.py @@ -46,31 +46,36 @@ class ControllerDB: Firm.fillna(0, inplace=True) # fill dct_lst_init_remove_firm_prod - # list_dct = [] - # for _, row in Firm.iterrows(): - # code = row['Code'] - # row = row['1':] - # for product_code in row.index[row == 1].to_list(): - # dct = {code: [product_code]} - # list_dct.append(dct) - str_sql = "select e_id, count, max_max_ts, " \ - "dct_lst_init_remove_firm_prod from " \ - "iiabmdb.without_exp_experiment as a " \ - "inner join " \ - "(select e_id, count(id) as count, max(max_ts) as max_max_ts " \ - "from iiabmdb.without_exp_sample as a " \ - "inner join (select s_id, max(ts) as max_ts from " \ - "iiabmdb.without_exp_result where ts > 0 group by s_id) as b " \ - "on a.id = b.s_id " \ - "group by e_id) as b " \ - "on a.id = b.e_id " \ - "order by count desc;" - 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() + assert self.db_name_prefix in ['test', 'without_exp', 'with_exp'], \ + "db name not in test, without_exp, with_exp" + + list_dct = [] + if self.db_name_prefix in ['test', 'without_exp']: + for _, row in Firm.iterrows(): + code = row['Code'] + row = row['1':] + for product_code in row.index[row == 1].to_list(): + dct = {code: [product_code]} + list_dct.append(dct) + elif self.db_name_prefix in ['with_exp']: + str_sql = "select e_id, count, max_max_ts, " \ + "dct_lst_init_remove_firm_prod from " \ + "iiabmdb.without_exp_experiment as a " \ + "inner join " \ + "(select e_id, count(id) as count, max(max_ts) as max_max_ts "\ + "from iiabmdb.without_exp_sample as a " \ + "inner join (select s_id, max(ts) as max_ts from " \ + "iiabmdb.without_exp_result where ts > 0 group by s_id) as b "\ + "on a.id = b.s_id " \ + "group by e_id) as b " \ + "on a.id = b.e_id " \ + "order by count desc;" + 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 = [{'133': ['1.4.4.1']}] # list_dct = [{'2': ['1.1.3']}] diff --git a/xv_with_exp.csv b/xv_with_exp.csv index dc9bfa7..dc41e90 100644 --- a/xv_with_exp.csv +++ b/xv_with_exp.csv @@ -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,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, +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.5,2,FALSE,2,FALSE +5,,,,15,,,0.7,0.5,2,0.7,1,,1, diff --git a/xv_without_exp.csv b/xv_without_exp.csv index d521c6b..065f822 100644 --- a/xv_without_exp.csv +++ b/xv_without_exp.csv @@ -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 -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