From 4b34dab443ba942ca9f773ba21706d1b9206df10 Mon Sep 17 00:00:00 2001 From: HaoYizhi Date: Tue, 14 Mar 2023 11:39:11 +0800 Subject: [PATCH] Firm accept request conditionally --- __pycache__/controller_db.cpython-38.pyc | Bin 6056 -> 6203 bytes __pycache__/firm.cpython-38.pyc | Bin 4700 -> 4768 bytes __pycache__/model.cpython-38.pyc | Bin 8548 -> 8548 bytes __pycache__/orm.cpython-38.pyc | Bin 3230 -> 3230 bytes controller_db.py | 18 +++++++++--------- firm.py | 7 ++++--- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/__pycache__/controller_db.cpython-38.pyc b/__pycache__/controller_db.cpython-38.pyc index 82956738859274cebfb41db51c20ec11e8a49186..e33cf51f4975a2a2faa8d4571ca3b92a23f05128 100644 GIT binary patch delta 1066 zcmZ`%O-vI(6yDkHUrT>L{sgfg0g-3~BvFA70TF|LsE8&FxM_D5Sz5a7>=w{$Ln1LT zo{W=tAtvSK#RK7D^dxr^&wKK!-t?`;h+CN`OG-}~nK-g}*yw|yV`V{@@sM1bGt z9|=0Y6Wf>KVaOC%mti@3yjdRD@JL147AA#-+w)>MRF*u6iY-D}hObJ6XBY#wjJcMD ztfBkMfKEeLIffdpB5?L^Wu3|^TbU8mCrzB4OBuU>}j5`9HHSB z0rVjvxOFu&;%Qp~t$7pLgaXBv{DnNEl7VjoX5?SwJ`#PUw4cx{*JR9Ib9~v#Q*+%{ zU0cstj_WJwLcz>ao>We4gjqAVd}+#JD=7`Pb!xai(fts3eaWz?=|>C9rX|DGgDivs z)uQXVxn5u`V6Q?eMr{D6VL6=u0*R0#Bu*q!OEeNCO^`>3LKLwUSn)s-`Ihp!_5vu` zMT8-QZa%Kw>I}$k%!dJdV*cBye|JYs6PcZZZQdBxm7qcwe-bvy2>%*x?Fk4K-J(U= zSq$njrCe5b(yOL!XO>OFb=WBHij2jt22Gr5lZjmx*%Ld)flGxQm+5XglQUTo^1uG- zB)=ECPVVzc>>=sm2eBl%!jtiS@_^68XOG@N@inZf7)!Qgm`p-uj(>?G%S!T|I{#c(m{p74CE<7&^CinFy1IeCEnBc?gmcfOZXnyF=X2j@NuzzgyRS+ z2t@!t>bPmwGFD7?$)?q5T-?MXW~;oTX@8=66@_%3rXALUCOKbPDLnSYe4#o~4T{%r XN2D2+$IK3N3~Jk~5y~|4QuE+%wmtW= delta 865 zcmZ`$O-vI(6yDjtmX>WRKP^NAObDbwORLo=Q9>#Z4B{_hM4&F6p)4-jGP@{{av~l) zzney*i3bx;go6ifo{R|>6BDyX6JqqFF)^7I2XimJxFP}0u9k{nOLMuwq#GO$=hT^nmaZtZz)@9O?s}?l$x}x z(}s4broK>!p<~pS`dW)hdTi$5RS)uQiYat7WTo#Y&RH73YaI2oJo zJ};u1iCetll)E`|nb*B&o8>g|RkvtSJ_I|lEV%|>VmI0*un}(F*Go$ktHij9%oUi7 zk2H^=8Hm#tE!$(97vN=lEH)nGQ)V;4<>62KI+@&^NOZ~_7eyqk@f0Q~VsvmnVO1XR zDR|iQYi0;rqP}z^KbXy@k-d$8TjB?E`5km|91nI_K8@}vR>!PAqz%e4z1-^uy1^cP#fBmM-SpWb4 diff --git a/__pycache__/firm.cpython-38.pyc b/__pycache__/firm.cpython-38.pyc index 033af6fc19576c40a9d074e013ef9adbcbf3b5e6..2264692c096138dbefd4c0e270093fa16cd4901c 100644 GIT binary patch delta 262 zcmcbkvOtwDl$V!_0SG!@^QVMJZ{+*KS3eENtzpPw$YRW5N?}Z4N@q%8PGJF(ti4P{ zlYlbJSu6`!!8BV9gCs~Ta~4|-qa;HLTMbhddnRKVb2{TfMn;efM-3AzP)!QE1p_mK z4M>EuhDnlP0apz~1!ERBkj(^AUBUyD<(+NLkOI_{#Xg%Mg|mhcD8Mk6wHYX#!Vt`$ z$>kT~mTn9NkL}ZE%>;p)_C+>8Cr|F>R~6tZVgWLXTtS2zNN_WMDZ3Pq!N4drSy!N+ Xv1{^Pfi;Z1ld}YuGV)Fq5b^;4@w+{N delta 194 zcmZ3WdPjvXl$V!_0SE+c@us|z+Q|2Zuf7JztzpPw$YNZ;1g4p57$hMg%r%UX3@MB? zOj#_MjA_j2j0+hVK{Bj0OsqgPDNGg&%nUXl5w;p8NrnaNH4qhySsXw%6G(LlCs3Aa zHbV+C$P^&WQo{)1&t+`}%BC;`voL6~`b|E-ugb_h`73`Zs|3h-lM4m<89OI43a(-7 PnY>PLDI?G15FsA`S4k`& diff --git a/__pycache__/model.cpython-38.pyc b/__pycache__/model.cpython-38.pyc index d18096c5a55e8ee4151cc6857aaebb5fa9014abd..bd0730501e855b48950de7cd6fbda4c866c12c56 100644 GIT binary patch delta 18 YcmaFj^u&oXl$V!_0SFQ{az-lx05XmQWdHyG delta 18 YcmaFj^u&oXl$V!_0SGKNaz-lx05Qu1J^%m! diff --git a/__pycache__/orm.cpython-38.pyc b/__pycache__/orm.cpython-38.pyc index 8e2fae3b32eddc944ed2012e4b731efa6e94b8df..778c97301a357e148c728685fe3d62d240dd4c5b 100644 GIT binary patch delta 19 ZcmbOyIZu)+l$V!_0SGeHH*!tk0RSi41Kj`s delta 19 ZcmbOyIZu)+l$V!_0SNX>Z{(W70{|(b1SbFh diff --git a/controller_db.py b/controller_db.py index 6f648b2..9dacf8e 100644 --- a/controller_db.py +++ b/controller_db.py @@ -45,15 +45,15 @@ class ControllerDB: Firm['Code'] = Firm['Code'].astype('string') Firm.fillna(0, inplace=True) 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) - # # break - # # break - list_dct = [{'140': ['1.4.5.1']}] + 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) + break + break + # list_dct = [{'140': ['1.4.5.1']}] for idx_exp, dct in enumerate(list_dct): self.add_experiment_1(idx_exp, self.dct_parameter['n_max_trial'], dct) diff --git a/firm.py b/firm.py index e24eb33..0670e2a 100644 --- a/firm.py +++ b/firm.py @@ -123,11 +123,12 @@ class FirmAgent(ap.Agent): # print(product.code, [firm.name for firm in list_firm]) def accept_request(self, down_firm, product): + # if self.model.nprandom.choice([True, False], p=[0.1, 0.9]): self.firm_network.graph.add_edges_from([ (self.firm_network.positions[self], - self.firm_network.positions[down_firm], { - 'Product': product.code - }) + self.firm_network.positions[down_firm], { + 'Product': product.code + }) ]) self.dct_prod_capacity[product] -= 1 self.dct_request_prod_from_firm[product].remove(down_firm)