From 48077189f0bf6690e3ab47bab65e9aec6f039b0e Mon Sep 17 00:00:00 2001 From: HaoYizhi Date: Sun, 11 Jun 2023 13:33:39 +0800 Subject: [PATCH] generate network based on size or not --- __pycache__/controller_db.cpython-38.pyc | Bin 7714 -> 7714 bytes __pycache__/model.cpython-38.pyc | Bin 13470 -> 13499 bytes __pycache__/orm.cpython-38.pyc | Bin 3948 -> 3936 bytes model.py | 60 ++++++++++++++--------- orm.py | 4 +- xv_with_exp.csv | 6 +-- xv_without_exp.csv | 2 +- 7 files changed, 42 insertions(+), 30 deletions(-) diff --git a/__pycache__/controller_db.cpython-38.pyc b/__pycache__/controller_db.cpython-38.pyc index 0fed664fd4efdcd8134c59ad71c9eec92de6a998..3c0bb02977d3640c5e8649d103135b43ef7fc118 100644 GIT binary patch delta 19 ZcmZ2vv&e=kl$V!_0SI11Zsd}X0{}1|1abfX delta 19 ZcmZ2vv&e=kl$V!_0SKJkH*!hH0RSuK1G@kK diff --git a/__pycache__/model.cpython-38.pyc b/__pycache__/model.cpython-38.pyc index f02fad25173402c6f429050df2d8fe3a83174015..b7f758a8f748b85eb7ffcd85a1fcf364d27f566d 100644 GIT binary patch delta 5305 zcmaJ^TWlN072Vn8OQc9qlqiy--j-}pFY95;vLnm3{7C#rZO5@4%aUnXODd#Z z>1^m$aY&|6pmxxYHhqvSkigAX;GZA~f);3jexyav0{!5JgSPo-fwT#N{x zQ{0@l2${8jQkzyKcJ?*gImEgeR?ZUNCHOU^om=c`HILA%6TAA7%qw;cAWNfZpV<1f zfKY7|yP(!2cFkhfQrfkOU0Z3_E_Ur&M}CLaneP(%I}4;hbfWFbcQc8R0)`UOdh)%h z41Af%suGa$eX0pUf_444#N>FtYE~_(bzLU78{pUE=JbFnsnT6pbs&w(aARcGW#D8II}><^V_S@u8BN z)wnj?gw>Xp)xt|TNzqH@VAaCQj{ImAQgaOapLrwan3r@XhM9E)B-I(fl=^eE%&AQ< zl0THKO&7=-*#}A+a`Js`LOaZyYrxS#K|8X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pdtI4F!D%Eo(G(R4wsp`_ zNsm{0KfARf+QdVB83lNy0EI|$@!tI%5pm*KI4z4Ysce`}ti;s{bXgSTEsMd0oO3Hn zi{bR_wMaNICr9ShbjUcLSYD2)%Jb|S{U;rWZODk&hE;U`@<8u!#XTCDK(1bz3o9X0 zO1Tk^LRvhc8iHkABrg5z-ps%!#B~8xkOS8MpYrF}<-tJnx~yePip{IwKY7T&*kGh* ztfoQAgb1G+7}loME=zo)PSlvN1UumuAz-RoocjE6d3n n$|YEb%s878%HnlJf~~@<0NFzo*!1qUmIyA<_Crn?+uieDOQk0f diff --git a/__pycache__/orm.cpython-38.pyc b/__pycache__/orm.cpython-38.pyc index 5fed76eb2efd82facf21a20908bb5ba854ba0772..d7e552a59c50251d342199b02f5473e0522c97b7 100644 GIT binary patch delta 52 zcmaDO_dt#}l$V!_0SInHwx;-P len(lst_pred_firm): n_pred_firm = len(lst_pred_firm) - lst_choose_firm = self.nprandom.choice(lst_pred_firm, - n_pred_firm, - replace=False, - p=lst_prob) + # based on size or not + if self.is_netw_sply_prf_size: + lst_pred_firm_size = \ + [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, {'Product': pred_product_code}) for pred_firm in lst_choose_firm] @@ -141,21 +146,28 @@ class Model(ap.Model): # get a list of firm producing this finished product lst_succ_firm = Firm['Code'][ 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) n_succ_firm = self.int_netw_cust_prf_n if n_succ_firm > len(lst_succ_firm): n_succ_firm = len(lst_succ_firm) - lst_choose_firm = self.nprandom.choice(lst_succ_firm, - n_succ_firm, - replace=False, - p=lst_prob) + # based on size or not + if self.is_netw_cust_prf_size: + lst_succ_firm_size = \ + [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, {'Product': product_code}) for succ_firm in lst_choose_firm] diff --git a/orm.py b/orm.py index 1e6121e..b446097 100644 --- a/orm.py +++ b/orm.py @@ -61,9 +61,9 @@ class Experiment(Base): firm_acc_prf_size = Column(DECIMAL(8, 4), nullable=False) firm_acc_prf_conn = Column(Boolean, 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_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_level = Column(DECIMAL(8, 4), nullable=False) diff_new_conn = Column(DECIMAL(8, 4), nullable=False) diff --git a/xv_with_exp.csv b/xv_with_exp.csv index 534ea83..9b87f46 100644 --- a/xv_with_exp.csv +++ b/xv_with_exp.csv @@ -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 -15,2,2,TRUE,2,TRUE,3,2,3,2,uniform,5,0.5,0.5,0.4 -10,1,1,FALSE,1,FALSE,2,1,2,1,normal,10,1,1,0.6 -5,0.5,0.5,,0.5,,1,0.5,1,0.5,,15,2,2,0.8 +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,FALSE,2,FALSE,normal,10,1,1,0.6 +5,0.5,0.5,,0.5,,1,,1,,,15,2,2,0.8 diff --git a/xv_without_exp.csv b/xv_without_exp.csv index f0c1f5d..a2d55d0 100644 --- a/xv_without_exp.csv +++ b/xv_without_exp.csv @@ -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 -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