From 36abde10224bd758b03f63ba4d98497bf91c6723 Mon Sep 17 00:00:00 2001 From: HaoYizhi Date: Wed, 14 Jun 2023 18:00:08 +0800 Subject: [PATCH] condense external variables --- .vscode/launch.json | 4 +- __pycache__/controller_db.cpython-38.pyc | Bin 8021 -> 7907 bytes __pycache__/firm.cpython-38.pyc | Bin 6849 -> 6685 bytes __pycache__/model.cpython-38.pyc | Bin 13397 -> 13254 bytes __pycache__/orm.cpython-38.pyc | Bin 3924 -> 3736 bytes controller_db.py | 59 +++++++++---------- firm.py | 20 +++---- model.py | 14 ++--- oa_with_exp.csv | 72 +++++++++++------------ oa_without_exp.csv | 4 +- orm.py | 11 +--- xv_with_exp.csv | 8 +-- xv_without_exp.csv | 4 +- 13 files changed, 93 insertions(+), 103 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 87ed9da..e582557 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,9 +12,9 @@ "console": "integratedTerminal", "justMyCode": true, "args": [ - "--exp", "with_exp", + "--exp", "test", "--reset_db", "True", - "--job", "24" + "--job", "1" ] } ] diff --git a/__pycache__/controller_db.cpython-38.pyc b/__pycache__/controller_db.cpython-38.pyc index 5bba38ad5b8e02a53b0ab03433db67dc366e6714..6b6b5836fbc4cff09213f84b81b752c30137be6b 100644 GIT binary patch delta 2555 zcmZuzU5p!76`ngYo*9qF_Sn1juJ^|wX%y8-vt*MrKnYQnlr)M^1Z`TWt0cq3cXoHY z$O)9-0wag1Q#@oHHvE+DzzQ_Eo7shkf-EPoQQZ@FXSiGd4xx{SX z%qjq9FD@EkFLqFs=DS|(I+5qmRv}e;eJ@N^^iA_i>p|cIJ(s4Xg(&h^?DxX2FxF$t zf*@(ZkDLuZUcp0!ru4|HxTajL&w)-NCK;DaBJZe*Dc5&YS^QCXd+#)8*z7}S!V02< zJ}_~w23~Ynyse%l=fv;S!<)-e0%<~N22@X!SnA}s5^L1BEhp-zG}}5gY2l_cB)C5* zakXQ>%4$foxC#Yak{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id3pgV~;PmkBRVDp|g)jFJrh zP`OCP`S(gDpc3(4`&;>(3}i$*Syq4-nKR3dTeK_HGn4#I;F5Ysco%*n0=Eep;(bAf zB>9bCE|?ZBc7%T!q){0@0Xxf&gbtHT?X^(1auROM&!X7q6R_=Pn)va$&>M|-p(?YD z^`gs~$Fs-9{v!W0GEc^MCeqK}?>)>@QT3^#$RUdeusGJo0bPI@KnO4{KoptAx;^Ea zyd1qU{QNG7E$*f0{6}$CygM-=LjlctA!B=`9JE%2P*Jw= zU4A=uo*d=B#uiTRhcf_}0z3hj2AlxM=AFjs6d(nV<;-F=$4lz4HYS!@SoYTIX&#H& zqC&uDL6lif@GsQd6e`ua*b>|?0~P>jfSj_pL+Mq$V2UQKSF7fGPuF7c9e)TaUt;I( zQ9e4#oswE?xxrzq)-F-Im|Ln%!ovAfjEBuY{{Z&4a9l9ywO`C*qq zx<^HruM6-l9nhmcBwuHlw=B$_4Xx{?p(GJ)LB352eT-{No`yIgPSA_l3_(tkTA{v#7ga zv#Yvg8}u)pPAV@Yj;wd%h8G?B9TEr{=0(6p@ApigX diff --git a/__pycache__/model.cpython-38.pyc b/__pycache__/model.cpython-38.pyc index 055949670e25f16265603adca2966ec411993fa3..1bd50d868e2a977dfc8f94478c8efaf57197ed9b 100644 GIT binary patch delta 3323 zcmZ`*X>1$E72a8rONtUHN}@zkBqi$>b=VXw`IHZ(itV_*Wcf&G$*k-lDXkPqT#n)< znKcd5ww6ug5}u|_o48#9E}El2Z42m;qCc7+ZGj#r&?YE|wrKyfE_$NB@}sHyW=Ttq z?GV_v@4b2Rj&I()<@?h=PC8FI9CiVIKfIR1Hx}+VcO&u7c6J1fWn5H{1-T}Rs1U0q zb%x|NqFrdYs31a| z4$`T2VG;CVI~B3XC+OYSTtJ*37N{tPumwxlx*{Sj^{}&IFw=ttEL;_FC8r4y_VgBn zQDL%mLR2lPM9q31m8gWPW?@b4*Ebe~0zyI_r8=pZn&b!j9SIR)nB+~^^dJT#94-hs zK@;?WQ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1B@_{+V+N|GlSQ zyf1K%zn%ZA%FTx>$HWJ?ZQyTJ9wR>mgg40=*Q&DQcl=*fkICQpr`10q63^Exk~%Ke z-XV>g*DjNG?yvg>8R8ZGZTz>sCjQsDR>MGCt&;BYXG*Z<_1}ou7ZwSIftJ z)evpi*FcVP=6jPI2g_Y@f`8xdBXRz||HDkEA|BDMg;R<7rEo%xhU1~?*|-*dPN}-# zZ_iNGv)a_`jYz0=HuapdsV<^kUQB5(pl(uD#hdW(4b8KNsOER-zrzm%J^&V<2O3Fe z&EGHr7qB+jxE+6%x4bWsTl}S#hPAUT77Mw~&uwiu@f8SGje%GvntA~@48;u;=TXE_ zoCUEirL=`akf>SI_%?(eZSrD*&S;U@wMSbAE##N{pB=BrCfX7|+S%>Tp!XDt>*#Gu zU0IAq=Ob#I-|jpH@qXO7mE7R}?(DC{P}Db2P!t-9ukroCwuWh3oPM$vMxtw=e3Bc-a~yJ#Wzvp_@kbF4`w4IV>ZH?dAiiwVqHNc@9G^Ue_EUA{SP6p z^69=Eq>_KDFY7o7MxO`(r+91st(`X!D~00OG^+1_E&zTh85S~e{#O=);$NKT`G9}Y ze}w#yw+*z{gyh6hVtzpj+11M@XVjUiDRqWl7-$|&qNfTXR2_>zWiHT2ct+FI*-MLB zB&B{GEsljnEleXZH4-T%dXB$0u#GJ7KMw5n;N6BSiFs|^l2}No1>Q1P>${JrW@4RG zow;V#@Pay5#wP~#+FNMMp}33U+bDj_KOO8jc+u{*$L!rIatT(2Y%{S)TuUsO7Yht# n;&djZM!*=d#uu-GVG`GNY#czp4wPOW>X6?;z)O62=-~eVCS&0N diff --git a/__pycache__/orm.cpython-38.pyc b/__pycache__/orm.cpython-38.pyc index ed5e1b56d99370713f88a502a0522c115dc7a23b..eb1ad504a3ae39cb0a9d2d726929ead53d32b00d 100644 GIT binary patch delta 295 zcmca2H$#>$l$V!_0SGQMb*AtMZshZ4W>lCQ$Gk&QEQKS5vzaM{C55$@DM})hH5Do{ zS(!y&o((E4lPa6SmBO9Elfv7}93_{+m%`t|5GB8PCyO;Bqx_UuSxY?A$hmp~Faua7O zWBg2`VlF6h{@21&XjiW#vG+plo?0aRnrC#Z;vft`zPRo)q3*<|yS9z7+lzhA5TI zwJg?*j6RchvMMsFPQJ~$M^-Q`vnV&dD77%YpeQZAII}AC7D8z9A~s7^2sbe~8C?ZT zC^{48QKt=`-7t2g`= 12, 'dct_lst_init_remove_firm_prod'].to_list() + else: + 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) # list_dct = [{'140': ['1.4.5.1']}] # list_dct = [{'133': ['1.4.4.1']}] # list_dct = [{'2': ['1.1.3']}] # list_dct = [{'135': ['1.3.2.1']}] # list_dct = [{'79': ['2.1.3.4']}] # list_dct = [{'99': ['1.3.3']}] - # list_dct = [{'41': ['1.4.5']}] + list_dct = [{'41': ['1.4.5']}] # fill g_bom BomNodes = pd.read_csv('BomNodes.csv', index_col=0) @@ -98,9 +101,13 @@ class ControllerDB: g_product_js = json.dumps(nx.adjacency_data(g_bom)) # insert exp - df_xv = pd.read_csv("xv_with_exp.csv", index_col=None) + df_xv = pd.read_csv( + f"xv_{'with_exp' if self.is_with_exp else 'without_exp'}.csv", + index_col=None) # read the OA table - df_oa = pd.read_csv("oa_with_exp.csv", index_col=None) + df_oa = pd.read_csv( + f"oa_{'with_exp' if self.is_with_exp else 'without_exp'}.csv", + index_col=None) df_oa = df_oa.iloc[:, 0:df_xv.shape[1]] for idx_scenario, row in df_oa.iterrows(): dct_exp_para = {} @@ -119,13 +126,10 @@ 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_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, + n_max_trial, prf_size, prf_conn, cap_limit_prob_type, cap_limit_level, - diff_new_conn, diff_remove, proactive_ratio): + diff_new_conn, crit_supplier, diff_remove, + proactive_ratio, netw_prf_n): e = Experiment( idx_scenario=idx_scenario, idx_init_removal=idx_init_removal, @@ -134,20 +138,15 @@ class ControllerDB: dct_lst_init_remove_firm_prod=dct_lst_init_remove_firm_prod, g_bom=g_bom, n_max_trial=n_max_trial, - crit_supplier=crit_supplier, - firm_req_prf_size=firm_req_prf_size, - firm_req_prf_conn=firm_req_prf_conn, - firm_acc_prf_size=firm_acc_prf_size, - firm_acc_prf_conn=firm_acc_prf_conn, - netw_sply_prf_n=netw_sply_prf_n, - netw_sply_prf_size=netw_sply_prf_size, - netw_cust_prf_n=netw_cust_prf_n, - netw_cust_prf_size=netw_cust_prf_size, + prf_size=prf_size, + prf_conn=prf_conn, cap_limit_prob_type=cap_limit_prob_type, cap_limit_level=cap_limit_level, diff_new_conn=diff_new_conn, + crit_supplier=crit_supplier, diff_remove=diff_remove, - proactive_ratio=proactive_ratio + proactive_ratio=proactive_ratio, + netw_prf_n=netw_prf_n ) db_session.add(e) db_session.commit() diff --git a/firm.py b/firm.py index 211caac..0621625 100644 --- a/firm.py +++ b/firm.py @@ -23,12 +23,10 @@ class FirmAgent(ap.Agent): self.dct_request_prod_from_firm = {} # para - self.flt_crit_supplier = float(self.p.crit_supplier) - 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.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.is_prf_size = self.model.is_prf_size + self.is_prf_conn = bool(self.p.prf_conn) self.flt_diff_new_conn = float(self.p.diff_new_conn) + self.flt_crit_supplier = float(self.p.crit_supplier) def remove_edge_to_cus_remove_cus_up_prod(self, remove_product): lst_out_edge = list( @@ -80,7 +78,7 @@ class FirmAgent(ap.Agent): continue # select based on connection lst_firm_connect = [] - if self.is_firm_req_prf_conn: + if self.is_prf_conn: for firm in \ self.dct_cand_alt_supply_up_prod_removed[product]: out_edges = self.model.firm_network.graph.out_edges( @@ -98,7 +96,7 @@ class FirmAgent(ap.Agent): lst_firm_connect.append(firm) if len(lst_firm_connect) == 0: # select based on size or not - if self.is_firm_req_prf_size: + if self.is_prf_size: lst_size = \ [size for size in self.dct_cand_alt_supply_up_prod_removed[ @@ -113,7 +111,7 @@ class FirmAgent(ap.Agent): self.dct_cand_alt_supply_up_prod_removed[product]) elif len(lst_firm_connect) > 0: # select based on size of connected firm or not - if self.is_firm_req_prf_size: + if self.is_prf_size: lst_firm_size = \ [firm.revenue_log for firm in lst_firm_connect] lst_prob = \ @@ -161,7 +159,7 @@ class FirmAgent(ap.Agent): elif len(lst_firm) > 1: # handling based on connection lst_firm_connect = [] - if self.is_firm_acc_prf_conn: + if self.is_prf_conn: for firm in lst_firm: out_edges = \ self.model.firm_network.graph.out_edges( @@ -182,7 +180,7 @@ class FirmAgent(ap.Agent): lst_firm_connect.append(firm) if len(lst_firm_connect) == 0: # handling based on size or not - if self.is_firm_acc_prf_size: + if self.is_prf_size: lst_firm_size = \ [firm.revenue_log for firm in lst_firm] lst_prob = \ @@ -197,7 +195,7 @@ class FirmAgent(ap.Agent): self.accept_request(select_customer, product) elif len(lst_firm_connect) > 0: # handling based on size of connected firm or not - if self.is_firm_acc_prf_size: + if self.is_prf_size: lst_firm_size = \ [firm.revenue_log for firm in lst_firm_connect] lst_prob = \ diff --git a/model.py b/model.py index 5efa281..e1fd664 100644 --- a/model.py +++ b/model.py @@ -19,14 +19,12 @@ 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.int_netw_sply_prf_n = int(self.p.netw_sply_prf_n) - 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.is_netw_cust_prf_size = bool(self.p.netw_cust_prf_size) + self.is_prf_size = bool(self.p.prf_size) 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_diff_remove = float(self.p.diff_remove) self.proactive_ratio = float(self.p.proactive_ratio) + self.int_netw_prf_n = int(self.p.netw_prf_n) # init graph bom G_bom = nx.adjacency_graph(json.loads(self.p.g_bom)) @@ -81,11 +79,11 @@ class Model(ap.Model): lst_pred_firm = \ Firm['Code'][Firm[pred_product_code] == 1].to_list() # select multiple supplier (multi-sourcing) - n_pred_firm = self.int_netw_sply_prf_n + n_pred_firm = self.int_netw_prf_n if n_pred_firm > len(lst_pred_firm): n_pred_firm = len(lst_pred_firm) # based on size or not - if self.is_netw_sply_prf_size: + if self.is_prf_size: lst_pred_firm_size = \ [G_Firm.nodes[pred_firm]['Revenue_Log'] for pred_firm in lst_pred_firm] @@ -147,11 +145,11 @@ class Model(ap.Model): lst_succ_firm = Firm['Code'][ Firm[succ_product_code] == 1].to_list() # select multiple customer (multi-selling) - n_succ_firm = self.int_netw_cust_prf_n + n_succ_firm = self.int_netw_prf_n if n_succ_firm > len(lst_succ_firm): n_succ_firm = len(lst_succ_firm) # based on size or not - if self.is_netw_cust_prf_size: + if self.is_prf_size: lst_succ_firm_size = \ [G_Firm.nodes[succ_firm]['Revenue_Log'] for succ_firm in lst_succ_firm] diff --git a/oa_with_exp.csv b/oa_with_exp.csv index 6034405..69f55af 100644 --- a/oa_with_exp.csv +++ b/oa_with_exp.csv @@ -1,37 +1,37 @@ X1,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,X13,X14,X15,X16,X17,X18,X19,X20,X21,X22,X23 -1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 -2,1,1,1,2,1,1,2,2,2,2,2,1,2,1,1,1,1,1,2,2,2,2 -3,1,1,1,3,1,1,3,3,3,3,3,1,3,1,1,1,1,1,3,3,3,3 -1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,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1,0,1,2,1,2,0,0,1,0,1,1,0,1,1,2,0 +1,1,1,0,0,0,1,1,2,0,2,0,0,1,1,0,1,1,0,2,2,0,1 +2,1,1,0,1,0,1,2,0,1,0,1,0,2,1,0,1,1,0,0,0,1,2 diff --git a/oa_without_exp.csv b/oa_without_exp.csv index 72b9261..66c1886 100644 --- a/oa_without_exp.csv +++ b/oa_without_exp.csv @@ -1,2 +1,2 @@ -X1,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,X13,X14,X15 -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +X1,X2,X3,X4,X5,X6,X7,X8,X9,X10 +0,0,0,0,0,0,0,0,0,0 diff --git a/orm.py b/orm.py index ff53deb..c3a25ac 100644 --- a/orm.py +++ b/orm.py @@ -55,20 +55,15 @@ class Experiment(Base): g_bom = Column(Text(4294000000), nullable=False) n_max_trial = Column(Integer, nullable=False) - firm_req_prf_size = Column(Boolean, nullable=False) - firm_req_prf_conn = Column(Boolean, nullable=False) + prf_size = Column(Boolean, nullable=False) + 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(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) diff_remove = Column(DECIMAL(8, 4), nullable=False) proactive_ratio = Column(DECIMAL(8, 4), nullable=False) - netw_sply_prf_n = Column(Integer, nullable=False) - netw_sply_prf_size = Column(Boolean, nullable=False) - netw_cust_prf_n = Column(Integer, nullable=False) - netw_cust_prf_size = Column(Boolean, nullable=False) + netw_prf_n = Column(Integer, nullable=False) sample = relationship( 'Sample', back_populates='experiment', lazy='dynamic') diff --git a/xv_with_exp.csv b/xv_with_exp.csv index dc41e90..5451536 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.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, +n_max_trial,prf_size,prf_conn,cap_limit_prob_type,cap_limit_level,diff_new_conn,crit_supplier,diff_remove,proactive_ratio,netw_prf_n +15,TRUE,TRUE,uniform,5,0.3,2,0.5,0.3,3 +10,FALSE,FALSE,normal,10,0.5,1,1,0.5,2 +5,,,,15,0.7,0.5,2,0.7,1 diff --git a/xv_without_exp.csv b/xv_without_exp.csv index 065f822..2d1cd7c 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.5,1,1,0,2,TRUE,2,TRUE +n_max_trial,prf_size,prf_conn,cap_limit_prob_type,cap_limit_level,diff_new_conn,crit_supplier,diff_remove,proactive_ratio,netw_prf_n +10,TRUE,TRUE,uniform,10,0.5,1,1,0,2