From 11b7b738f9b030b39de5f8c7973625438534cebf Mon Sep 17 00:00:00 2001 From: Cricial <2911646453@qq.com> Date: Fri, 27 Dec 2024 16:32:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=AF=94=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/csv-editor.xml | 7 + __pycache__/computation.cpython-38.pyc | Bin 8534 -> 8548 bytes __pycache__/firm.cpython-38.pyc | Bin 11499 -> 11499 bytes __pycache__/my_model.cpython-38.pyc | Bin 16494 -> 16874 bytes __pycache__/product.cpython-38.pyc | Bin 1392 -> 1423 bytes computation.py | 4 +- firm.py | 2 +- input_data/产品消耗制造比例.csv | 238 +++++++++++++++++++++++++ main.py | 2 +- my_model.py | 65 ++++--- product.py | 3 +- 11 files changed, 290 insertions(+), 31 deletions(-) create mode 100644 input_data/产品消耗制造比例.csv diff --git a/.idea/csv-editor.xml b/.idea/csv-editor.xml index 9b71347..dba7d86 100644 --- a/.idea/csv-editor.xml +++ b/.idea/csv-editor.xml @@ -136,6 +136,13 @@ + + + + + + diff --git a/__pycache__/computation.cpython-38.pyc b/__pycache__/computation.cpython-38.pyc index 409e8faf19d7b74b7f66b41001c60895f0978849..cd356de2fb539abf9eb16998982c51bd98e4456a 100644 GIT binary patch delta 434 zcmZ9Ize@u#6vy)}{Y871Yp`<_F5)1%l|l&!6)LRmp)6zj$yZcws_i?RD?N^#y)yz_NDHHC0Ylx-st0gb0ShlkFZa>T60F~0yt^0dPqcCOol}S zb!he^`@5mrkT)X3lKI-OORw?RSZV0as5geuW`3jf2NCm1HaRF=S{WaF!!s9rWalVM Ts91grR)g*Q$sm=t$qV=a?>Ke8 delta 425 zcmZ9I!Ak-`6vpT6tQzXhuDaEZi58LaNf(K(UJ|;95)*=gplt>*Qj~{<2!y$I z*gbU%VxgmdL#Mh5dG63((9`JBz%cW^Vcz?F-?aQ*HmZgZC%8T@s?Fkykz#fq2yuxI z9&Kp>9Fh^#PSq}}fTeC(3AWUjZ9_wSv7F_buHlh85V1fT!FgQe%r$PcQj$tt#62Ps z5Beb5Nnhc89rwA0n*`zeNXKh?H_Ct+2_6^UKaGKqukW;CAB|OVt%@Ucc G4&etUGjt08 diff --git a/__pycache__/firm.cpython-38.pyc b/__pycache__/firm.cpython-38.pyc index d5d075f5b34b67739097f4209f1ca27b68d1ee35..b6388e52c8c5d6dd51f6e795482b163c1118c3f3 100644 GIT binary patch delta 132 zcmaDI`8tv}l$V!_0SLr3v(oc6^3G;syft|xTR3CXW=8gtjNDp4sUm$4p|klaM+Ot4 z@n$>jwako$o8R#L5MVO`$!KkUCBKN3QGar;>Lo^<$q8y(*udJfCrhcfvFU)6=mMGA UlP{`Avw_Vr0C6|RYV@%H09@-MYXATM delta 132 zcmaDI`8tv}l$V!_0SF!)3QdpO$UB>jF>3Nkws6K#-}ptI@{-0P5c)n*aa+ diff --git a/__pycache__/my_model.cpython-38.pyc b/__pycache__/my_model.cpython-38.pyc index 2ce3b7ae942d2d4d292ffb2833ca84caac61511b..d4057b24ccbd11b728eb3b9d9bb6def108712684 100644 GIT binary patch delta 2360 zcmZ8h4{RG}6~A|PK3{CdasDUJCbnZIajQ1z3Q5%FpVU$qXw}9T5>~6j%IA7^5-0h5 zu84G&Go@pxAQ15(#zG}r1Vb8y{y9-qrK}PN38~O^14?I!F}5aM3t~f~pn~}G-q~%l zob~rtL6p;MexcEuR4>*^O;|3jD_2_u-!^pbF?b4L)(UGXc$_F_?jNl(&j+1rNX$@m6pi zy6i)tEWrEXO87+4hgsI*QgG$AfFxN`M#=yKCNIN&>F{R{$ptu0R+$!4+9eAn<#vgw z?NULu$btS8&5lxo`mb4@>4S6n0VeVyDLA9ikW~nCuq&YwOa#NIIHOzM^ zVV;wY0Ml8`F&zo|erXX3E|h9$G0*+b1r2r2CYu{|Z^mcVTCfP13VHBv(8)*L2Hj%@ zFv(q%rMI2XhwfdLX1OihsDw#F;Ryw_njDF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/computation.py @@ -148,7 +148,7 @@ class Computation: # 归一化生成 lst_prob lst_prob = [size / sum_pred_firm_size for size in lst_pred_firm_size] # 使用 np.isclose() 确保概率总和接近 1 - if not np.isclose(sum(lst_prob), 1.0): + if not pd.np.isclose(sum(lst_prob), 1.0): # print(f"警告: 概率总和为 {sum(lst_prob)},现在进行修正") lst_prob = [prob / sum(lst_prob) for prob in lst_prob] # 确保没有负值或 0 @@ -234,7 +234,7 @@ class Computation: # 归一化生成 lst_prob lst_prob = [size / sum_pred_firm_size for size in lst_succ_firm_size] # 使用 np.isclose() 确保概率总和接近 1 - if not np.isclose(sum(lst_prob), 1.0): + if not pd.np.isclose(sum(lst_prob), 1.0): # print(f"警告: 概率总和为 {sum(lst_prob)},现在进行修正") lst_prob = [prob / sum(lst_prob) for prob in lst_prob] diff --git a/firm.py b/firm.py index 81f48cf..e66be0f 100644 --- a/firm.py +++ b/firm.py @@ -45,7 +45,7 @@ class FirmAgent(Agent): self.c_consumption = demand_quantity # 设备c购买价格(初始值) # self.c_price = c_price - # 资源r补货库存阈值 + # 资源r补货库存阈值 很重要设置 self.s_r = 40 self.S_r = 120 # 设备补货阙值 可选 diff --git a/input_data/产品消耗制造比例.csv b/input_data/产品消耗制造比例.csv new file mode 100644 index 0000000..0c42e76 --- /dev/null +++ b/input_data/产品消耗制造比例.csv @@ -0,0 +1,238 @@ +IndustryID,MaterialID,Quantity +38,47,1.0 +39,49,1.0 +40,44,1.0 +41,15,0.02 +41,18,0.1 +41,20,0.4 +41,22,0.15 +41,23,0.04 +41,25,0.02 +41,31,0.25 +41,36,1.0 +42,15,0.02 +42,18,0.1 +42,20,0.4 +42,22,0.15 +42,23,0.04 +42,25,0.02 +42,31,0.25 +43,46,1.0 +44,7,1.4 +44,15,0.02 +44,18,0.1 +44,20,0.4 +44,22,0.15 +44,23,0.04 +44,25,0.02 +44,27,0.25 +45,7,1.4 +45,15,0.02 +45,18,0.1 +45,20,0.4 +45,22,0.15 +45,23,0.04 +45,25,0.02 +45,27,0.25 +46,15,0.02 +46,18,0.1 +46,20,0.4 +46,22,0.15 +46,23,0.04 +46,25,0.02 +46,27,0.25 +46,32,1.3 +47,15,0.02 +47,18,0.1 +47,20,0.4 +47,22,0.15 +47,23,0.04 +47,25,0.02 +47,27,0.25 +47,33,1.0 +48,15,0.02 +48,18,0.1 +48,20,0.4 +48,22,0.15 +48,23,0.04 +48,25,0.02 +48,27,0.25 +48,34,1.3 +49,15,0.02 +49,18,0.1 +49,20,0.4 +49,22,0.15 +49,23,0.04 +49,25,0.02 +49,27,0.25 +49,35,1.3 +50,19,0.005 +50,20,0.4 +50,22,0.15 +50,23,0.04 +50,25,0.02 +50,28,0.25 +50,29,0.03 +50,27,0.01 +50,40,1.0 +51,19,0.005 +51,20,0.4 +51,22,0.15 +51,23,0.04 +51,25,0.02 +51,28,0.25 +51,29,0.03 +51,27,0.01 +51,38,1.0 +52,19,0.005 +52,20,0.4 +52,22,0.15 +52,23,0.04 +52,25,0.02 +52,28,0.25 +52,29,0.03 +52,27,0.01 +52,41,1.0 +53,19,0.005 +53,20,0.4 +53,22,0.15 +53,23,0.04 +53,25,0.02 +53,28,0.25 +53,29,0.03 +53,27,0.01 +53,39,1.0 +54,19,0.005 +54,20,0.4 +54,22,0.15 +54,23,0.04 +54,25,0.02 +54,28,0.25 +54,29,0.03 +54,27,0.01 +54,43,1.0 +55,19,0.005 +55,20,0.4 +55,22,0.15 +55,23,0.04 +55,25,0.02 +55,28,0.25 +55,29,0.03 +55,27,0.01 +55,42,1.0 +90,7,1.7 +90,8,0.07 +90,9,0.07 +90,10,0.02 +90,11,0.04 +90,17,0.1 +90,19,0.005 +90,20,0.4 +90,21,0.04 +90,23,0.04 +90,24,0.07 +90,25,0.02 +90,28,0.03 +90,31,0.25 +90,44,0.2 +90,45,0.1 +91,8,0.07 +91,9,0.07 +91,10,0.02 +91,11,0.04 +91,17,0.1 +91,18,0.1 +91,19,0.005 +91,20,0.4 +91,23,0.04 +91,24,0.07 +91,28,0.03 +91,31,0.25 +92,8,0.07 +92,9,0.07 +92,10,0.02 +92,11,0.04 +92,17,0.1 +92,18,0.1 +92,19,0.005 +92,20,0.4 +92,23,0.04 +92,24,0.07 +92,28,0.03 +92,31,0.26 +93,8,0.07 +93,9,0.07 +93,10,0.02 +93,11,0.04 +93,17,0.1 +93,18,0.1 +93,19,0.005 +93,20,0.4 +93,23,0.04 +93,24,0.07 +93,28,0.03 +93,31,0.27 +94,8,0.07 +94,9,0.07 +94,10,0.02 +94,11,0.04 +94,17,0.1 +94,18,0.1 +94,19,0.005 +94,20,0.4 +94,23,0.04 +94,24,0.07 +94,28,0.03 +94,31,0.28 +95,8,0.1 +95,9,0.0 +95,10,7.0 +95,11,0.02 +95,12,0.03 +95,13,0.01 +95,14,0.01 +95,15,0.07 +95,16,0.05 +95,17,0.003 +95,18,0.1 +95,19,0.04 +95,20,0.01 +95,21,0.04 +95,22,0.03 +95,23,0.02 +95,24,0.01 +95,25,0.05 +95,26,0.01 +95,27,0.003 +95,28,0.1 +95,29,0.05 +95,30,0.04 +95,31,0.01 +95,37,0.1 +95,44,0.04 +95,45,0.7 +95,46,0.07 +95,47,0.01 +95,48,0.03 +95,49,0.01 +95,50,0.01 +95,51,0.01 +95,52,0.2 +95,53,0.03 +95,54,0.01 +95,55,0.01 +95,90,0.01 +95,91,0.01 +95,92,1.0 +95,93,1.0 +95,94,1.0 +96,95,1.0 +96,101,0.01 +96,102,0.01 +96,103,0.02 +96,104,0.01 +96,105,0.2 +96,106,0.1 +96,107,0.01 +96,108,0.03 +96,109,0.02 diff --git a/main.py b/main.py index 93d7407..4880349 100644 --- a/main.py +++ b/main.py @@ -44,7 +44,7 @@ if __name__ == '__main__': # 输入参数 parser = argparse.ArgumentParser(description='setting') parser.add_argument('--exp', type=str, default='without_exp') - parser.add_argument('--job', type=int, default='1') + parser.add_argument('--job', type=int, default='3') parser.add_argument('--reset_sample', type=int, default='0') parser.add_argument('--reset_db', type=bool, default=False) diff --git a/my_model.py b/my_model.py index c78cfc1..255b10f 100644 --- a/my_model.py +++ b/my_model.py @@ -316,21 +316,23 @@ class MyModel(Model): for ag_node, attr in self.product_network.nodes(data=True): # 产业种类 + production_ratio = self.data_production_ratio[self.data_production_ratio['IndustryID'] == ag_node]['Production_ratio'] + # 转换为字典 + if not production_ratio.empty: # 检查 Series 是否为空 + production_ratio_dict = production_ratio.iloc[0] # 提取第一个值 + else: + # 如果 Series 是空的,返回一个空字典 + production_ratio_dict = {} - # type2 = self.type2[self.type2["Index"] == ag_node]["产业种类"] - # depreciation ratio 折旧比值 - # product_id = product_id.iloc[0] - product = ProductAgent(ag_node, self, name=attr['Name'], type2=0) + product = ProductAgent(ag_node, self, name=attr['Name'], type2=0, production_ratio=production_ratio_dict) self.add_agent(product) - # self.grid.place_agent(product, ag_node) - ##print(f"Product agent created: {product.name}, ID: {product.unique_id}") for ag_node, attr in self.firm_network.nodes(data=True): a_lst_product = [agent for agent in self.product_agents if agent.unique_id in attr['Product_Code']] - demand_quantity = self.data_consumed[self.data_consumed['Firm_Code'] == ag_node] + demand_quantity = self.data_materials[self.data_materials['Firm_Code'] == ag_node] - production_output = self.data_produced[self.data_consumed['Firm_Code'] == ag_node] + production_output = self.data_produced[self.data_materials['Firm_Code'] == ag_node] # c购买价格? 数据预处理 # c_price = self.Firm.loc[self.Firm['Code'] == ag_node, 'c_price'].values[0] @@ -418,24 +420,26 @@ class MyModel(Model): def j_comp_consumed_produced(self): # 着重修改这 然后考虑逻辑 如何传递值 - data_consumed = pd.read_csv('input_data/input_firm_data/firms_materials.csv') + data_materials = pd.read_csv('input_data/input_firm_data/firms_materials.csv') data_produced = pd.read_csv('input_data/input_firm_data/firms_products.csv') - data_not_consumed = data_consumed.groupby('Firm_Code')[['材料id', '材料数量']] \ + data_production_ratio = pd.read_csv('input_data/产品消耗制造比例.csv') + + data_not_consumed = data_materials.groupby('Firm_Code')[['材料id', '材料数量']] \ .apply(lambda x: dict(zip(x['材料id'], x['材料数量']))) \ .reset_index(name='Material_not_Consumed') - # 这里简单设置为折半 考虑 企业的设备量 - # 可以引入 换算率 也就是 材料——计算产品比例 通过上游产业 现在假设为 2:1 的比例 - data_consumed0 = data_consumed.groupby('Firm_Code')[['材料id', '材料数量']] \ - .apply(lambda x: dict(zip(x['材料id'], x['材料数量'] / 2))) \ - .reset_index(name='Material_not_Consumed') - data_produced = data_consumed.groupby('Firm_Code')[['材料id', '材料数量']] \ - .apply(lambda x: dict(zip(x['材料id'], x['材料数量'] / 4))) \ + data_not_produced = data_produced.groupby('Firm_Code')[['产品id', '产品数量']] \ + .apply(lambda x: dict(zip(x['产品id'], x['产品数量']))) \ .reset_index(name='Material_not_Consumed') - self.data_consumed = data_consumed0 - self.data_produced = data_produced + data_production_ratio = data_production_ratio.groupby('IndustryID')[['MaterialID', 'Quantity']] \ + .apply(lambda x: dict(zip(x['MaterialID'], x['Quantity']))) \ + .reset_index(name='Production_ratio') + + self.data_materials = data_not_consumed + self.data_produced = data_not_produced + self.data_production_ratio = data_production_ratio def step(self): # 1. Remove edge to customer and disrupt customer up product @@ -538,16 +542,25 @@ class MyModel(Model): C_list[2] = C0_list[2] # 消耗资源过程 # 这里需要修改 + k = 0.6 + # 特定的产业 + firm_consumed_nums_dct = {} + for indus_i in firm.indus_i: + print("这是 公司产业 编码:" + indus_i) + print(type(indus_i)) + for p_id, p_nums in firm.P.items(): + print("这是 产品 编码:" + p_id) + print(type(p_id)) + if p_id == indus_i.unique_id: + consumed_nums = p_nums * k + firm_consumed_nums_dct[indus_i] = consumed_nums for r_id, r_nums in firm.R.items(): - for consumed_id, consumed_nums in firm.c_consumption: - if consumed_id == r_id: - r_nums = r_nums - consumed_nums - + for i, value in firm_consumed_nums_dct.items(): + if r_id in i: + r_nums = r_nums - i[r_id] * value # 生产产品过程 for p_id, p_nums in firm.P.items(): - for product_id, product_nums in firm.c_consumption: - if product_id == p_id: - p_nums = p_nums + product_nums + p_nums = p_nums * 1.6 firm.refresh_R() # 刷新 C状态 diff --git a/product.py b/product.py index 24ef514..62c8659 100644 --- a/product.py +++ b/product.py @@ -2,13 +2,14 @@ from mesa import Agent class ProductAgent(Agent): - def __init__(self, unique_id, model, name, type2): + def __init__(self, unique_id, model, name, type2, production_ratio): # 调用超类的 __init__ 方法 super().__init__(unique_id, model) # 初始化代理属性 self.name = name self.product_network = self.model.product_network + self.production_ratio = production_ratio if type2 == 0: self.is_equip = True else: