Compare commits

..

20 Commits

Author SHA1 Message Date
Cricial
d57216d51f 增加绘图以及图片属性转换(中英)
增加企业规模描述统计表
增加绘制供应链以及产业链度图
2025-05-25 22:15:12 +08:00
Cricial
8f4c5929bb no message 2025-02-23 23:33:19 +08:00
Cricial
c30ec71014 修改企业产品干扰字典逻辑部分—R 2025-02-22 10:33:49 +08:00
Cricial
46df9bace7 修改部分逻辑 2025-02-22 10:33:08 +08:00
Cricial
66e40a1250 更新iiabmdb_basic_info.sql 2025-02-13 16:03:57 +08:00
Cricial
ebc8159bf8 增加resilience 2025-02-12 15:23:55 +08:00
Cricial
0233f642e4 优化图形 2025-02-08 21:25:56 +08:00
Cricial
5b2cf3a3e5 no message 2025-02-03 22:57:45 +08:00
Cricial
0da29d58d6 修改图形代码漏洞 2025-02-03 22:23:18 +08:00
Cricial
42fba119d1 no message 2025-01-27 20:25:25 +08:00
Cricial
30e7e56c11 暂时通过测试 2025-01-27 15:18:51 +08:00
Cricial
0f7f9c1a4b 优化查看进度 2025-01-27 01:15:15 +08:00
Cricial
3a46d09b8e 优化 干扰列表 2025-01-27 01:04:21 +08:00
Cricial
13521ff752 优化代码中的网络结构构建过程,未完成缓存设置 和 多进程共享内容 2025-01-26 23:56:37 +08:00
Cricial
09622cf33d 77.5万数据 2025-01-18 11:32:42 +08:00
Cricial
3ba41c3491 todo 2025-01-18 11:32:04 +08:00
Cricial
3d97db42d0 极大优化模型运行速度 2025-01-18 11:30:44 +08:00
Cricial
2ccdc976e7 no message 2024-12-29 22:50:48 +08:00
Cricial
11b7b738f9 调整比例 2024-12-27 16:32:57 +08:00
Cricial
2d359c80f1 no message 2024-12-11 15:58:06 +08:00
65 changed files with 91020 additions and 52416 deletions

30
.idea/csv-editor.xml generated
View File

@@ -3,7 +3,7 @@
<component name="CsvFileAttributes">
<option name="attributeMap">
<map>
<entry key="C:\Users\www\Desktop\半导体数据——暂时的数据\我做的数据\汇总数据\BomCateNet.csv">
<entry key="C:\Users\www\Desktop\python项目\数据\抽样第3次数据\firm_amended.csv">
<value>
<Attribute>
<option name="separator" value="," />
@@ -136,6 +136,34 @@
</Attribute>
</value>
</entry>
<entry key="\input_data\产品消耗制造比例.csv">
<value>
<Attribute>
<option name="separator" value="," />
</Attribute>
</value>
</entry>
<entry key="\output_result\resilience\anova.csv">
<value>
<Attribute>
<option name="separator" value="," />
</Attribute>
</value>
</entry>
<entry key="\output_result\resilience\anova_visualization.csv">
<value>
<Attribute>
<option name="separator" value="," />
</Attribute>
</value>
</entry>
<entry key="\output_result\resilience\experiment_result.csv">
<value>
<Attribute>
<option name="separator" value="," />
</Attribute>
</value>
</entry>
<entry key="\output_result\risk\count.csv">
<value>
<Attribute>

22
.idea/dataSources.local.xml generated Normal file
View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="dataSourceStorageLocal" created-in="PY-242.23726.102">
<data-source name="iiabmdb@localhost" uuid="8145438e-516b-4005-a581-b91b5eedc759">
<database-info product="MySQL" version="8.0.36" jdbc-version="4.2" driver-name="MySQL Connector/J" driver-version="mysql-connector-j-8.2.0 (Revision: 06a1f724497fd81c6a659131fda822c9e5085b6c)" dbms="MYSQL" exact-version="8.0.36" exact-driver-version="8.2">
<extra-name-characters>#@</extra-name-characters>
<identifier-quote-string>`</identifier-quote-string>
</database-info>
<case-sensitivity plain-identifiers="lower" quoted-identifiers="lower" />
<secret-storage>master_key</secret-storage>
<user-name>iiabm_user</user-name>
<schema-mapping>
<introspection-scope>
<node kind="schema">
<name qname="@" />
<name qname="information_schema" />
</node>
</introspection-scope>
</schema-mapping>
</data-source>
</component>
</project>

12
.idea/dataSources.xml generated Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="iiabmdb@localhost" uuid="8145438e-516b-4005-a581-b91b5eedc759">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://localhost:3306/iiabmdb</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
#n:iiabmdb
!<md> [0, 0, null, null, -2147483648, -2147483648]

View File

@@ -0,0 +1,2 @@
#n:information_schema
!<md> [0, 0, null, null, -2147483648, -2147483648]

6
.idea/developer-tools.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DeveloperToolsToolWindowSettingsV1" lastSelectedContentNodeId="base64-encoder-decoder">
<developerToolsConfigurations />
</component>
</project>

4
.idea/encodings.xml generated
View File

@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/input_data/input_firm_data/Firm_amended.csv" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/input_data/input_firm_data/firm_amended.csv" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/output_result/resilience/anova_visualization.csv" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/查看进度.py" charset="GBK" />
</component>
</project>

11
.idea/sqldialects.xml generated Normal file
View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SqlDialectMappings">
<file url="file://$PROJECT_DIR$/SQL_analysis_experiment.sql" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/SQL_analysis_risk.sql" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/SQL_db_user_create.sql" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/SQL_export_high_risk_setting.sql" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/SQL_migrate_db.sql" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/iiabmdb_basic_info.sql" dialect="MySQL" />
</component>
</project>

29
11.py Normal file
View File

@@ -0,0 +1,29 @@
import pickle
import os
from 查看进度 import visualize_progress
def load_cached_data(file_path):
"""
从指定的缓存文件加载数据。
如果文件不存在或加载失败,则返回空字典。
"""
if not os.path.exists(file_path):
print(f"Warning: Cache file '{file_path}' does not exist.")
return {}
try:
with open(file_path, 'rb') as f:
data = pickle.load(f)
print(f"Successfully loaded cache from '{file_path}'.")
return data
except (pickle.UnpicklingError, FileNotFoundError, EOFError) as e:
print(f"Error loading cache from '{file_path}': {e}")
return {}
# 示例用法
# data_dct = load_cached_data("G_Firm_add_edges.pkl")
visualize_progress()

36
README.md Normal file
View File

@@ -0,0 +1,36 @@
## 安装内容
1. 数据库推荐使用mysql 8.0以上版本
2. Python 3.8
3. 通过pip等方法安装*requirements_manual_selected_20230304.txt*文件中的包
## 前期准备工作
1. 复制整个代码到本地
2. 用root及密码登录mysql在本地数据库中创建一个数据库命名为*iiabmdb*
3. 在mysql中运行*SQL_db_user_create.sql*里的sql命令创建数据库用户。如果创建用户报错需打开该文件并运行第三行被注释掉的代码。该文件后面的sql命令也需要运行将数据库用户的权限赋予*iiabmdb*数据库
4. 之后直接运行controller.py文件如果没有报错则说明前期准备工作完成
## 运行程序
1. 将*conf_db_prefix.yaml*文件中的*db_prefix*改为*db_name_prefix: without_exp*
2. 打开命令行,进入代码所在目录,运行
```shell
python main.py --exp without_exp --job 6 --reset_db True
```
3. 等待运行完成1.2万个样本)。结束后,将*db_name_prefix: without_exp*改为*db_name_prefix: with_exp*,并运行
```shell
python main.py --exp with_exp --job 6 --reset_db True
```
4. 漫长的等待3.4万个样本),直到运行完成
## 获得结果,绘制图表
### 风险节点分析
1. 运行*risk_analysis_sum_result.py*文件该程序自动产生风险节点分析统计数据并放置到output_result/risk文件夹中
2. 依次运行*risk_analysis_prod_network.py**risk_analysis_firm_network.py*文件将自动产生相关结果放置到output_result/risk文件夹中
### 韧性影响因素分析
1. 运行*SQL_analysis_experiment.sql*文件将汇总结果手工复制至output_result/resilience文件夹*experiment_result.csv*文件中
2. 使用Minitab进行田口设计分析
3. 新建田口设计统计——DOE——田口——创建田口设计——混合水平设计因子数选项设置为8设计选项设置为L36水平^列为2^33^5因子选项中将列名依次修改为is_prf_sizeis_prf_connex_cap_typen_max_trialex_cap_paraprob_new_connt_max_trialn_sourcing
4. 将output_result/resilience文件夹*experiment_result.csv*文件中结果复制入田口设计表格右侧列
5. 依次对各个韧性指标进行田口设计分析统计——DOE——田口——分析田口设计从mean_count_firm_prodmean_max_ts_firm_prodmean_n_remove_firm_prodmean_end_ts中选择一个韧性指标图形选项勾选均值分析选项中显示响应表勾选均值拟合线性模型勾选均值点击确定
6. 手工汇总方差分析结果至output_result/resilience文件夹*anova.csv*文件中,汇总响应表结果至*anova_visualization.csv*文件中

View File

@@ -74,7 +74,7 @@ left join
from iiabmdb.with_exp_result
where `status` = "R"
group by s_id, id_firm) as s_n_remove_prod
left join iiabmdb_basic_info.firm_n_prod as firm_n_prod
left join iiabmdb.firm_n_prod as firm_n_prod
on s_n_remove_prod.id_firm = firm_n_prod.code
where n_remove_prod = n_prod
group by s_id) as s_n_all_prod_remove_firm

View File

@@ -1,13 +1,16 @@
CREATE DATABASE iiabmdb20230829;
RENAME TABLE iiabmdb.not_test_experiment TO iiabmdb20230829.not_test_experiment,
iiabmdb.not_test_result TO iiabmdb20230829.not_test_result,
iiabmdb.not_test_sample TO iiabmdb20230829.not_test_sample,
iiabmdb.test_experiment TO iiabmdb20230829.test_experiment,
iiabmdb.test_result TO iiabmdb20230829.test_result,
iiabmdb.test_sample TO iiabmdb20230829.test_sample;
RENAME TABLE iiabmdb.with_exp_experiment TO iiabmdb20230829.with_exp_experiment,
iiabmdb.with_exp_result TO iiabmdb20230829.with_exp_result,
iiabmdb.with_exp_sample TO iiabmdb20230829.with_exp_sample,
iiabmdb.without_exp_experiment TO iiabmdb20230829.without_exp_experiment,
iiabmdb.without_exp_result TO iiabmdb20230829.without_exp_result,
iiabmdb.without_exp_sample TO iiabmdb20230829.without_exp_sample;
-- 创建新的数据库
CREATE DATABASE iiabmdb2025211;
-- 重命名表到新数据库
RENAME TABLE
iiabmdb.test_experiment TO iiabmdb2025211.test_experiment,
iiabmdb.test_result TO iiabmdb2025211.test_result,
iiabmdb.test_sample TO iiabmdb2025211.test_sample;
RENAME TABLE
iiabmdb.with_exp_experiment TO iiabmdb2025211.with_exp_experiment,
iiabmdb.with_exp_result TO iiabmdb2025211.with_exp_result,
iiabmdb.with_exp_sample TO iiabmdb2025211.with_exp_sample,
iiabmdb.without_exp_experiment TO iiabmdb2025211.without_exp_experiment,
iiabmdb.without_exp_result TO iiabmdb2025211.without_exp_result,
iiabmdb.without_exp_sample TO iiabmdb2025211.without_exp_sample;

4
ToDo.md Normal file
View File

@@ -0,0 +1,4 @@
## 下一步计划
1. 运行with_exp
2. 方差分析
3. 优化资源消耗逻辑

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,6 +1,7 @@
import json
import os
import datetime
import time
import networkx as nx
import pandas as pd
@@ -41,230 +42,7 @@ class Computation:
'seed': sample_random.seed,
**dct_exp}
product_network_test = nx.adjacency_graph(json.loads(dct_sample_para['g_bom']))
model = MyModel(dct_sample_para)
for i in range(1):
model.step()
print(i, datetime.datetime.now())
model.end()
return False
def initialize_firm_network(self):
# Read the firm data
firm = pd.read_csv("input_data/input_firm_data/Firm_amended.csv")
firm['Code'] = firm['Code'].astype(str)
firm.fillna(0, inplace=True)
firm_attr = firm.loc[:, ["Code", "Type_Region", "Revenue_Log"]]
firm_industry_relation = pd.read_csv("input_data/firm_industry_relation.csv")
firm_industry_relation['Firm_Code'] = firm_industry_relation['Firm_Code'].astype('string')
firm_product = []
grouped = firm_industry_relation.groupby('Firm_Code')['Product_Code'].apply(list)
firm_product.append(grouped)
firm_attr['Product_Code'] = firm_attr['Code'].map(grouped)
firm_attr.set_index('Code', inplace=True)
grouped = firm_industry_relation.groupby('Firm_Code')
self.firm_prod_labels_dict = {code: group['Product_Code'].tolist() for code, group in grouped}
# 遍历'Product_Code' 与 index 交换
for index, row in firm_attr.iterrows():
id_index_list = []
for i in row['Product_Code']:
for key_values in self.id_code.items():
if int(key_values[0]) == i:
for id in key_values[1]:
id_index_list.append(id)
firm_attr.at[index, 'Product_Code'] = id_index_list
self.G_Firm.add_nodes_from(firm["Code"])
# Assign attributes to the firm nodes
firm_labels_dict = {code: firm_attr.loc[code].to_dict() for code in self.G_Firm.nodes}
nx.set_node_attributes(self.G_Firm, firm_labels_dict)
self.Firm = firm
def initialize_firm_product_network(self):
firm_industry_relation = pd.read_csv("input_data/firm_industry_relation.csv")
firm_industry_relation['Firm_Code'] = firm_industry_relation['Firm_Code'].astype('string')
firm_industry_relation['Product_Code'] = firm_industry_relation['Product_Code'].apply(lambda x: [x])
# 将 'firm_prod' 表中的每一行作为图中的节点
self.G_FirmProd.add_nodes_from(firm_industry_relation.index)
# 为每个节点分配属性
# 遍历'Product_Code' 与 index 交换
for index, row in firm_industry_relation.iterrows():
id_index_list = []
for i in row['Product_Code']:
for key_values in self.id_code.items():
if int(key_values[0]) == i:
for id in key_values[1]:
id_index_list.append(id)
firm_industry_relation.at[index, 'Product_Code'] = id_index_list
firm_prod_labels_dict = {code: firm_industry_relation.loc[code].to_dict() for code in
firm_industry_relation.index}
nx.set_node_attributes(self.G_FirmProd, firm_prod_labels_dict)
def add_edges_to_firm_network(self):
""" Add edges between firms based on the product BOM relationships """
# Add edges to G_Firm according to G_bom
for node in nx.nodes(self.G_Firm):
lst_pred_product_code = []
for product_code in self.G_Firm.nodes[node]['Product_Code']:
lst_pred_product_code += list(self.G_bom.predecessors(product_code))
lst_pred_product_code = list(set(lst_pred_product_code))
lst_pred_product_code = list(sorted(lst_pred_product_code)) # Ensure consistency
for pred_product_code in lst_pred_product_code:
# Get a list of firms producing the component (pred_product_code)
lst_pred_firm = [firm_code for firm_code, product in self.firm_prod_labels_dict.items() if
pred_product_code in product]
# Select multiple suppliers (multi-sourcing)
n_pred_firm = self.int_netw_prf_n
if n_pred_firm > len(lst_pred_firm):
n_pred_firm = len(lst_pred_firm)
if self.is_prf_size:
# 获取 firm 的 size 列表
lst_pred_firm_size = [self.G_Firm.nodes[pred_firm]['Revenue_Log'] for pred_firm in lst_pred_firm]
# 检查 lst_pred_firm_size 是否为空或总和为 0
if len(lst_pred_firm_size) == 0 or sum(lst_pred_firm_size) == 0:
# print("警告: lst_pred_firm_size 为空或总和为 0无法生成概率分布")
lst_choose_firm = [] # 返回空结果,或根据需要处理
else:
# 计算总和
sum_pred_firm_size = sum(lst_pred_firm_size)
# 归一化生成 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):
# print(f"警告: 概率总和为 {sum(lst_prob)},现在进行修正")
lst_prob = [prob / sum(lst_prob) for prob in lst_prob]
# 确保没有负值或 0
lst_prob = [max(0, prob) for prob in lst_prob]
# 根据修正后的概率选择 firm
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)
# Add edges from predecessor firms to current node (firm)
lst_add_edge = [(pred_firm, node, {'Product': pred_product_code}) for pred_firm in lst_choose_firm]
self.G_Firm.add_edges_from(lst_add_edge)
# Add edges to firm-product network
self.add_edges_to_firm_product_network(node, pred_product_code, lst_choose_firm)
def add_edges_to_firm_product_network(self, node, pred_product_code, lst_choose_firm):
""" Helper function to add edges to the firm-product network """
set_node_prod_code = set(self.G_Firm.nodes[node]['Product_Code'])
set_pred_succ_code = set(self.G_bom.successors(pred_product_code))
lst_use_pred_prod_code = list(set_node_prod_code & set_pred_succ_code)
if len(lst_use_pred_prod_code) == 0:
print("错误")
pred_node_list = []
for pred_firm in lst_choose_firm:
for n, v in self.G_FirmProd.nodes(data=True):
for v1 in v['Product_Code']:
if v1 == pred_product_code and v['Firm_Code'] == pred_firm:
pred_node_list.append(n)
if len(pred_node_list) != 0:
pred_node = pred_node_list[0]
else:
pred_node = -1
current_node_list = []
for use_pred_prod_code in lst_use_pred_prod_code:
for n, v in self.G_FirmProd.nodes(data=True):
for v1 in v['Product_Code']:
if v1 == use_pred_prod_code and v['Firm_Code'] == node:
current_node_list.append(n)
if len(current_node_list) != 0:
current_node = current_node_list[0]
else:
current_node = -1
if current_node != -1 and pred_node != -1:
self.G_FirmProd.add_edge(pred_node, current_node)
def connect_unconnected_nodes(self):
""" Connect unconnected nodes in the firm network """
for node in nx.nodes(self.G_Firm):
if self.G_Firm.degree(node) == 0:
current_node_list = []
for product_code in self.G_Firm.nodes[node]['Product_Code']:
for n, v in self.G_FirmProd.nodes(data=True):
for v1 in v['Product_Code']:
if v['Firm_Code'] == node and v1 == product_code:
current_node_list.append(n)
if len(current_node_list) != 0:
current_node = current_node_list[0]
else:
current_node = -1
lst_succ_product_code = list(self.G_bom.successors(product_code))
for succ_product_code in lst_succ_product_code:
lst_succ_firm = [firm_code for firm_code, product in self.firm_prod_labels_dict.items() if
succ_product_code in product]
n_succ_firm = self.int_netw_prf_n
if n_succ_firm > len(lst_succ_firm):
n_succ_firm = len(lst_succ_firm)
if self.is_prf_size:
lst_succ_firm_size = [self.G_Firm.nodes[succ_firm]['Revenue_Log'] for succ_firm in
lst_succ_firm]
if len(lst_succ_firm_size) == 0 or sum(lst_succ_firm_size) == 0:
# print("警告: lst_pred_firm_size 为空或总和为 0无法生成概率分布")
lst_choose_firm = [] # 返回空结果,或根据需要处理
else:
# 计算总和
sum_pred_firm_size = sum(lst_succ_firm_size)
# 归一化生成 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):
# print(f"警告: 概率总和为 {sum(lst_prob)},现在进行修正")
lst_prob = [prob / sum(lst_prob) for prob in lst_prob]
# 确保没有负值或 0
lst_prob = [max(0, prob) for prob in lst_prob]
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]
self.G_Firm.add_edges_from(lst_add_edge)
# Add edges to firm-product network
succ_node_list = []
for succ_firm in lst_choose_firm:
for n, v in self.G_FirmProd.nodes(data=True):
for v1 in v['Product_Code']:
if v1 == succ_product_code and v['Firm_Code'] == succ_firm:
succ_node_list.append(n)
if len(succ_node_list) != 0:
succ_node = succ_node_list[0]
else:
succ_node = -1
if current_node != -1 and succ_node != -1:
self.G_FirmProd.add_edge(current_node, succ_node)
self.sample.g_firm = json.dumps(nx.adjacency_data(self.G_Firm))
self.firm_network = self.G_Firm # 直接使用 networkx 图对象
self.firm_prod_network = self.G_FirmProd # 直接使用 networkx 图对象
model.step() # 运行仿真一步
model.end() # 汇总结果

View File

@@ -53,7 +53,6 @@ class ControllerDB:
# fill dct_lst_init_disrupt_firm_prod
# 存储 公司-在供应链结点的位置.. 0 1.1
list_dct = [] # 存储 公司编码code 和对应的产业链 结点
if self.is_with_exp:
# 对于方差分析时候使用
with open('SQL_export_high_risk_setting.sql', 'r') as f:
@@ -67,12 +66,27 @@ class ControllerDB:
# 行索引 (index):这一行在数据帧中的索引值。
# 行数据 (row):这一行的数据,是一个 pandas.Series 对象,包含该行的所有列和值。
# 读取企业与产品关系数据
firm_industry = pd.read_csv("input_data/firm_industry_relation.csv")
firm_industry['Firm_Code'] = firm_industry['Firm_Code'].astype('string')
# 假设已从 BOM 数据构建了 code_to_indices
bom_nodes = pd.read_csv("input_data/input_product_data/BomNodes.csv")
code_to_indices = bom_nodes.groupby('Code')['Index'].apply(list).to_dict()
# 初始化存储映射结果的列表
list_dct = []
# 遍历 firm_industry 数据
for _, row in firm_industry.iterrows():
code = row['Firm_Code']
row = row['Product_Code']
dct = {code: [row]}
firm_code = row['Firm_Code'] # 企业代码
product_code = row['Product_Code'] # 原始产品代码
# 使用 code_to_indices 映射 Product_Code 到 Product_Indices
mapped_indices = code_to_indices.get(product_code, []) # 如果找不到则返回空列表
# 构建企业到产品索引的映射
dct = {firm_code: mapped_indices}
list_dct.append(dct)
# fill g_bom

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 KiB

73
firm.py
View File

@@ -2,7 +2,7 @@ from mesa import Agent
class FirmAgent(Agent):
def __init__(self, unique_id, model, type_region, revenue_log, n_equip_c, a_lst_product,
def __init__(self, unique_id, model, type_region, revenue_log, a_lst_product,
production_output, demand_quantity, R, P, C):
# 调用超类的 __init__ 方法
super().__init__(unique_id, model)
@@ -32,20 +32,20 @@ class FirmAgent(Agent):
# 包括 产品时间
self.P1 = {0: P}
# 企业i的供应商
self.upper_i = [agent for u, v in self.firm_network.in_edges(self.unique_id)
for agent in self.model.company_agents if agent.unique_id == u]
self.upper_i = [self.model.agent_map[u] for u, v in self.firm_network.in_edges(self.unique_id)
if u in self.model.agent_map]
# 企业i的客户
self.downer_i = [agent for u, v in self.firm_network.out_edges(self.unique_id)
for agent in self.model.company_agents if agent.unique_id == u]
self.downer_i = [self.model.agent_map[v] for u, v in self.firm_network.out_edges(self.unique_id)
if v in self.model.agent_map]
# 设备c的数量 (总量) 使用这个来判断设备数量
self.n_equip_c = n_equip_c
# self.n_equip_c = n_equip_c
# 设备c产量 根据设备量进行估算
self.c_yield = production_output
# 消耗材料量 根据设备量进行估算 { }
self.c_consumption = demand_quantity
# 设备c购买价格初始值
# self.c_price = c_price
# 资源r补货库存阈值
# 资源r补货库存阈值 很重要设置
self.s_r = 40
self.S_r = 120
# 设备补货阙值 可选
@@ -143,41 +143,68 @@ class FirmAgent(Agent):
# f"disrupted supplier of {disrupted_up_prod.code}")
def seek_alt_supply(self, product):
# 检查当前产品的尝试次数是否达到最大值
if self.dct_n_trial_up_prod_disrupted[product] <= self.model.int_n_max_trial:
# 初始化候选供应商列表
if self.dct_n_trial_up_prod_disrupted[product] == 0:
self.dct_cand_alt_supp_up_prod_disrupted[product] = [
firm for firm in self.model.company_agents
if firm.is_prod_in_current_normal(product)]
if self.dct_cand_alt_supp_up_prod_disrupted[product]:
firm for firm in self.model.company_agents if firm.is_prod_in_current_normal(product)
]
# 如果没有候选供应商,直接退出
if not self.dct_cand_alt_supp_up_prod_disrupted[product]:
# print(f"No valid candidates found for product {product.unique_id}")
return
# 查找与当前企业已连接的候选供应商
lst_firm_connect = []
if self.is_prf_conn:
for firm in self.dct_cand_alt_supp_up_prod_disrupted[product]:
if self.firm_network.has_edge(self.unique_id, firm.unique_id) or \
self.firm_network.has_edge(firm.unique_id, self.unique_id):
lst_firm_connect.append(firm)
if len(lst_firm_connect) == 0:
if self.is_prf_size:
lst_firm_connect = [
firm for firm in self.dct_cand_alt_supp_up_prod_disrupted[product]
if self.firm_network.has_edge(self.unique_id, firm.unique_id) or
self.firm_network.has_edge(firm.unique_id, self.unique_id)
]
# 如果没有连接的供应商
if not lst_firm_connect:
if self.is_prf_size: # 根据规模加权选择
lst_size = [firm.size_stat[-1][0] for firm in self.dct_cand_alt_supp_up_prod_disrupted[product]]
lst_prob = [size / sum(lst_size) for size in lst_size]
select_alt_supply = \
self.random.choices(self.dct_cand_alt_supp_up_prod_disrupted[product], weights=lst_prob)[0]
else:
select_alt_supply = self.random.choices(
self.dct_cand_alt_supp_up_prod_disrupted[product], weights=lst_prob
)[0]
else: # 随机选择
select_alt_supply = self.random.choice(self.dct_cand_alt_supp_up_prod_disrupted[product])
elif len(lst_firm_connect) > 0:
if self.is_prf_size:
else: # 如果存在连接的供应商
if self.is_prf_size: # 根据规模加权选择
lst_firm_size = [firm.size_stat[-1][0] for firm in lst_firm_connect]
lst_prob = [size / sum(lst_firm_size) for size in lst_firm_size]
select_alt_supply = self.random.choices(lst_firm_connect, weights=lst_prob)[0]
else:
else: # 随机选择
select_alt_supply = self.random.choice(lst_firm_connect)
assert select_alt_supply.is_prod_in_current_normal(product)
# 检查选中的供应商是否能够生产产品
if not select_alt_supply.is_prod_in_current_normal(product):
# print(f"Selected supplier {select_alt_supply.unique_id} cannot produce product {product.unique_id}")
# 打印供应商的生产状态字典
#print(f"Supplier production state: {select_alt_supply.dct_prod_up_prod_stat}")
# 检查产品是否存在于生产状态字典中
if product in select_alt_supply.dct_prod_up_prod_stat:
print(
f"Product {product.unique_id} production state: {select_alt_supply.dct_prod_up_prod_stat[product]['p_stat']}")
else:
print(f"Product {product.unique_id} not found in supplier production state.")
return
# 添加到供应商的请求字典
if product in select_alt_supply.dct_request_prod_from_firm:
select_alt_supply.dct_request_prod_from_firm[product].append(self)
else:
select_alt_supply.dct_request_prod_from_firm[product] = [self]
# 更新尝试次数
self.dct_n_trial_up_prod_disrupted[product] += 1
def handle_request(self):

BIN
firm_network.pkl Normal file

Binary file not shown.

BIN
iiabmdb_basic_info.sql Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -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
1 IndustryID MaterialID Quantity
2 38 47 1.0
3 39 49 1.0
4 40 44 1.0
5 41 15 0.02
6 41 18 0.1
7 41 20 0.4
8 41 22 0.15
9 41 23 0.04
10 41 25 0.02
11 41 31 0.25
12 41 36 1.0
13 42 15 0.02
14 42 18 0.1
15 42 20 0.4
16 42 22 0.15
17 42 23 0.04
18 42 25 0.02
19 42 31 0.25
20 43 46 1.0
21 44 7 1.4
22 44 15 0.02
23 44 18 0.1
24 44 20 0.4
25 44 22 0.15
26 44 23 0.04
27 44 25 0.02
28 44 27 0.25
29 45 7 1.4
30 45 15 0.02
31 45 18 0.1
32 45 20 0.4
33 45 22 0.15
34 45 23 0.04
35 45 25 0.02
36 45 27 0.25
37 46 15 0.02
38 46 18 0.1
39 46 20 0.4
40 46 22 0.15
41 46 23 0.04
42 46 25 0.02
43 46 27 0.25
44 46 32 1.3
45 47 15 0.02
46 47 18 0.1
47 47 20 0.4
48 47 22 0.15
49 47 23 0.04
50 47 25 0.02
51 47 27 0.25
52 47 33 1.0
53 48 15 0.02
54 48 18 0.1
55 48 20 0.4
56 48 22 0.15
57 48 23 0.04
58 48 25 0.02
59 48 27 0.25
60 48 34 1.3
61 49 15 0.02
62 49 18 0.1
63 49 20 0.4
64 49 22 0.15
65 49 23 0.04
66 49 25 0.02
67 49 27 0.25
68 49 35 1.3
69 50 19 0.005
70 50 20 0.4
71 50 22 0.15
72 50 23 0.04
73 50 25 0.02
74 50 28 0.25
75 50 29 0.03
76 50 27 0.01
77 50 40 1.0
78 51 19 0.005
79 51 20 0.4
80 51 22 0.15
81 51 23 0.04
82 51 25 0.02
83 51 28 0.25
84 51 29 0.03
85 51 27 0.01
86 51 38 1.0
87 52 19 0.005
88 52 20 0.4
89 52 22 0.15
90 52 23 0.04
91 52 25 0.02
92 52 28 0.25
93 52 29 0.03
94 52 27 0.01
95 52 41 1.0
96 53 19 0.005
97 53 20 0.4
98 53 22 0.15
99 53 23 0.04
100 53 25 0.02
101 53 28 0.25
102 53 29 0.03
103 53 27 0.01
104 53 39 1.0
105 54 19 0.005
106 54 20 0.4
107 54 22 0.15
108 54 23 0.04
109 54 25 0.02
110 54 28 0.25
111 54 29 0.03
112 54 27 0.01
113 54 43 1.0
114 55 19 0.005
115 55 20 0.4
116 55 22 0.15
117 55 23 0.04
118 55 25 0.02
119 55 28 0.25
120 55 29 0.03
121 55 27 0.01
122 55 42 1.0
123 90 7 1.7
124 90 8 0.07
125 90 9 0.07
126 90 10 0.02
127 90 11 0.04
128 90 17 0.1
129 90 19 0.005
130 90 20 0.4
131 90 21 0.04
132 90 23 0.04
133 90 24 0.07
134 90 25 0.02
135 90 28 0.03
136 90 31 0.25
137 90 44 0.2
138 90 45 0.1
139 91 8 0.07
140 91 9 0.07
141 91 10 0.02
142 91 11 0.04
143 91 17 0.1
144 91 18 0.1
145 91 19 0.005
146 91 20 0.4
147 91 23 0.04
148 91 24 0.07
149 91 28 0.03
150 91 31 0.25
151 92 8 0.07
152 92 9 0.07
153 92 10 0.02
154 92 11 0.04
155 92 17 0.1
156 92 18 0.1
157 92 19 0.005
158 92 20 0.4
159 92 23 0.04
160 92 24 0.07
161 92 28 0.03
162 92 31 0.26
163 93 8 0.07
164 93 9 0.07
165 93 10 0.02
166 93 11 0.04
167 93 17 0.1
168 93 18 0.1
169 93 19 0.005
170 93 20 0.4
171 93 23 0.04
172 93 24 0.07
173 93 28 0.03
174 93 31 0.27
175 94 8 0.07
176 94 9 0.07
177 94 10 0.02
178 94 11 0.04
179 94 17 0.1
180 94 18 0.1
181 94 19 0.005
182 94 20 0.4
183 94 23 0.04
184 94 24 0.07
185 94 28 0.03
186 94 31 0.28
187 95 8 0.1
188 95 9 0.0
189 95 10 7.0
190 95 11 0.02
191 95 12 0.03
192 95 13 0.01
193 95 14 0.01
194 95 15 0.07
195 95 16 0.05
196 95 17 0.003
197 95 18 0.1
198 95 19 0.04
199 95 20 0.01
200 95 21 0.04
201 95 22 0.03
202 95 23 0.02
203 95 24 0.01
204 95 25 0.05
205 95 26 0.01
206 95 27 0.003
207 95 28 0.1
208 95 29 0.05
209 95 30 0.04
210 95 31 0.01
211 95 37 0.1
212 95 44 0.04
213 95 45 0.7
214 95 46 0.07
215 95 47 0.01
216 95 48 0.03
217 95 49 0.01
218 95 50 0.01
219 95 51 0.01
220 95 52 0.2
221 95 53 0.03
222 95 54 0.01
223 95 55 0.01
224 95 90 0.01
225 95 91 0.01
226 95 92 1.0
227 95 93 1.0
228 95 94 1.0
229 96 95 1.0
230 96 101 0.01
231 96 102 0.01
232 96 103 0.02
233 96 104 0.01
234 96 105 0.2
235 96 106 0.1
236 96 107 0.01
237 96 108 0.03
238 96 109 0.02

14
main.py
View File

@@ -3,6 +3,9 @@ import random
import time
from multiprocessing import Process
import argparse
from matplotlib import pyplot as plt
from computation import Computation
from sqlalchemy.orm import close_all_sessions
import yaml
@@ -30,11 +33,16 @@ def do_process(target: object, controller_db: ControllerDB, ):
for i in process_list:
i.join()
# 所有子进程完成后刷新最终进度
# 显示最终进度后关闭图表
def do_computation(c_db):
exp = Computation(c_db)
while 1:
time.sleep(random.uniform(0, 1))
# time.sleep(random.uniform(0, 1))
is_all_done = exp.run()
if is_all_done:
break
@@ -44,9 +52,9 @@ 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='4')
parser.add_argument('--reset_sample', type=int, default='0')
parser.add_argument('--reset_db', type=bool, default=False)
parser.add_argument('--reset_db', type=bool, default=True)
args = parser.parse_args()
# 几核参与进程

File diff suppressed because it is too large Load Diff

4
orm.py
View File

@@ -98,8 +98,8 @@ class Result(Base):
s_id = Column(Integer, ForeignKey('{}.id'.format(
f"{db_name_prefix}_sample")), nullable=False)
id_firm = Column(String(10), nullable=False)
id_product = Column(String(10), nullable=False)
id_firm = Column(String(20), nullable=False)
id_product = Column(String(20), nullable=False)
ts = Column(Integer, nullable=False)
status = Column(String(5), nullable=False)

View File

@@ -0,0 +1,9 @@
Unnamed: 0.1,Unnamed: 0,mean_end_ts,mean_n_remove_firm_prod,mean_max_ts_firm_prod,mean_count_firm_prod
p1,n_sourcing,0.319,0.145,0.043,0.186
p2,is_prf_size,0.607,0.608,0.005,0.111
p3,n_max_trial,0.003,0.135,0.0,0.0
p4,is_prf_conn,0.504,0.567,0.001,0.0
p5,ex_cap_type,0.403,0.667,0.329,0.444
p6,ex_cap_para,0.0,0.0,0.0,0.0
p7,prob_new_conn,0.017,0.334,0.01,0.007
p8,t_max_trial,0.0,0.014,0.939,0.1
1 Unnamed: 0.1 Unnamed: 0 mean_end_ts mean_n_remove_firm_prod mean_max_ts_firm_prod mean_count_firm_prod
2 p1 n_sourcing 0.319 0.145 0.043 0.186
3 p2 is_prf_size 0.607 0.608 0.005 0.111
4 p3 n_max_trial 0.003 0.135 0.0 0.0
5 p4 is_prf_conn 0.504 0.567 0.001 0.0
6 p5 ex_cap_type 0.403 0.667 0.329 0.444
7 p6 ex_cap_para 0.0 0.0 0.0 0.0
8 p7 prob_new_conn 0.017 0.334 0.01 0.007
9 p8 t_max_trial 0.0 0.014 0.939 0.1

View File

@@ -0,0 +1,22 @@
自变量,level,系统恢复用时R1,产业-企业边累计扰乱次数R2,产业-企业边最大传导深度R3,产业-企业边断裂总数R4
采购策略P1,三供应商,3.549,62.11,1.715,22.14
采购策略P1,双供应商,3.743,62.43,1.759,21.71
采购策略P1,单供应商,3.668,62.21,1.736,22.17
是否规模偏好P2,倾向,3.681,62.13,1.715,22.06
是否规模偏好P2,不倾向,3.627,62.37,1.758,21.96
最大尝试次数P3,,3.47,61.08,1.636,21.85
最大尝试次数P3,,3.552,62.08,1.742,21.86
最大尝试次数P3,,3.939,63.58,1.832,22.31
是否已有连接偏好P4,倾向,3.619,61.95,1.711,21.95
是否已有连接偏好P4,不倾向,3.689,62.55,1.762,22.07
额外产能分布P5,均匀分布,3.698,62.19,1.73,21.96
额外产能分布P5,正态分布,3.61,62.3,1.743,22.05
额外产能分布参数P6,,2.949,61.48,1.808,12.41
额外产能分布参数P6,,3.787,62.2,1.661,22.87
额外产能分布参数P6,,4.224,63.06,1.741,30.75
新供应关系构成概率P7,,3.882,62.41,1.749,22.2
新供应关系构成概率P7,,3.543,62.44,1.756,22.01
新供应关系构成概率P7,,3.535,61.9,1.705,21.82
最大尝试时间步P8,,2.601,62.03,1.738,22.47
最大尝试时间步P8,,3.656,62.31,1.733,21.78
最大尝试时间步P8,,4.704,62.4,1.738,21.78
1 自变量 level 系统恢复用时R1 产业-企业边累计扰乱次数R2 产业-企业边最大传导深度R3 产业-企业边断裂总数R4
2 采购策略P1 三供应商 3.549 62.11 1.715 22.14
3 采购策略P1 双供应商 3.743 62.43 1.759 21.71
4 采购策略P1 单供应商 3.668 62.21 1.736 22.17
5 是否规模偏好P2 倾向 3.681 62.13 1.715 22.06
6 是否规模偏好P2 不倾向 3.627 62.37 1.758 21.96
7 最大尝试次数P3 3.47 61.08 1.636 21.85
8 最大尝试次数P3 3.552 62.08 1.742 21.86
9 最大尝试次数P3 3.939 63.58 1.832 22.31
10 是否已有连接偏好P4 倾向 3.619 61.95 1.711 21.95
11 是否已有连接偏好P4 不倾向 3.689 62.55 1.762 22.07
12 额外产能分布P5 均匀分布 3.698 62.19 1.73 21.96
13 额外产能分布P5 正态分布 3.61 62.3 1.743 22.05
14 额外产能分布参数P6 2.949 61.48 1.808 12.41
15 额外产能分布参数P6 3.787 62.2 1.661 22.87
16 额外产能分布参数P6 4.224 63.06 1.741 30.75
17 新供应关系构成概率P7 3.882 62.41 1.749 22.2
18 新供应关系构成概率P7 3.543 62.44 1.756 22.01
19 新供应关系构成概率P7 3.535 61.9 1.705 21.82
20 最大尝试时间步P8 2.601 62.03 1.738 22.47
21 最大尝试时间步P8 3.656 62.31 1.733 21.78
22 最大尝试时间步P8 4.704 62.4 1.738 21.78

View File

@@ -0,0 +1,37 @@
idx_scenario,n_max_trial,prf_size,prf_conn,cap_limit_prob_type,cap_limit_level,diff_new_conn,remove_t,netw_prf_n,mean_count_firm_prod,mean_count_firm,mean_count_prod,mean_max_ts_firm_prod,mean_max_ts_firm,mean_max_ts_prod,mean_n_remove_firm_prod,mean_n_all_prod_remove_firm,mean_end_ts,
0,7,1,1,uniform,5.0000,0.3000,3,3,59.6916,15.7589,13.3347,1.5063,1.5032,1.3842,12.3074,1.5379,2.0400
1,5,1,1,uniform,10.0000,0.5000,5,2,61.8937,17.1126,13.8095,1.7284,1.7263,1.6042,22.7779,2.9611,3.7432
2,3,1,1,uniform,15.0000,0.7000,7,1,63.9568,18.2253,14.2779,1.8263,1.8221,1.7347,30.9263,3.7842,5.6253
3,7,1,1,uniform,5.0000,0.3000,3,2,59.5811,15.7474,13.3168,1.4958,1.4937,1.3884,12.8358,1.4621,2.0221
4,5,1,1,uniform,10.0000,0.5000,5,1,61.8200,17.0116,13.8053,1.7095,1.7084,1.6032,22.5474,2.9579,3.6811
5,3,1,1,uniform,15.0000,0.7000,7,3,63.8821,18.2547,14.2432,1.8421,1.8305,1.7295,30.9474,3.7411,5.6632
6,7,1,1,normal,5.0000,0.5000,7,3,59.9116,15.7516,13.3316,1.4905,1.4884,1.3674,12.2463,1.3326,3.1600
7,5,1,1,normal,10.0000,0.7000,3,2,61.3095,16.8326,13.7716,1.7011,1.7011,1.6011,22.4779,2.9642,2.4916
8,3,1,1,normal,15.0000,0.3000,5,1,63.6568,18.1316,14.2358,1.8253,1.8232,1.7242,31.1253,3.7400,4.3474
9,7,1,0,uniform,5.0000,0.7000,5,3,59.7158,15.6811,13.3000,1.4600,1.4568,1.3537,12.4063,1.3400,2.5316
10,5,1,0,uniform,10.0000,0.3000,7,2,63.0063,17.6695,14.0432,1.8063,1.8053,1.6747,22.6916,3.0042,5.1126
11,3,1,0,uniform,15.0000,0.5000,3,1,63.6779,18.3842,14.3547,1.8621,1.8600,1.7621,31.3663,4.0253,2.9632
12,7,1,0,normal,10.0000,0.7000,3,1,60.6295,16.3884,13.5811,1.6179,1.6147,1.5147,22.5221,2.7800,2.3495
13,5,1,0,normal,15.0000,0.3000,5,3,63.3484,18.0042,14.2074,1.8316,1.8263,1.7232,30.6379,3.7747,4.2979
14,3,1,0,normal,5.0000,0.5000,7,2,64.0737,18.3684,14.3000,1.8505,1.8484,1.7589,11.4789,1.1663,4.1400
15,7,1,0,normal,10.0000,0.7000,5,3,61.0337,16.5684,13.6053,1.6358,1.6347,1.5074,22.7474,2.8937,3.5147
16,5,1,0,normal,15.0000,0.3000,7,2,63.4747,18.0568,14.1989,1.8347,1.8305,1.7263,30.4063,3.7989,5.7295
17,3,1,0,normal,5.0000,0.5000,3,1,63.7158,18.2863,14.2958,1.8547,1.8537,1.7579,14.6568,2.1432,2.8368
18,7,0,1,normal,10.0000,0.3000,7,1,61.2326,16.6442,13.6789,1.6705,1.6684,1.5495,22.5453,2.8379,4.7474
19,5,0,1,normal,15.0000,0.5000,3,3,62.3863,17.4684,13.9905,1.7874,1.7853,1.6705,31.1558,3.8189,2.7926
20,3,0,1,normal,5.0000,0.7000,5,2,62.8305,17.6074,14.0811,1.7705,1.7695,1.6768,11.7621,1.2474,3.2684
21,7,0,1,normal,10.0000,0.5000,7,1,61.1832,16.5389,13.6874,1.6505,1.6484,1.5337,22.8484,2.8147,4.7326
22,5,0,1,normal,15.0000,0.7000,3,3,62.3305,17.5337,14.0011,1.7768,1.7747,1.6495,30.6705,3.7832,2.7316
23,3,0,1,normal,5.0000,0.3000,5,2,62.8821,17.6916,14.0905,1.7821,1.7821,1.6895,12.2158,1.3442,3.3484
24,7,0,1,uniform,15.0000,0.5000,3,2,62.2463,17.4084,13.9789,1.7979,1.7958,1.6674,30.6842,3.7126,2.7589
25,5,0,1,uniform,5.0000,0.7000,5,1,60.9453,16.4442,13.6316,1.6274,1.6263,1.5032,12.2347,1.2663,2.7368
26,3,0,1,uniform,10.0000,0.3000,7,3,63.3400,17.8968,14.1147,1.8084,1.8074,1.6937,22.7768,3.0442,5.2442
27,7,0,0,normal,15.0000,0.5000,5,2,62.6505,17.5074,14.0032,1.7811,1.7800,1.6758,30.0211,3.6116,4.1263
28,5,0,0,normal,5.0000,0.7000,7,1,60.9200,16.5126,13.6168,1.6368,1.6358,1.5168,11.9432,1.2495,3.3305
29,3,0,0,normal,10.0000,0.3000,3,3,63.9074,18.4432,14.3916,1.8811,1.8779,1.7789,25.4905,3.4789,3.0295
30,7,0,0,uniform,15.0000,0.7000,7,2,62.2442,17.2747,13.9400,1.7400,1.7358,1.6253,30.5084,3.6589,5.4421
31,5,0,0,uniform,5.0000,0.3000,3,1,61.9147,17.2211,13.9347,1.7558,1.7526,1.6453,12.8168,1.6895,2.4516
32,3,0,0,uniform,10.0000,0.5000,5,3,64.1074,18.3579,14.3558,1.8579,1.8568,1.7505,22.2800,3.0684,4.0642
33,7,0,0,uniform,15.0000,0.3000,5,1,62.8737,17.5600,14.0642,1.7895,1.7874,1.6684,30.5453,3.6695,4.2147
34,5,0,0,uniform,5.0000,0.5000,7,3,61.6337,16.9042,13.7632,1.7032,1.7011,1.5716,12.0011,1.2263,3.5221
35,3,0,0,uniform,10.0000,0.7000,3,2,62.9663,17.9737,14.2221,1.8221,1.8211,1.7211,22.6979,3.1600,2.7389
1 idx_scenario,n_max_trial,prf_size,prf_conn,cap_limit_prob_type,cap_limit_level,diff_new_conn,remove_t,netw_prf_n,mean_count_firm_prod,mean_count_firm,mean_count_prod,mean_max_ts_firm_prod,mean_max_ts_firm,mean_max_ts_prod,mean_n_remove_firm_prod,mean_n_all_prod_remove_firm,mean_end_ts,
2 0,7,1,1,uniform,5.0000,0.3000,3,3,59.6916,15.7589,13.3347,1.5063,1.5032,1.3842,12.3074,1.5379,2.0400
3 1,5,1,1,uniform,10.0000,0.5000,5,2,61.8937,17.1126,13.8095,1.7284,1.7263,1.6042,22.7779,2.9611,3.7432
4 2,3,1,1,uniform,15.0000,0.7000,7,1,63.9568,18.2253,14.2779,1.8263,1.8221,1.7347,30.9263,3.7842,5.6253
5 3,7,1,1,uniform,5.0000,0.3000,3,2,59.5811,15.7474,13.3168,1.4958,1.4937,1.3884,12.8358,1.4621,2.0221
6 4,5,1,1,uniform,10.0000,0.5000,5,1,61.8200,17.0116,13.8053,1.7095,1.7084,1.6032,22.5474,2.9579,3.6811
7 5,3,1,1,uniform,15.0000,0.7000,7,3,63.8821,18.2547,14.2432,1.8421,1.8305,1.7295,30.9474,3.7411,5.6632
8 6,7,1,1,normal,5.0000,0.5000,7,3,59.9116,15.7516,13.3316,1.4905,1.4884,1.3674,12.2463,1.3326,3.1600
9 7,5,1,1,normal,10.0000,0.7000,3,2,61.3095,16.8326,13.7716,1.7011,1.7011,1.6011,22.4779,2.9642,2.4916
10 8,3,1,1,normal,15.0000,0.3000,5,1,63.6568,18.1316,14.2358,1.8253,1.8232,1.7242,31.1253,3.7400,4.3474
11 9,7,1,0,uniform,5.0000,0.7000,5,3,59.7158,15.6811,13.3000,1.4600,1.4568,1.3537,12.4063,1.3400,2.5316
12 10,5,1,0,uniform,10.0000,0.3000,7,2,63.0063,17.6695,14.0432,1.8063,1.8053,1.6747,22.6916,3.0042,5.1126
13 11,3,1,0,uniform,15.0000,0.5000,3,1,63.6779,18.3842,14.3547,1.8621,1.8600,1.7621,31.3663,4.0253,2.9632
14 12,7,1,0,normal,10.0000,0.7000,3,1,60.6295,16.3884,13.5811,1.6179,1.6147,1.5147,22.5221,2.7800,2.3495
15 13,5,1,0,normal,15.0000,0.3000,5,3,63.3484,18.0042,14.2074,1.8316,1.8263,1.7232,30.6379,3.7747,4.2979
16 14,3,1,0,normal,5.0000,0.5000,7,2,64.0737,18.3684,14.3000,1.8505,1.8484,1.7589,11.4789,1.1663,4.1400
17 15,7,1,0,normal,10.0000,0.7000,5,3,61.0337,16.5684,13.6053,1.6358,1.6347,1.5074,22.7474,2.8937,3.5147
18 16,5,1,0,normal,15.0000,0.3000,7,2,63.4747,18.0568,14.1989,1.8347,1.8305,1.7263,30.4063,3.7989,5.7295
19 17,3,1,0,normal,5.0000,0.5000,3,1,63.7158,18.2863,14.2958,1.8547,1.8537,1.7579,14.6568,2.1432,2.8368
20 18,7,0,1,normal,10.0000,0.3000,7,1,61.2326,16.6442,13.6789,1.6705,1.6684,1.5495,22.5453,2.8379,4.7474
21 19,5,0,1,normal,15.0000,0.5000,3,3,62.3863,17.4684,13.9905,1.7874,1.7853,1.6705,31.1558,3.8189,2.7926
22 20,3,0,1,normal,5.0000,0.7000,5,2,62.8305,17.6074,14.0811,1.7705,1.7695,1.6768,11.7621,1.2474,3.2684
23 21,7,0,1,normal,10.0000,0.5000,7,1,61.1832,16.5389,13.6874,1.6505,1.6484,1.5337,22.8484,2.8147,4.7326
24 22,5,0,1,normal,15.0000,0.7000,3,3,62.3305,17.5337,14.0011,1.7768,1.7747,1.6495,30.6705,3.7832,2.7316
25 23,3,0,1,normal,5.0000,0.3000,5,2,62.8821,17.6916,14.0905,1.7821,1.7821,1.6895,12.2158,1.3442,3.3484
26 24,7,0,1,uniform,15.0000,0.5000,3,2,62.2463,17.4084,13.9789,1.7979,1.7958,1.6674,30.6842,3.7126,2.7589
27 25,5,0,1,uniform,5.0000,0.7000,5,1,60.9453,16.4442,13.6316,1.6274,1.6263,1.5032,12.2347,1.2663,2.7368
28 26,3,0,1,uniform,10.0000,0.3000,7,3,63.3400,17.8968,14.1147,1.8084,1.8074,1.6937,22.7768,3.0442,5.2442
29 27,7,0,0,normal,15.0000,0.5000,5,2,62.6505,17.5074,14.0032,1.7811,1.7800,1.6758,30.0211,3.6116,4.1263
30 28,5,0,0,normal,5.0000,0.7000,7,1,60.9200,16.5126,13.6168,1.6368,1.6358,1.5168,11.9432,1.2495,3.3305
31 29,3,0,0,normal,10.0000,0.3000,3,3,63.9074,18.4432,14.3916,1.8811,1.8779,1.7789,25.4905,3.4789,3.0295
32 30,7,0,0,uniform,15.0000,0.7000,7,2,62.2442,17.2747,13.9400,1.7400,1.7358,1.6253,30.5084,3.6589,5.4421
33 31,5,0,0,uniform,5.0000,0.3000,3,1,61.9147,17.2211,13.9347,1.7558,1.7526,1.6453,12.8168,1.6895,2.4516
34 32,3,0,0,uniform,10.0000,0.5000,5,3,64.1074,18.3579,14.3558,1.8579,1.8568,1.7505,22.2800,3.0684,4.0642
35 33,7,0,0,uniform,15.0000,0.3000,5,1,62.8737,17.5600,14.0642,1.7895,1.7874,1.6684,30.5453,3.6695,4.2147
36 34,5,0,0,uniform,5.0000,0.5000,7,3,61.6337,16.9042,13.7632,1.7032,1.7011,1.5716,12.0011,1.2263,3.5221
37 35,3,0,0,uniform,10.0000,0.7000,3,2,62.9663,17.9737,14.2221,1.8221,1.8211,1.7211,22.6979,3.1600,2.7389

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

@@ -1,23 +1,710 @@
up_id_product,down_id_product,count
2.1.3.7,2.1.3,7
1.3.1.3,1.3.1,5
2.1.3.4,2.1.3,4
2.1.3.2,2.1.3,3
1.3.3.3,1.3.3,3
1.1.1,1.1,2
1.3.4.2,1.3.4,2
2.1.1.5,2.1.1,2
1.3.4.3,1.3.4,2
2.3.1,2.3,2
1.3.1.5,1.3.1,2
1.3.3.4,1.3.3,1
1.1.3,1.1,1
1.4.5.6,1.4.5,1
2.1.1.4,2.1.1,1
1.3.1.7,1.3.1,1
2.1.2.2,2.1.2,1
1.3.1.4,1.3.1,1
1.3.1.1,1.3.1,1
2.1.4.1.1,2.1.4.1,1
2.2,2,1
1.4.3.4,1.4.3,1
46,52,8413
48,52,8375
48,55,8345
46,55,8328
45,52,8274
44,52,8248
49,52,8246
49,55,8197
44,55,8172
45,55,8151
47,52,8077
47,55,8016
55,99,7248
52,99,7163
50,99,7085
54,99,7066
51,99,7031
53,99,7010
54,55,5570
54,52,5539
53,55,5524
52,55,5462
51,55,5441
50,55,5440
53,52,5438
55,52,5379
51,52,5312
50,52,5296
55,55,5254
52,52,5177
45,99,5036
46,99,4997
48,99,4976
44,99,4960
49,99,4941
55,95,4906
52,95,4895
47,99,4812
53,95,4643
51,95,4628
50,95,4578
54,95,4539
95,99,3147
47,95,3060
44,95,3028
46,95,3026
48,95,3021
49,95,3013
45,95,2937
46,43,2771
48,43,2748
45,43,2740
49,43,2738
44,43,2721
47,43,2720
49,39,2461
45,39,2460
48,39,2452
44,39,2427
46,39,2409
47,39,2378
54,43,2375
53,43,2366
55,43,2364
50,43,2338
52,43,2328
51,43,2327
44,40,2305
45,40,2296
48,40,2289
46,40,2287
49,40,2265
47,40,2257
47,38,2240
49,38,2224
45,38,2214
46,38,2200
54,39,2195
53,39,2184
48,38,2183
55,39,2177
51,39,2162
50,39,2156
44,38,2154
52,39,2147
48,90,2100
49,90,2092
45,90,2088
46,90,2077
47,90,2062
44,90,2054
94,99,2051
93,99,2019
91,99,1996
54,40,1977
50,40,1976
53,40,1973
55,40,1966
51,40,1964
52,40,1937
54,38,1928
50,38,1910
51,38,1900
53,38,1893
55,38,1888
52,38,1883
42,55,1788
41,52,1779
95,55,1734
95,52,1729
42,52,1717
41,55,1699
53,90,1629
55,90,1628
54,90,1623
51,90,1619
52,90,1606
50,90,1597
94,52,1207
92,99,1179
94,55,1143
94,95,1124
91,52,1084
93,55,1073
93,52,1065
91,55,1057
93,95,1005
91,95,1005
90,99,997
95,95,798
41,99,778
42,99,765
92,95,670
92,55,644
92,52,625
95,43,563
95,39,543
90,95,523
95,40,495
42,95,464
95,38,453
41,95,441
90,52,419
95,90,407
41,43,403
20,55,402
42,43,394
90,55,390
20,52,384
41,39,381
42,39,376
41,40,345
41,38,341
7,95,340
42,40,334
42,38,332
60,55,318
60,52,316
64,55,308
67,55,300
42,90,299
23,52,299
25,52,297
65,55,296
23,55,296
71,55,296
65,52,295
25,55,294
64,52,292
67,52,290
22,52,288
22,55,287
41,90,284
71,52,282
18,52,259
15,48,258
27,49,255
18,46,252
28,51,250
27,47,250
68,55,250
29,55,250
63,55,250
72,51,249
41,53,249
43,53,249
38,53,249
69,55,249
23,49,249
42,53,249
39,53,249
23,45,248
69,52,248
68,52,248
94,43,248
20,44,248
65,45,248
40,51,247
41,51,247
38,51,247
39,51,247
71,54,247
15,46,247
63,50,247
43,51,247
42,51,247
71,51,246
62,53,246
25,44,246
39,55,246
72,50,246
67,48,246
40,53,246
43,55,246
68,51,246
40,55,246
38,55,246
18,44,246
69,51,246
23,50,246
65,46,246
20,48,246
67,49,245
72,54,245
22,50,245
33,47,245
62,51,244
68,54,244
64,46,244
23,44,244
67,51,244
18,48,244
23,47,244
69,53,244
19,52,243
65,47,243
60,45,243
65,54,243
67,44,243
28,52,243
67,54,243
60,54,243
71,49,243
20,46,243
19,51,242
20,54,242
63,53,242
65,48,242
62,52,242
64,54,242
25,49,242
71,45,242
27,46,242
69,50,241
27,55,241
67,46,241
64,50,241
64,45,241
18,45,241
60,44,241
20,49,241
19,55,241
19,54,241
63,52,241
60,48,240
25,53,240
25,50,240
15,49,240
28,54,240
72,55,240
60,49,240
27,48,240
20,53,240
19,50,240
23,46,240
40,52,239
60,53,239
38,52,239
67,47,239
39,52,239
35,49,239
68,50,239
64,53,239
43,52,239
22,53,239
20,47,238
25,51,238
65,53,238
15,44,238
18,49,238
60,47,238
28,53,238
27,51,238
29,50,238
27,53,238
29,53,238
68,53,237
67,53,237
23,48,237
67,50,237
34,48,237
72,52,237
32,46,237
27,50,237
63,51,236
19,53,236
23,54,236
71,48,236
25,45,236
15,47,236
22,48,236
20,50,236
27,44,236
22,46,235
20,51,235
38,50,235
41,50,235
39,50,235
64,51,235
22,44,235
67,45,235
40,50,235
42,50,235
28,50,235
27,54,235
27,52,235
43,50,235
60,50,234
18,55,234
25,47,234
25,48,234
65,49,234
62,54,233
64,49,233
62,55,233
71,46,233
65,50,233
72,53,233
22,47,233
22,45,233
29,51,233
15,45,232
65,44,232
22,49,232
18,47,232
64,48,232
71,53,232
23,53,231
27,45,231
20,45,231
63,54,231
28,55,231
22,54,231
22,51,230
71,47,230
60,51,230
60,46,230
62,50,230
25,46,229
25,54,229
29,54,228
50,45,227
23,51,227
48,45,227
49,45,227
55,45,227
51,45,227
54,45,227
52,45,227
7,45,227
53,45,227
47,45,227
65,51,227
71,44,227
64,44,227
45,45,227
46,45,227
44,45,227
46,44,226
7,44,226
51,44,226
45,44,226
50,44,226
55,44,226
47,44,226
48,44,226
44,44,226
49,44,226
53,44,226
54,44,226
52,44,226
69,54,225
29,52,224
64,47,224
39,54,222
41,54,222
38,54,222
42,54,222
43,54,222
40,54,222
71,50,221
91,40,208
93,43,208
91,43,204
93,39,199
93,40,198
94,40,190
91,39,189
94,38,184
93,38,182
91,38,182
94,39,181
90,43,158
90,39,130
90,38,130
92,43,130
90,40,127
91,90,124
94,90,120
93,90,120
20,95,118
23,95,113
92,40,109
92,39,107
92,38,107
15,95,97
19,95,90
62,95,90
28,95,90
9,95,88
18,95,88
7,90,86
64,95,86
66,95,83
60,95,79
24,95,79
72,95,78
22,99,74
31,95,73
8,95,73
17,94,72
28,94,71
67,95,71
27,95,70
17,99,70
66,91,69
63,95,69
9,94,69
18,94,69
28,99,69
59,94,69
24,94,68
31,93,68
65,99,68
11,94,68
29,99,68
23,94,68
66,93,67
70,91,67
28,93,67
10,93,67
8,91,67
70,93,67
15,55,66
10,94,66
66,94,66
64,99,66
59,93,66
31,94,66
18,93,65
62,94,65
11,93,65
8,94,65
59,99,65
9,93,65
62,91,64
24,91,64
25,99,64
19,94,64
18,91,64
10,91,64
61,93,64
61,91,64
8,93,64
9,91,64
24,93,64
31,91,63
43,95,63
39,95,63
19,93,63
61,94,62
59,91,62
11,91,62
38,95,62
71,99,62
40,95,62
23,93,62
65,94,61
20,93,61
23,91,61
79,99,61
10,99,61
20,94,61
29,95,60
71,95,60
19,91,60
70,95,60
17,95,60
65,95,60
25,95,60
61,95,60
22,95,60
10,95,60
59,95,60
62,93,59
17,93,59
92,90,59
70,94,58
20,91,58
15,52,58
28,91,58
65,91,57
17,91,57
62,99,57
18,99,57
65,93,55
70,99,55
69,95,55
11,95,53
8,99,52
68,95,52
97,95,50
9,99,49
30,95,49
74,95,49
26,95,49
19,99,49
73,95,49
37,95,48
16,95,48
13,95,48
12,95,48
49,53,45
23,90,45
52,53,45
65,90,40
18,92,40
25,41,40
28,92,39
46,53,39
44,53,39
48,53,39
11,92,39
59,92,39
60,90,39
71,42,39
31,92,39
62,92,38
66,99,38
70,92,38
18,41,38
17,92,38
23,42,38
64,42,38
15,42,38
31,42,38
9,92,38
24,99,38
65,92,38
25,90,37
65,43,37
67,90,37
71,90,37
23,92,37
65,41,37
67,42,37
20,92,37
20,42,37
24,92,37
45,53,36
71,43,36
20,90,36
50,53,36
31,41,36
60,41,36
53,53,36
10,92,36
61,92,36
25,40,36
19,92,36
67,41,36
8,92,36
22,43,35
25,43,35
9,90,35
7,39,35
22,90,35
20,41,35
18,42,35
61,90,35
71,39,34
71,41,34
7,40,34
23,41,34
66,92,34
22,42,34
60,42,34
25,38,33
55,53,33
25,42,33
65,39,33
54,53,33
65,38,33
22,41,33
66,90,33
47,53,33
51,53,33
65,42,33
7,43,33
22,39,33
64,41,33
7,38,32
36,41,32
15,99,32
18,90,32
15,41,32
65,40,32
59,90,31
18,43,31
18,40,31
17,90,31
71,40,31
8,90,31
19,90,30
11,90,30
28,90,30
24,90,30
90,90,30
62,90,30
22,38,30
71,38,29
10,90,29
22,40,28
63,99,28
68,90,28
25,39,27
18,38,26
67,99,25
64,39,24
18,39,24
31,90,24
15,90,23
72,99,22
60,43,21
99,99,20
20,99,18
23,99,18
64,38,17
38,99,17
60,39,17
23,43,17
60,99,16
64,43,15
20,39,15
31,52,14
67,39,14
43,99,13
60,40,13
99,53,12
64,90,12
23,40,12
20,43,12
27,90,12
64,40,11
60,38,11
27,43,11
40,99,10
31,55,10
39,99,10
15,43,10
27,40,10
23,38,9
20,40,9
20,38,9
95,53,9
23,39,8
33,95,7
69,99,7
90,53,6
15,40,6
61,99,6
67,43,6
31,99,5
15,38,5
15,39,4
99,95,4
27,39,4
67,40,4
67,38,4
33,38,3
13,99,2
27,99,2
35,95,2
32,95,1
11,99,1
32,43,1
68,99,1
34,95,1
73,99,1
1 up_id_product down_id_product count
2 2.1.3.7 46 2.1.3 52 7 8413
3 1.3.1.3 48 1.3.1 52 5 8375
4 2.1.3.4 48 2.1.3 55 4 8345
5 2.1.3.2 46 2.1.3 55 3 8328
6 1.3.3.3 45 1.3.3 52 3 8274
7 1.1.1 44 1.1 52 2 8248
8 1.3.4.2 49 1.3.4 52 2 8246
9 2.1.1.5 49 2.1.1 55 2 8197
10 1.3.4.3 44 1.3.4 55 2 8172
11 2.3.1 45 2.3 55 2 8151
12 1.3.1.5 47 1.3.1 52 2 8077
13 1.3.3.4 47 1.3.3 55 1 8016
14 1.1.3 55 1.1 99 1 7248
15 1.4.5.6 52 1.4.5 99 1 7163
16 2.1.1.4 50 2.1.1 99 1 7085
17 1.3.1.7 54 1.3.1 99 1 7066
18 2.1.2.2 51 2.1.2 99 1 7031
19 1.3.1.4 53 1.3.1 99 1 7010
20 1.3.1.1 54 1.3.1 55 1 5570
21 2.1.4.1.1 54 2.1.4.1 52 1 5539
22 2.2 53 2 55 1 5524
23 1.4.3.4 52 1.4.3 55 1 5462
24 51 55 5441
25 50 55 5440
26 53 52 5438
27 55 52 5379
28 51 52 5312
29 50 52 5296
30 55 55 5254
31 52 52 5177
32 45 99 5036
33 46 99 4997
34 48 99 4976
35 44 99 4960
36 49 99 4941
37 55 95 4906
38 52 95 4895
39 47 99 4812
40 53 95 4643
41 51 95 4628
42 50 95 4578
43 54 95 4539
44 95 99 3147
45 47 95 3060
46 44 95 3028
47 46 95 3026
48 48 95 3021
49 49 95 3013
50 45 95 2937
51 46 43 2771
52 48 43 2748
53 45 43 2740
54 49 43 2738
55 44 43 2721
56 47 43 2720
57 49 39 2461
58 45 39 2460
59 48 39 2452
60 44 39 2427
61 46 39 2409
62 47 39 2378
63 54 43 2375
64 53 43 2366
65 55 43 2364
66 50 43 2338
67 52 43 2328
68 51 43 2327
69 44 40 2305
70 45 40 2296
71 48 40 2289
72 46 40 2287
73 49 40 2265
74 47 40 2257
75 47 38 2240
76 49 38 2224
77 45 38 2214
78 46 38 2200
79 54 39 2195
80 53 39 2184
81 48 38 2183
82 55 39 2177
83 51 39 2162
84 50 39 2156
85 44 38 2154
86 52 39 2147
87 48 90 2100
88 49 90 2092
89 45 90 2088
90 46 90 2077
91 47 90 2062
92 44 90 2054
93 94 99 2051
94 93 99 2019
95 91 99 1996
96 54 40 1977
97 50 40 1976
98 53 40 1973
99 55 40 1966
100 51 40 1964
101 52 40 1937
102 54 38 1928
103 50 38 1910
104 51 38 1900
105 53 38 1893
106 55 38 1888
107 52 38 1883
108 42 55 1788
109 41 52 1779
110 95 55 1734
111 95 52 1729
112 42 52 1717
113 41 55 1699
114 53 90 1629
115 55 90 1628
116 54 90 1623
117 51 90 1619
118 52 90 1606
119 50 90 1597
120 94 52 1207
121 92 99 1179
122 94 55 1143
123 94 95 1124
124 91 52 1084
125 93 55 1073
126 93 52 1065
127 91 55 1057
128 93 95 1005
129 91 95 1005
130 90 99 997
131 95 95 798
132 41 99 778
133 42 99 765
134 92 95 670
135 92 55 644
136 92 52 625
137 95 43 563
138 95 39 543
139 90 95 523
140 95 40 495
141 42 95 464
142 95 38 453
143 41 95 441
144 90 52 419
145 95 90 407
146 41 43 403
147 20 55 402
148 42 43 394
149 90 55 390
150 20 52 384
151 41 39 381
152 42 39 376
153 41 40 345
154 41 38 341
155 7 95 340
156 42 40 334
157 42 38 332
158 60 55 318
159 60 52 316
160 64 55 308
161 67 55 300
162 42 90 299
163 23 52 299
164 25 52 297
165 65 55 296
166 23 55 296
167 71 55 296
168 65 52 295
169 25 55 294
170 64 52 292
171 67 52 290
172 22 52 288
173 22 55 287
174 41 90 284
175 71 52 282
176 18 52 259
177 15 48 258
178 27 49 255
179 18 46 252
180 28 51 250
181 27 47 250
182 68 55 250
183 29 55 250
184 63 55 250
185 72 51 249
186 41 53 249
187 43 53 249
188 38 53 249
189 69 55 249
190 23 49 249
191 42 53 249
192 39 53 249
193 23 45 248
194 69 52 248
195 68 52 248
196 94 43 248
197 20 44 248
198 65 45 248
199 40 51 247
200 41 51 247
201 38 51 247
202 39 51 247
203 71 54 247
204 15 46 247
205 63 50 247
206 43 51 247
207 42 51 247
208 71 51 246
209 62 53 246
210 25 44 246
211 39 55 246
212 72 50 246
213 67 48 246
214 40 53 246
215 43 55 246
216 68 51 246
217 40 55 246
218 38 55 246
219 18 44 246
220 69 51 246
221 23 50 246
222 65 46 246
223 20 48 246
224 67 49 245
225 72 54 245
226 22 50 245
227 33 47 245
228 62 51 244
229 68 54 244
230 64 46 244
231 23 44 244
232 67 51 244
233 18 48 244
234 23 47 244
235 69 53 244
236 19 52 243
237 65 47 243
238 60 45 243
239 65 54 243
240 67 44 243
241 28 52 243
242 67 54 243
243 60 54 243
244 71 49 243
245 20 46 243
246 19 51 242
247 20 54 242
248 63 53 242
249 65 48 242
250 62 52 242
251 64 54 242
252 25 49 242
253 71 45 242
254 27 46 242
255 69 50 241
256 27 55 241
257 67 46 241
258 64 50 241
259 64 45 241
260 18 45 241
261 60 44 241
262 20 49 241
263 19 55 241
264 19 54 241
265 63 52 241
266 60 48 240
267 25 53 240
268 25 50 240
269 15 49 240
270 28 54 240
271 72 55 240
272 60 49 240
273 27 48 240
274 20 53 240
275 19 50 240
276 23 46 240
277 40 52 239
278 60 53 239
279 38 52 239
280 67 47 239
281 39 52 239
282 35 49 239
283 68 50 239
284 64 53 239
285 43 52 239
286 22 53 239
287 20 47 238
288 25 51 238
289 65 53 238
290 15 44 238
291 18 49 238
292 60 47 238
293 28 53 238
294 27 51 238
295 29 50 238
296 27 53 238
297 29 53 238
298 68 53 237
299 67 53 237
300 23 48 237
301 67 50 237
302 34 48 237
303 72 52 237
304 32 46 237
305 27 50 237
306 63 51 236
307 19 53 236
308 23 54 236
309 71 48 236
310 25 45 236
311 15 47 236
312 22 48 236
313 20 50 236
314 27 44 236
315 22 46 235
316 20 51 235
317 38 50 235
318 41 50 235
319 39 50 235
320 64 51 235
321 22 44 235
322 67 45 235
323 40 50 235
324 42 50 235
325 28 50 235
326 27 54 235
327 27 52 235
328 43 50 235
329 60 50 234
330 18 55 234
331 25 47 234
332 25 48 234
333 65 49 234
334 62 54 233
335 64 49 233
336 62 55 233
337 71 46 233
338 65 50 233
339 72 53 233
340 22 47 233
341 22 45 233
342 29 51 233
343 15 45 232
344 65 44 232
345 22 49 232
346 18 47 232
347 64 48 232
348 71 53 232
349 23 53 231
350 27 45 231
351 20 45 231
352 63 54 231
353 28 55 231
354 22 54 231
355 22 51 230
356 71 47 230
357 60 51 230
358 60 46 230
359 62 50 230
360 25 46 229
361 25 54 229
362 29 54 228
363 50 45 227
364 23 51 227
365 48 45 227
366 49 45 227
367 55 45 227
368 51 45 227
369 54 45 227
370 52 45 227
371 7 45 227
372 53 45 227
373 47 45 227
374 65 51 227
375 71 44 227
376 64 44 227
377 45 45 227
378 46 45 227
379 44 45 227
380 46 44 226
381 7 44 226
382 51 44 226
383 45 44 226
384 50 44 226
385 55 44 226
386 47 44 226
387 48 44 226
388 44 44 226
389 49 44 226
390 53 44 226
391 54 44 226
392 52 44 226
393 69 54 225
394 29 52 224
395 64 47 224
396 39 54 222
397 41 54 222
398 38 54 222
399 42 54 222
400 43 54 222
401 40 54 222
402 71 50 221
403 91 40 208
404 93 43 208
405 91 43 204
406 93 39 199
407 93 40 198
408 94 40 190
409 91 39 189
410 94 38 184
411 93 38 182
412 91 38 182
413 94 39 181
414 90 43 158
415 90 39 130
416 90 38 130
417 92 43 130
418 90 40 127
419 91 90 124
420 94 90 120
421 93 90 120
422 20 95 118
423 23 95 113
424 92 40 109
425 92 39 107
426 92 38 107
427 15 95 97
428 19 95 90
429 62 95 90
430 28 95 90
431 9 95 88
432 18 95 88
433 7 90 86
434 64 95 86
435 66 95 83
436 60 95 79
437 24 95 79
438 72 95 78
439 22 99 74
440 31 95 73
441 8 95 73
442 17 94 72
443 28 94 71
444 67 95 71
445 27 95 70
446 17 99 70
447 66 91 69
448 63 95 69
449 9 94 69
450 18 94 69
451 28 99 69
452 59 94 69
453 24 94 68
454 31 93 68
455 65 99 68
456 11 94 68
457 29 99 68
458 23 94 68
459 66 93 67
460 70 91 67
461 28 93 67
462 10 93 67
463 8 91 67
464 70 93 67
465 15 55 66
466 10 94 66
467 66 94 66
468 64 99 66
469 59 93 66
470 31 94 66
471 18 93 65
472 62 94 65
473 11 93 65
474 8 94 65
475 59 99 65
476 9 93 65
477 62 91 64
478 24 91 64
479 25 99 64
480 19 94 64
481 18 91 64
482 10 91 64
483 61 93 64
484 61 91 64
485 8 93 64
486 9 91 64
487 24 93 64
488 31 91 63
489 43 95 63
490 39 95 63
491 19 93 63
492 61 94 62
493 59 91 62
494 11 91 62
495 38 95 62
496 71 99 62
497 40 95 62
498 23 93 62
499 65 94 61
500 20 93 61
501 23 91 61
502 79 99 61
503 10 99 61
504 20 94 61
505 29 95 60
506 71 95 60
507 19 91 60
508 70 95 60
509 17 95 60
510 65 95 60
511 25 95 60
512 61 95 60
513 22 95 60
514 10 95 60
515 59 95 60
516 62 93 59
517 17 93 59
518 92 90 59
519 70 94 58
520 20 91 58
521 15 52 58
522 28 91 58
523 65 91 57
524 17 91 57
525 62 99 57
526 18 99 57
527 65 93 55
528 70 99 55
529 69 95 55
530 11 95 53
531 8 99 52
532 68 95 52
533 97 95 50
534 9 99 49
535 30 95 49
536 74 95 49
537 26 95 49
538 19 99 49
539 73 95 49
540 37 95 48
541 16 95 48
542 13 95 48
543 12 95 48
544 49 53 45
545 23 90 45
546 52 53 45
547 65 90 40
548 18 92 40
549 25 41 40
550 28 92 39
551 46 53 39
552 44 53 39
553 48 53 39
554 11 92 39
555 59 92 39
556 60 90 39
557 71 42 39
558 31 92 39
559 62 92 38
560 66 99 38
561 70 92 38
562 18 41 38
563 17 92 38
564 23 42 38
565 64 42 38
566 15 42 38
567 31 42 38
568 9 92 38
569 24 99 38
570 65 92 38
571 25 90 37
572 65 43 37
573 67 90 37
574 71 90 37
575 23 92 37
576 65 41 37
577 67 42 37
578 20 92 37
579 20 42 37
580 24 92 37
581 45 53 36
582 71 43 36
583 20 90 36
584 50 53 36
585 31 41 36
586 60 41 36
587 53 53 36
588 10 92 36
589 61 92 36
590 25 40 36
591 19 92 36
592 67 41 36
593 8 92 36
594 22 43 35
595 25 43 35
596 9 90 35
597 7 39 35
598 22 90 35
599 20 41 35
600 18 42 35
601 61 90 35
602 71 39 34
603 71 41 34
604 7 40 34
605 23 41 34
606 66 92 34
607 22 42 34
608 60 42 34
609 25 38 33
610 55 53 33
611 25 42 33
612 65 39 33
613 54 53 33
614 65 38 33
615 22 41 33
616 66 90 33
617 47 53 33
618 51 53 33
619 65 42 33
620 7 43 33
621 22 39 33
622 64 41 33
623 7 38 32
624 36 41 32
625 15 99 32
626 18 90 32
627 15 41 32
628 65 40 32
629 59 90 31
630 18 43 31
631 18 40 31
632 17 90 31
633 71 40 31
634 8 90 31
635 19 90 30
636 11 90 30
637 28 90 30
638 24 90 30
639 90 90 30
640 62 90 30
641 22 38 30
642 71 38 29
643 10 90 29
644 22 40 28
645 63 99 28
646 68 90 28
647 25 39 27
648 18 38 26
649 67 99 25
650 64 39 24
651 18 39 24
652 31 90 24
653 15 90 23
654 72 99 22
655 60 43 21
656 99 99 20
657 20 99 18
658 23 99 18
659 64 38 17
660 38 99 17
661 60 39 17
662 23 43 17
663 60 99 16
664 64 43 15
665 20 39 15
666 31 52 14
667 67 39 14
668 43 99 13
669 60 40 13
670 99 53 12
671 64 90 12
672 23 40 12
673 20 43 12
674 27 90 12
675 64 40 11
676 60 38 11
677 27 43 11
678 40 99 10
679 31 55 10
680 39 99 10
681 15 43 10
682 27 40 10
683 23 38 9
684 20 40 9
685 20 38 9
686 95 53 9
687 23 39 8
688 33 95 7
689 69 99 7
690 90 53 6
691 15 40 6
692 61 99 6
693 67 43 6
694 31 99 5
695 15 38 5
696 15 39 4
697 99 95 4
698 27 39 4
699 67 40 4
700 67 38 4
701 33 38 3
702 13 99 2
703 27 99 2
704 35 95 2
705 32 95 1
706 11 99 1
707 32 43 1
708 68 99 1
709 34 95 1
710 73 99 1

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 MiB

View File

@@ -1,46 +1,175 @@
id_firm,count
126,6
85,5
100,3
80,3
79,3
99,3
57,2
74,2
13,2
97,2
94,2
93,2
108,2
45,2
68,2
53,2
106,2
73,2
75,2
58,1
124,1
77,1
117,1
81,1
84,1
98,1
115,1
49,1
50,1
159,1
131,1
135,1
14,1
142,1
148,1
149,1
21,1
119,1
22,1
23,1
25,1
26,1
31,1
41,1
36,1
653528340,4007
2348941764,3957
3215814536,3831
888395016,3750
2354145351,3619
3147511625,3346
3048263744,3326
2317245827,3230
631449822,3149
3103797386,3123
194210021,3077
2327031723,3004
301209792,2997
191912252,2804
70634828,2464
2321109759,1165
3299144127,1130
3445928818,1120
2312490120,1077
503176785,1003
930767828,467
3407754893,451
2944892892,355
3269039233,354
750610681,353
25685135,351
343012684,342
3069206426,339
448033045,329
2624175,328
2320475044,321
413274977,314
3111033905,310
2317841563,310
43407343,304
571058167,302
607512171,286
152008168,272
888356483,250
25945288,222
1452048,20
2311838590,20
3373311444,20
11807506,20
2424229017,18
4208851809,10
3271705843,10
3269940677,10
420984285,10
400488703,10
400692942,10
354897041,10
3462551351,10
3288105727,10
3312358902,10
3344297292,10
3372913783,10
3384021594,10
3445244192,10
3433628561,10
3395900897,10
453289520,10
1033972427,10
581407487,10
474279224,10
857978527,10
7299120,10
737770776,10
762985858,10
771821595,10
80158773,10
829768,10
863079,10
495782506,10
868012326,10
872394725,10
887840774,10
888478182,10
9,10
9746245,10
71271700,10
7,10
695995052,10
688155470,10
654825436,10
644292599,10
620220747,10
615763365,10
594378026,10
593312758,10
591452402,10
5849940,10
3226664625,10
561545339,10
560866402,10
549184982,10
5278074,10
3267688490,10
996174506,10
3221190269,10
2311581270,10
2316990095,10
2320102626,10
2324787028,10
2324844174,10
2326478786,10
2327979389,10
2329375731,10
2333843479,10
2337952436,10
2339684065,10
2341555098,10
2343704209,10
2347013470,10
2350418059,10
2352036411,10
2313209417,10
2310825263,10
3211956484,10
218633337,10
1128343125,10
118882692,10
1217957486,10
1307012237,10
1375606900,10
145511905,10
151606446,10
1549474227,10
15613202,10
159511306,10
1606833003,10
1679596339,10
2010673,10
203314437,10
213386023,10
24284343,10
24673506,10
25036634,10
3120341363,10
3047163873,10
3070859372,10
3072715478,10
3089095447,10
3100891962,10
3113895788,10
3122923980,10
251189644,10
11164476478,10
3133307899,10
3177507356,10
3188352290,10
3188903709,10
3195502499,10
3045721313,10
3031009366,10
3026382513,10
271860868,10
2545430247,10
26162741,10
26516263,10
3025036704,10
27075840,10
2728939,10
27731896,10
278221281,10
2820140348,10
29954548,10
3398677646,9
3127420424,9
5007015990,8
3203777710,8
2339188563,7
483081978,6
517717050,6
1 id_firm count
2 126 653528340 6 4007
3 85 2348941764 5 3957
4 100 3215814536 3 3831
5 80 888395016 3 3750
6 79 2354145351 3 3619
7 99 3147511625 3 3346
8 57 3048263744 2 3326
9 74 2317245827 2 3230
10 13 631449822 2 3149
11 97 3103797386 2 3123
12 94 194210021 2 3077
13 93 2327031723 2 3004
14 108 301209792 2 2997
15 45 191912252 2 2804
16 68 70634828 2 2464
17 53 2321109759 2 1165
18 106 3299144127 2 1130
19 73 3445928818 2 1120
20 75 2312490120 2 1077
21 58 503176785 1 1003
22 124 930767828 1 467
23 77 3407754893 1 451
24 117 2944892892 1 355
25 81 3269039233 1 354
26 84 750610681 1 353
27 98 25685135 1 351
28 115 343012684 1 342
29 49 3069206426 1 339
30 50 448033045 1 329
31 159 2624175 1 328
32 131 2320475044 1 321
33 135 413274977 1 314
34 14 3111033905 1 310
35 142 2317841563 1 310
36 148 43407343 1 304
37 149 571058167 1 302
38 21 607512171 1 286
39 119 152008168 1 272
40 22 888356483 1 250
41 23 25945288 1 222
42 25 1452048 1 20
43 26 2311838590 1 20
44 31 3373311444 1 20
45 41 11807506 1 20
46 36 2424229017 1 18
47 4208851809 10
48 3271705843 10
49 3269940677 10
50 420984285 10
51 400488703 10
52 400692942 10
53 354897041 10
54 3462551351 10
55 3288105727 10
56 3312358902 10
57 3344297292 10
58 3372913783 10
59 3384021594 10
60 3445244192 10
61 3433628561 10
62 3395900897 10
63 453289520 10
64 1033972427 10
65 581407487 10
66 474279224 10
67 857978527 10
68 7299120 10
69 737770776 10
70 762985858 10
71 771821595 10
72 80158773 10
73 829768 10
74 863079 10
75 495782506 10
76 868012326 10
77 872394725 10
78 887840774 10
79 888478182 10
80 9 10
81 9746245 10
82 71271700 10
83 7 10
84 695995052 10
85 688155470 10
86 654825436 10
87 644292599 10
88 620220747 10
89 615763365 10
90 594378026 10
91 593312758 10
92 591452402 10
93 5849940 10
94 3226664625 10
95 561545339 10
96 560866402 10
97 549184982 10
98 5278074 10
99 3267688490 10
100 996174506 10
101 3221190269 10
102 2311581270 10
103 2316990095 10
104 2320102626 10
105 2324787028 10
106 2324844174 10
107 2326478786 10
108 2327979389 10
109 2329375731 10
110 2333843479 10
111 2337952436 10
112 2339684065 10
113 2341555098 10
114 2343704209 10
115 2347013470 10
116 2350418059 10
117 2352036411 10
118 2313209417 10
119 2310825263 10
120 3211956484 10
121 218633337 10
122 1128343125 10
123 118882692 10
124 1217957486 10
125 1307012237 10
126 1375606900 10
127 145511905 10
128 151606446 10
129 1549474227 10
130 15613202 10
131 159511306 10
132 1606833003 10
133 1679596339 10
134 2010673 10
135 203314437 10
136 213386023 10
137 24284343 10
138 24673506 10
139 25036634 10
140 3120341363 10
141 3047163873 10
142 3070859372 10
143 3072715478 10
144 3089095447 10
145 3100891962 10
146 3113895788 10
147 3122923980 10
148 251189644 10
149 11164476478 10
150 3133307899 10
151 3177507356 10
152 3188352290 10
153 3188903709 10
154 3195502499 10
155 3045721313 10
156 3031009366 10
157 3026382513 10
158 271860868 10
159 2545430247 10
160 26162741 10
161 26516263 10
162 3025036704 10
163 27075840 10
164 2728939 10
165 27731896 10
166 278221281 10
167 2820140348 10
168 29954548 10
169 3398677646 9
170 3127420424 9
171 5007015990 8
172 3203777710 8
173 2339188563 7
174 483081978 6
175 517717050 6

View File

@@ -1,58 +1,370 @@
id_firm,id_product,count
126,2.1.3,4
100,1.3.1,3
85,1.3.1,3
106,2.1.3,2
68,1.3.1.3,2
73,2.1.3,2
74,2.1.3,2
75,1.3.3,2
85,2.1.1,2
80,1.3.4,2
93,1.3.1,2
94,1.1,2
108,2.1.3,2
99,1.3.1,2
53,1.4.5.6,1
57,1.3.3.3,1
57,2.3.1,1
58,1.3.4.3,1
98,2,1
97,2.1.3,1
97,1.3.3,1
77,1.3.4,1
79,2.1.3.2,1
79,2.1.3.7,1
79,2.1.4.1,1
50,1.3.1.5,1
80,2.1.1,1
81,1.3.4,1
84,2.3,1
53,1.4.3.4,1
45,2.1.4.1.1,1
49,1.3.1.4,1
45,1.3.4.2,1
115,1.1.3,1
117,2.1.1.4,1
119,1.3.1.1,1
124,2.3,1
126,1.1,1
126,2.1.1.5,1
13,2.1.3.4,1
13,2.1.3.7,1
131,2.1.1.5,1
135,2.2,1
14,1.3.3.4,1
142,1.4.3,1
148,2.1.3,1
149,2.1.2.2,1
159,2.1.2,1
21,1.3.1.3,1
22,2.1.3.7,1
23,2.3.1,1
25,1.3.1.7,1
26,2.1.3.4,1
31,1.3.3.3,1
36,1.1.1,1
41,1.4.5,1
99,1.3.3,1
2321109759,95,1155
3299144127,95,1138
3445928818,95,1123
930767828,90,468
3407754893,90,443
653528340,55,434
653528340,52,430
2348941764,55,427
2348941764,52,425
2354145351,52,421
3215814536,52,421
888395016,55,420
2354145351,55,419
888395016,52,411
3215814536,55,409
653528340,54,397
653528340,53,396
653528340,50,395
653528340,51,395
750610681,92,389
343012684,92,379
2348941764,51,379
3048263744,55,379
2354145351,53,377
3147511625,52,374
2354145351,51,372
888395016,50,371
888395016,53,371
3048263744,52,370
888395016,51,369
2348941764,53,369
2348941764,54,367
3147511625,55,367
2354145351,54,365
448033045,94,364
2354145351,50,364
2348941764,50,361
3269039233,99,361
888395016,54,358
3215814536,51,355
2944892892,99,354
2317245827,55,353
25685135,99,351
2317245827,52,350
3215814536,54,349
631449822,55,349
3069206426,93,348
3215814536,50,347
194210021,52,346
631449822,52,345
3215814536,53,344
3111033905,93,343
2327031723,52,341
191912252,55,341
70634828,52,340
3103797386,55,339
194210021,55,336
301209792,52,335
301209792,55,333
3103797386,52,332
191912252,52,330
2320475044,94,327
3147511625,53,322
3048263744,53,319
2327031723,55,318
2624175,99,318
3147511625,51,316
3048263744,51,312
3147511625,54,310
2317245827,50,308
3147511625,50,307
3048263744,50,307
571058167,94,306
2317245827,53,303
2317841563,91,303
3048263744,54,302
2317245827,54,298
631449822,51,297
194210021,53,297
413274977,91,295
3103797386,50,291
2317245827,51,291
3103797386,51,290
43407343,93,289
70634828,55,289
607512171,91,288
194210021,51,288
3103797386,53,287
194210021,50,287
194210021,54,286
631449822,53,285
653528340,48,285
152008168,94,283
653528340,49,283
653528340,46,282
631449822,50,281
3103797386,54,281
653528340,45,278
2327031723,53,277
653528340,44,276
653528340,47,276
2327031723,50,275
631449822,54,273
191912252,54,272
2327031723,51,270
301209792,54,266
2312490120,41,266
888395016,45,266
2348941764,49,266
191912252,51,264
301209792,53,263
2348941764,48,262
2348941764,46,262
2348941764,45,261
301209792,51,261
301209792,50,260
2327031723,54,259
888395016,49,259
2348941764,47,257
191912252,50,256
888395016,48,256
2348941764,44,253
888395016,46,253
2354145351,46,252
70634828,51,252
888395016,47,251
2312490120,42,250
191912252,53,248
888395016,44,248
2354145351,47,247
2354145351,49,246
2354145351,48,245
3215814536,49,241
70634828,54,239
3215814536,48,238
888356483,91,236
3215814536,46,236
70634828,50,232
3215814536,47,232
2354145351,45,231
2354145351,44,231
3215814536,44,230
3215814536,45,230
3048263744,48,230
70634828,53,229
3048263744,47,227
3048263744,46,221
3048263744,45,220
3048263744,44,217
194210021,46,217
2317245827,44,217
3048263744,49,216
3147511625,48,212
3147511625,49,212
3147511625,45,210
3147511625,44,210
2317245827,46,209
503176785,42,208
503176785,41,208
3147511625,47,206
194210021,48,206
3103797386,44,205
2317245827,47,204
194210021,44,203
2317245827,49,203
3147511625,46,202
2317245827,45,201
194210021,45,200
3103797386,49,200
631449822,45,199
194210021,49,197
191912252,49,196
3103797386,46,196
2317245827,48,196
2327031723,49,195
194210021,47,194
25945288,93,194
631449822,49,193
2327031723,48,192
301209792,46,192
70634828,49,191
191912252,46,190
191912252,44,190
2327031723,45,190
3103797386,47,190
631449822,48,189
3103797386,48,189
301209792,44,188
631449822,47,185
301209792,45,185
191912252,48,183
191912252,45,183
631449822,44,183
2327031723,46,182
503176785,43,182
3103797386,45,181
70634828,46,180
631449822,46,180
2327031723,44,180
301209792,48,177
2327031723,47,176
191912252,47,174
301209792,49,174
301209792,47,173
70634828,48,173
70634828,47,172
70634828,44,165
70634828,45,160
2312490120,40,140
2312490120,39,139
2312490120,38,135
503176785,39,128
503176785,38,122
2312490120,43,119
503176785,40,110
3133307899,23,20
3395900897,73,18
3221190269,20,17
3384021594,64,15
2820140348,62,15
1375606900,67,15
3445244192,24,15
887840774,8,15
3312358902,59,14
26516263,8,14
24284343,35,14
251189644,23,14
7,10,14
26162741,11,14
400692942,68,13
354897041,72,13
996174506,15,13
3211956484,34,13
203314437,22,13
11807506,23,13
1307012237,68,13
194210021,7,13
2010673,64,13
3373311444,20,13
688155470,30,13
2347013470,61,13
271860868,12,13
71271700,27,12
863079,11,12
420984285,16,12
644292599,11,12
9,37,12
5849940,26,12
9746245,97,12
868012326,29,12
1033972427,61,12
3373311444,71,12
3120341363,79,12
1128343125,63,12
1217957486,31,12
1452048,63,12
191912252,7,12
2311838590,97,12
2327979389,13,12
2341555098,11,12
2354145351,7,12
2728939,63,12
25036634,31,12
3271705843,62,12
3344297292,12,12
2350418059,79,11
15613202,32,11
2352036411,17,11
653528340,7,11
3269940677,28,11
278221281,66,11
2324844174,67,11
2317245827,7,11
3045721313,25,11
3070859372,62,11
771821595,10,11
615763365,68,11
1679596339,74,11
561545339,33,11
2311581270,19,11
888478182,9,11
3398677646,79,11
888395016,7,11
3195502499,18,11
1549474227,67,11
474279224,71,11
453289520,37,10
2313209417,32,10
11807506,60,10
2324787028,18,10
5278074,36,10
2327031723,7,10
3188903709,65,10
3372913783,20,10
695995052,8,10
2343704209,69,10
400488703,28,10
118882692,35,10
3047163873,27,10
3127420424,32,10
151606446,61,10
3122923980,34,10
593312758,31,10
80158773,69,10
145511905,68,10
4208851809,16,10
2311838590,34,9
2348941764,7,9
2326478786,60,9
872394725,70,9
737770776,34,9
218633337,33,9
2333843479,70,9
213386023,19,9
2337952436,24,9
1606833003,9,9
159511306,69,9
3072715478,33,9
3267688490,73,9
3026382513,15,9
3203777710,74,9
5007015990,74,9
3188352290,64,9
3177507356,24,9
620220747,15,9
3031009366,59,9
631449822,7,9
581407487,72,8
591452402,66,8
594378026,27,8
3100891962,26,8
3215814536,7,8
24673506,67,8
2339188563,37,8
29954548,27,8
2339684065,74,8
3462551351,13,8
560866402,9,7
3103797386,7,7
2320102626,18,7
3288105727,36,7
829768,23,7
2424229017,30,7
11164476478,60,7
762985858,72,7
7299120,32,7
70634828,7,7
2316990095,66,7
3025036704,17,7
3113895788,35,7
654825436,61,6
1452048,30,6
3147511625,7,6
3226664625,28,6
549184982,69,6
301209792,7,6
2545430247,25,6
2329375731,31,6
27075840,65,6
857978527,60,6
2424229017,26,6
3048263744,7,6
3433628561,29,5
517717050,36,5
495782506,19,5
483081978,36,5
27731896,20,5
3089095447,22,5
2310825263,15,4
1 id_firm id_product count
2 126 2321109759 2.1.3 95 4 1155
3 100 3299144127 1.3.1 95 3 1138
4 85 3445928818 1.3.1 95 3 1123
5 106 930767828 2.1.3 90 2 468
6 68 3407754893 1.3.1.3 90 2 443
7 73 653528340 2.1.3 55 2 434
8 74 653528340 2.1.3 52 2 430
9 75 2348941764 1.3.3 55 2 427
10 85 2348941764 2.1.1 52 2 425
11 80 2354145351 1.3.4 52 2 421
12 93 3215814536 1.3.1 52 2 421
13 94 888395016 1.1 55 2 420
14 108 2354145351 2.1.3 55 2 419
15 99 888395016 1.3.1 52 2 411
16 53 3215814536 1.4.5.6 55 1 409
17 57 653528340 1.3.3.3 54 1 397
18 57 653528340 2.3.1 53 1 396
19 58 653528340 1.3.4.3 50 1 395
20 98 653528340 2 51 1 395
21 97 750610681 2.1.3 92 1 389
22 97 343012684 1.3.3 92 1 379
23 77 2348941764 1.3.4 51 1 379
24 79 3048263744 2.1.3.2 55 1 379
25 79 2354145351 2.1.3.7 53 1 377
26 79 3147511625 2.1.4.1 52 1 374
27 50 2354145351 1.3.1.5 51 1 372
28 80 888395016 2.1.1 50 1 371
29 81 888395016 1.3.4 53 1 371
30 84 3048263744 2.3 52 1 370
31 53 888395016 1.4.3.4 51 1 369
32 45 2348941764 2.1.4.1.1 53 1 369
33 49 2348941764 1.3.1.4 54 1 367
34 45 3147511625 1.3.4.2 55 1 367
35 115 2354145351 1.1.3 54 1 365
36 117 448033045 2.1.1.4 94 1 364
37 119 2354145351 1.3.1.1 50 1 364
38 124 2348941764 2.3 50 1 361
39 126 3269039233 1.1 99 1 361
40 126 888395016 2.1.1.5 54 1 358
41 13 3215814536 2.1.3.4 51 1 355
42 13 2944892892 2.1.3.7 99 1 354
43 131 2317245827 2.1.1.5 55 1 353
44 135 25685135 2.2 99 1 351
45 14 2317245827 1.3.3.4 52 1 350
46 142 3215814536 1.4.3 54 1 349
47 148 631449822 2.1.3 55 1 349
48 149 3069206426 2.1.2.2 93 1 348
49 159 3215814536 2.1.2 50 1 347
50 21 194210021 1.3.1.3 52 1 346
51 22 631449822 2.1.3.7 52 1 345
52 23 3215814536 2.3.1 53 1 344
53 25 3111033905 1.3.1.7 93 1 343
54 26 2327031723 2.1.3.4 52 1 341
55 31 191912252 1.3.3.3 55 1 341
56 36 70634828 1.1.1 52 1 340
57 41 3103797386 1.4.5 55 1 339
58 99 194210021 1.3.3 55 1 336
59 301209792 52 335
60 301209792 55 333
61 3103797386 52 332
62 191912252 52 330
63 2320475044 94 327
64 3147511625 53 322
65 3048263744 53 319
66 2327031723 55 318
67 2624175 99 318
68 3147511625 51 316
69 3048263744 51 312
70 3147511625 54 310
71 2317245827 50 308
72 3147511625 50 307
73 3048263744 50 307
74 571058167 94 306
75 2317245827 53 303
76 2317841563 91 303
77 3048263744 54 302
78 2317245827 54 298
79 631449822 51 297
80 194210021 53 297
81 413274977 91 295
82 3103797386 50 291
83 2317245827 51 291
84 3103797386 51 290
85 43407343 93 289
86 70634828 55 289
87 607512171 91 288
88 194210021 51 288
89 3103797386 53 287
90 194210021 50 287
91 194210021 54 286
92 631449822 53 285
93 653528340 48 285
94 152008168 94 283
95 653528340 49 283
96 653528340 46 282
97 631449822 50 281
98 3103797386 54 281
99 653528340 45 278
100 2327031723 53 277
101 653528340 44 276
102 653528340 47 276
103 2327031723 50 275
104 631449822 54 273
105 191912252 54 272
106 2327031723 51 270
107 301209792 54 266
108 2312490120 41 266
109 888395016 45 266
110 2348941764 49 266
111 191912252 51 264
112 301209792 53 263
113 2348941764 48 262
114 2348941764 46 262
115 2348941764 45 261
116 301209792 51 261
117 301209792 50 260
118 2327031723 54 259
119 888395016 49 259
120 2348941764 47 257
121 191912252 50 256
122 888395016 48 256
123 2348941764 44 253
124 888395016 46 253
125 2354145351 46 252
126 70634828 51 252
127 888395016 47 251
128 2312490120 42 250
129 191912252 53 248
130 888395016 44 248
131 2354145351 47 247
132 2354145351 49 246
133 2354145351 48 245
134 3215814536 49 241
135 70634828 54 239
136 3215814536 48 238
137 888356483 91 236
138 3215814536 46 236
139 70634828 50 232
140 3215814536 47 232
141 2354145351 45 231
142 2354145351 44 231
143 3215814536 44 230
144 3215814536 45 230
145 3048263744 48 230
146 70634828 53 229
147 3048263744 47 227
148 3048263744 46 221
149 3048263744 45 220
150 3048263744 44 217
151 194210021 46 217
152 2317245827 44 217
153 3048263744 49 216
154 3147511625 48 212
155 3147511625 49 212
156 3147511625 45 210
157 3147511625 44 210
158 2317245827 46 209
159 503176785 42 208
160 503176785 41 208
161 3147511625 47 206
162 194210021 48 206
163 3103797386 44 205
164 2317245827 47 204
165 194210021 44 203
166 2317245827 49 203
167 3147511625 46 202
168 2317245827 45 201
169 194210021 45 200
170 3103797386 49 200
171 631449822 45 199
172 194210021 49 197
173 191912252 49 196
174 3103797386 46 196
175 2317245827 48 196
176 2327031723 49 195
177 194210021 47 194
178 25945288 93 194
179 631449822 49 193
180 2327031723 48 192
181 301209792 46 192
182 70634828 49 191
183 191912252 46 190
184 191912252 44 190
185 2327031723 45 190
186 3103797386 47 190
187 631449822 48 189
188 3103797386 48 189
189 301209792 44 188
190 631449822 47 185
191 301209792 45 185
192 191912252 48 183
193 191912252 45 183
194 631449822 44 183
195 2327031723 46 182
196 503176785 43 182
197 3103797386 45 181
198 70634828 46 180
199 631449822 46 180
200 2327031723 44 180
201 301209792 48 177
202 2327031723 47 176
203 191912252 47 174
204 301209792 49 174
205 301209792 47 173
206 70634828 48 173
207 70634828 47 172
208 70634828 44 165
209 70634828 45 160
210 2312490120 40 140
211 2312490120 39 139
212 2312490120 38 135
213 503176785 39 128
214 503176785 38 122
215 2312490120 43 119
216 503176785 40 110
217 3133307899 23 20
218 3395900897 73 18
219 3221190269 20 17
220 3384021594 64 15
221 2820140348 62 15
222 1375606900 67 15
223 3445244192 24 15
224 887840774 8 15
225 3312358902 59 14
226 26516263 8 14
227 24284343 35 14
228 251189644 23 14
229 7 10 14
230 26162741 11 14
231 400692942 68 13
232 354897041 72 13
233 996174506 15 13
234 3211956484 34 13
235 203314437 22 13
236 11807506 23 13
237 1307012237 68 13
238 194210021 7 13
239 2010673 64 13
240 3373311444 20 13
241 688155470 30 13
242 2347013470 61 13
243 271860868 12 13
244 71271700 27 12
245 863079 11 12
246 420984285 16 12
247 644292599 11 12
248 9 37 12
249 5849940 26 12
250 9746245 97 12
251 868012326 29 12
252 1033972427 61 12
253 3373311444 71 12
254 3120341363 79 12
255 1128343125 63 12
256 1217957486 31 12
257 1452048 63 12
258 191912252 7 12
259 2311838590 97 12
260 2327979389 13 12
261 2341555098 11 12
262 2354145351 7 12
263 2728939 63 12
264 25036634 31 12
265 3271705843 62 12
266 3344297292 12 12
267 2350418059 79 11
268 15613202 32 11
269 2352036411 17 11
270 653528340 7 11
271 3269940677 28 11
272 278221281 66 11
273 2324844174 67 11
274 2317245827 7 11
275 3045721313 25 11
276 3070859372 62 11
277 771821595 10 11
278 615763365 68 11
279 1679596339 74 11
280 561545339 33 11
281 2311581270 19 11
282 888478182 9 11
283 3398677646 79 11
284 888395016 7 11
285 3195502499 18 11
286 1549474227 67 11
287 474279224 71 11
288 453289520 37 10
289 2313209417 32 10
290 11807506 60 10
291 2324787028 18 10
292 5278074 36 10
293 2327031723 7 10
294 3188903709 65 10
295 3372913783 20 10
296 695995052 8 10
297 2343704209 69 10
298 400488703 28 10
299 118882692 35 10
300 3047163873 27 10
301 3127420424 32 10
302 151606446 61 10
303 3122923980 34 10
304 593312758 31 10
305 80158773 69 10
306 145511905 68 10
307 4208851809 16 10
308 2311838590 34 9
309 2348941764 7 9
310 2326478786 60 9
311 872394725 70 9
312 737770776 34 9
313 218633337 33 9
314 2333843479 70 9
315 213386023 19 9
316 2337952436 24 9
317 1606833003 9 9
318 159511306 69 9
319 3072715478 33 9
320 3267688490 73 9
321 3026382513 15 9
322 3203777710 74 9
323 5007015990 74 9
324 3188352290 64 9
325 3177507356 24 9
326 620220747 15 9
327 3031009366 59 9
328 631449822 7 9
329 581407487 72 8
330 591452402 66 8
331 594378026 27 8
332 3100891962 26 8
333 3215814536 7 8
334 24673506 67 8
335 2339188563 37 8
336 29954548 27 8
337 2339684065 74 8
338 3462551351 13 8
339 560866402 9 7
340 3103797386 7 7
341 2320102626 18 7
342 3288105727 36 7
343 829768 23 7
344 2424229017 30 7
345 11164476478 60 7
346 762985858 72 7
347 7299120 32 7
348 70634828 7 7
349 2316990095 66 7
350 3025036704 17 7
351 3113895788 35 7
352 654825436 61 6
353 1452048 30 6
354 3147511625 7 6
355 3226664625 28 6
356 549184982 69 6
357 301209792 7 6
358 2545430247 25 6
359 2329375731 31 6
360 27075840 65 6
361 857978527 60 6
362 2424229017 26 6
363 3048263744 7 6
364 3433628561 29 5
365 517717050 36 5
366 495782506 19 5
367 483081978 36 5
368 27731896 20 5
369 3089095447 22 5
370 2310825263 15 4

View File

@@ -1,35 +1,73 @@
id_product,count
2.1.3,14
1.3.1,10
1.3.4,4
1.3.3,4
1.1,3
2.1.3.7,3
1.3.1.3,3
2.1.1,3
2.3,2
2.1.3.4,2
2.1.1.5,2
2.3.1,2
1.3.3.3,2
1.3.3.4,1
2.1.2.2,1
1.1.3,1
2.2,1
2.1.4.1.1,1
2.1.4.1,1
1.3.1.1,1
1.3.1.4,1
2.1.3.2,1
1.3.1.5,1
2.1.2,1
1.3.4.2,1
1.3.1.7,1
2.1.1.4,1
2,1
1.4.5.6,1
1.1.1,1
1.4.3.4,1
1.4.3,1
1.3.4.3,1
1.4.5,1
52,5571
55,5513
51,4711
53,4687
50,4642
54,4622
95,3416
49,3272
46,3254
48,3233
44,3196
45,3195
47,3164
99,1384
94,1280
93,1174
91,1122
90,911
92,768
41,474
42,458
43,301
39,267
38,257
40,250
7,138
23,54
11,50
68,47
20,45
67,45
34,41
61,41
31,40
8,39
62,38
32,38
27,38
74,37
64,37
63,36
15,35
69,35
79,34
24,33
60,32
35,31
37,30
33,29
72,28
18,28
9,27
73,27
36,27
28,27
66,26
30,26
26,26
12,25
10,25
19,25
97,24
71,23
59,23
16,22
13,20
70,18
17,18
22,18
25,17
29,17
65,16
1 id_product count
2 2.1.3 52 14 5571
3 1.3.1 55 10 5513
4 1.3.4 51 4 4711
5 1.3.3 53 4 4687
6 1.1 50 3 4642
7 2.1.3.7 54 3 4622
8 1.3.1.3 95 3 3416
9 2.1.1 49 3 3272
10 2.3 46 2 3254
11 2.1.3.4 48 2 3233
12 2.1.1.5 44 2 3196
13 2.3.1 45 2 3195
14 1.3.3.3 47 2 3164
15 1.3.3.4 99 1 1384
16 2.1.2.2 94 1 1280
17 1.1.3 93 1 1174
18 2.2 91 1 1122
19 2.1.4.1.1 90 1 911
20 2.1.4.1 92 1 768
21 1.3.1.1 41 1 474
22 1.3.1.4 42 1 458
23 2.1.3.2 43 1 301
24 1.3.1.5 39 1 267
25 2.1.2 38 1 257
26 1.3.4.2 40 1 250
27 1.3.1.7 7 1 138
28 2.1.1.4 23 1 54
29 2 11 1 50
30 1.4.5.6 68 1 47
31 1.1.1 20 1 45
32 1.4.3.4 67 1 45
33 1.4.3 34 1 41
34 1.3.4.3 61 1 41
35 1.4.5 31 1 40
36 8 39
37 62 38
38 32 38
39 27 38
40 74 37
41 64 37
42 63 36
43 15 35
44 69 35
45 79 34
46 24 33
47 60 32
48 35 31
49 37 30
50 33 29
51 72 28
52 18 28
53 9 27
54 73 27
55 36 27
56 28 27
57 66 26
58 30 26
59 26 26
60 12 25
61 10 25
62 19 25
63 97 24
64 71 23
65 59 23
66 16 22
67 13 20
68 70 18
69 17 18
70 22 18
71 25 17
72 29 17
73 65 16

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 5.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 5.9 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 MiB

After

Width:  |  Height:  |  Size: 13 MiB

View File

@@ -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:

View File

@@ -1,5 +1,5 @@
agentpy==0.1.5
matplotlib==3.3.4
matplotlib==3.7.5
matplotlib-inline==0.1.6
networkx==2.5
numpy==1.20.3

View File

@@ -13,8 +13,7 @@ count_dcp = pd.read_csv("output_result/risk/count_dcp.csv",
'up_id_firm': str,
'down_id_firm': str
})
# print(count_dcp)
count_dcp = count_dcp[count_dcp['count'] > 35]
count_dcp = count_dcp[count_dcp['count'] > 130]
list_firm = count_dcp['up_id_firm'].tolist(
) + count_dcp['down_id_firm'].tolist()
@@ -24,7 +23,7 @@ list_firm = list(set(list_firm))
Firm = pd.read_csv("input_data/input_firm_data/Firm_amended.csv")
Firm['Code'] = Firm['Code'].astype('string')
Firm.fillna(0, inplace=True)
Firm_attr = Firm.loc[:, ["Code", "Type_Region", "Revenue_Log"]]
Firm_attr = Firm.loc[:, ["Code", "企业名称", "Type_Region", "Revenue_Log"]]
firm_industry_relation = pd.read_csv("input_data/firm_industry_relation.csv")
firm_industry_relation['Firm_Code'] = firm_industry_relation['Firm_Code'].astype('string')
firm_product = []
@@ -43,7 +42,7 @@ nx.set_node_attributes(G_firm, firm_labels_dict)
count_max = count_dcp['count'].max()
count_min = count_dcp['count'].min()
k = 5 / (count_max - count_min)
k = 15 / (count_max - count_min)
for _, row in count_dcp.iterrows():
# print(row)
lst_add_edge = [(
@@ -54,20 +53,43 @@ for _, row in count_dcp.iterrows():
'down_id_product': row['down_id_product'],
'edge_label': f"{row['up_id_product']} - {row['down_id_product']}",
'edge_width': k * (row['count'] - count_min),
'count': row['count']
'count': (row['count'])*18
})]
G_firm.add_edges_from(lst_add_edge)
# dcp_networkx
pos = nx.nx_agraph.graphviz_layout(G_firm, prog="dot", args="")
node_label = nx.get_node_attributes(G_firm, 'Revenue_Log')
pos = nx.nx_agraph.graphviz_layout(G_firm, prog="twopi", args="")
node_label = nx.get_node_attributes(G_firm, '企业名称')
# desensitize
node_label = {key: f"{key} " for key, value in node_label.items()}
node_label = {
key: key
for key in node_label.keys()
'343012684': '59',
'2944892892': '165',
'3269039233': '194',
'503176785': '73',
'3111033905': '178',
'3215814536': '190',
'413274977': '64',
'2317841563': '131',
'2354145351': '157',
'653528340': '88',
'888395016': '104',
'3069206426': '174',
'3299144127': '197',
'2624175': '8',
'25685135': '24',
'2348941764': '151',
'750610681': '95',
'2320475044': '133',
'571058167': '78',
'152008168': '44',
'448033045': '66',
'2321109759': '134',
'3445928818': '213'
}
node_size = list(nx.get_node_attributes(G_firm, 'Revenue_Log').values())
node_size = list(map(lambda x: x**2, node_size))
node_size = list(map(lambda x: x * 10, node_size))
edge_label = nx.get_edge_attributes(G_firm, "edge_label")
edge_label = {(n1, n2): label for (n1, n2, _), label in edge_label.items()}
edge_width = nx.get_edge_attributes(G_firm, "edge_width")
@@ -77,23 +99,30 @@ colors = [w for (n1, n2, _), w in colors.items()]
vmin = min(colors)
vmax = max(colors)
cmap = plt.cm.Blues
fig = plt.figure(figsize=(10, 8), dpi=300)
fig = plt.figure(figsize=(10, 8), dpi=500)
nx.draw(G_firm,
pos,
node_size=node_size,
labels=node_label,
font_size=8,
width=3,
width=2,
edge_color=colors,
edge_cmap=cmap,
edge_vmin=vmin,
edge_vmax=vmax)
nx.draw_networkx_edge_labels(G_firm, pos, edge_label, font_size=6)
# nx.draw_networkx_edge_labels(G_firm, pos, font_size=6)
nx.draw_networkx_edge_labels(
G_firm,
pos,
edge_labels=edge_label,
font_size=5
)
sm = plt.cm.ScalarMappable(cmap=cmap, norm=plt.Normalize(vmin=vmin, vmax=vmax))
sm._A = []
position = fig.add_axes([0.95, 0.05, 0.01, 0.3])
cb = plt.colorbar(sm, fraction=0.01, cax=position)
cb.ax.tick_params(labelsize=10)
cb.ax.tick_params(labelsize=4)
cb.outline.set_visible(False)
plt.savefig("output_result\\risk\\count_dcp_network")
plt.close()

View File

@@ -11,53 +11,82 @@ print(count_prod)
print(count_prod.describe())
# prod_networkx
BomNodes = pd.read_csv('input_data/input_product_data/BomNodes.csv', index_col=0)
BomNodes.set_index('Code', inplace=True)
BomCateNet = pd.read_csv('input_data/input_product_data/BomCateNet.csv', index_col=0)
BomCateNet.fillna(0, inplace=True)
# BomNodes = pd.read_csv('input_data/input_product_data/BomNodes.csv', index_col=0)
# BomNodes.set_index('Code', inplace=True)
# BomCateNet = pd.read_csv('input_data/input_product_data/BomCateNet.csv', index_col=0)
# BomCateNet.fillna(0, inplace=True)
G = nx.from_pandas_adjacency(BomCateNet.T, create_using=nx.MultiDiGraph())
bom_nodes = pd.read_csv('input_data/input_product_data/BomNodes.csv')
bom_nodes['Code'] = bom_nodes['Code'].astype(str)
bom_nodes.set_index('Index', inplace=True)
bom_cate_net = pd.read_csv('input_data/input_product_data/合成结点.csv')
g_bom = nx.from_pandas_edgelist(bom_cate_net, source='UPID', target='ID', create_using=nx.MultiDiGraph())
labels_dict = {}
for code in G.nodes:
node_attr = BomNodes.loc[code].to_dict()
for code in g_bom.nodes:
node_attr = bom_nodes.loc[code].to_dict()
index_list = count_prod[count_prod['id_product'] == code].index.tolist()
index = index_list[0] if len(index_list) == 1 else -1
node_attr['count'] = count_prod['count'].get(index, 0)
node_attr['node_size'] = count_prod['count'].get(index, 0)
node_attr['node_size'] = (count_prod['count'].get(index, 0))/10
node_attr['node_color'] = count_prod['count'].get(index, 0)
labels_dict[code] = node_attr
nx.set_node_attributes(G, labels_dict)
nx.set_node_attributes(g_bom, labels_dict)
# print(labels_dict)
pos = nx.nx_agraph.graphviz_layout(G, prog="twopi", args="")
dict_node_name = nx.get_node_attributes(G, 'Name')
pos = nx.nx_agraph.graphviz_layout(g_bom, prog="twopi", args="")
dict_node_name = nx.get_node_attributes(g_bom, 'Name')
node_labels = {}
for node in nx.nodes(G):
for node in nx.nodes(g_bom):
node_labels[node] = f"{node} {str(dict_node_name[node])}"
# node_labels[node] = f"{str(dict_node_name[node])}"
colors = list(nx.get_node_attributes(G, 'node_color').values())
colors = list(nx.get_node_attributes(g_bom, 'node_color').values())
vmin = min(colors)
vmax = max(colors)
cmap = plt.cm.Blues
# 创建绘图对象
fig = plt.figure(figsize=(10, 10), dpi=300)
nx.draw(G,
pos,
node_size=list(nx.get_node_attributes(G, 'node_size').values()),
ax = fig.add_subplot(111)
# 绘制网络图(优化样式参数)
nx.draw(g_bom, pos,
node_size=list(nx.get_node_attributes(g_bom, 'node_size').values()),
labels=node_labels,
font_size=6,
font_size=3,
node_color=colors,
cmap=cmap,
vmin=vmin,
vmax=vmax,
edge_color='grey')
edge_color='#808080', # 中性灰
width=0.3,
edgecolors='#404040',
linewidths=0.2)
# 创建颜色条(修正实现方式)
sm = plt.cm.ScalarMappable(cmap=cmap, norm=plt.Normalize(vmin=vmin, vmax=vmax))
sm._A = []
position = fig.add_axes([0.01, 0.05, 0.01, 0.3])
cb = plt.colorbar(sm, fraction=0.01, cax=position)
cb.ax.tick_params(labelsize=8)
cb.outline.set_visible(False)
plt.savefig("output_result\\risk\\count_prod_network")
sm.set_array([])
# 设置颜色条位置和样式
cax = fig.add_axes([0.88, 0.3, 0.015, 0.4]) # 右侧垂直对齐
cb = plt.colorbar(sm, cax=cax)
cb.ax.tick_params(labelsize=4, width=0.5, colors='#333333')
cb.outline.set_linewidth(0.5)
cb.set_label('Risk Level', fontsize=5, labelpad=2)
# 添加图元信息
ax.set_title("Production Risk Network", fontsize=6, pad=8, color='#2F2F2F')
plt.text(0.5, 0.02, 'Data: USTB Production System | Viz: DeepSeek-R1',
ha='center', fontsize=3, color='#666666',
transform=fig.transFigure)
# 调整边界和保存
plt.subplots_adjust(left=0.05, right=0.85, top=0.95, bottom=0.1) # 适应颜色条
plt.savefig(r"output_result/risk/count_prod_network.png", # 规范路径格式
dpi=600,
bbox_inches='tight',
pad_inches=0.05,
transparent=False)
plt.close()
# dcp_prod
@@ -74,7 +103,7 @@ count_dcp_prod.sort_values('count', inplace=True, ascending=False)
count_dcp_prod.to_csv('output_result\\risk\\count_dcp_prod.csv',
index=False,
encoding='utf-8-sig')
count_dcp_prod = count_dcp_prod[count_dcp_prod['count'] > 50]
count_dcp_prod = count_dcp_prod[count_dcp_prod['count'] > 1000]
# print(count_dcp_prod)
list_prod = count_dcp_prod['up_id_product'].tolist(
@@ -83,8 +112,8 @@ list_prod = list(set(list_prod))
# init graph bom
BomNodes = pd.read_csv('input_data/input_product_data/BomNodes.csv', index_col=0)
BomNodes.set_index('Code', inplace=True)
BomNodes = pd.read_csv('input_data/input_product_data/BomNodes.csv')
BomNodes.set_index('Index', inplace=True)
g_bom = nx.MultiDiGraph()
g_bom.add_nodes_from(list_prod)
@@ -95,7 +124,6 @@ for code in list_prod:
bom_labels_dict[code] = dct_attr
nx.set_node_attributes(g_bom, bom_labels_dict)
count_max = count_dcp_prod['count'].max()
count_min = count_dcp_prod['count'].min()
k = 5 / (count_max - count_min)
@@ -110,28 +138,55 @@ for _, row in count_dcp_prod.iterrows():
g_bom.add_edges_from(lst_add_edge)
# dcp_networkx
pos = nx.nx_agraph.graphviz_layout(g_bom, prog="dot", args="")
pos = nx.nx_agraph.graphviz_layout(g_bom, prog="twopi", args="")
node_labels = nx.get_node_attributes(g_bom, 'Name')
# rename node 1
# node_labels['1'] = '解决方案'
temp = {}
for key, value in node_labels.items():
temp[key] = key + " " + value
temp[key] = str(key) + " " + value
node_labels = temp
node_labels ={
38: 'SiC Substrate',
39: 'GaN Substrate',
40: 'Si Substrate',
41: 'AlN Substrate',
42: 'DUV LED Substrate',
43: 'InP Substrate',
44: 'Mono-Si Wafer',
45: 'Poly-Si Wafer',
46: 'InP Cryst./Wafer',
47: 'SiC Cryst./Wafer',
48: 'GaAs Wafer',
49: 'GaN Cryst./Wafer',
50: 'Si Epi Wafer',
51: 'SiC Epi Wafer',
52: 'AlN Epi',
53: 'GaN Epi',
54: 'InP Epi',
55: 'LED Epi Wafer',
90: 'Power Devices',
91: 'Diode',
92: 'Transistor',
93: 'Thyristor',
94: 'Rectifier',
95: 'IC Fab',
99: 'Wafer Test'
}
colors = nx.get_edge_attributes(g_bom, "count")
colors = [w for (n1, n2, _), w in colors.items()]
vmin = min(colors)
vmax = max(colors)
cmap = plt.cm.Blues
pos_new = {}
for node, p in pos.items():
pos_new[node] = (p[1], p[0])
pos_new = {node: (p[1], p[0]) for node, p in pos.items()} # 字典推导式优化
fig = plt.figure(figsize=(6, 10), dpi=300)
# plt.subplots_adjust(right=0.7)
nx.draw(g_bom,
pos_new,
fig = plt.figure(figsize=(8, 8), dpi=300)
plt.subplots_adjust(right=0.85) # 关键调整右侧保留15%空白
# 使用Axes对象精准控制
main_ax = fig.add_axes([0.1, 0.1, 0.75, 0.8]) # 主图占左75%宽上下各留10%边距
nx.draw(g_bom, pos_new,
ax=main_ax,
node_size=50,
labels=node_labels,
font_size=5,
@@ -139,17 +194,30 @@ nx.draw(g_bom,
edge_color=colors,
edge_cmap=cmap,
edge_vmin=vmin,
edge_vmax=vmax)
plt.axis('off')
axis = plt.gca()
axis.set_xlim([1.2*x for x in axis.get_xlim()])
axis.set_ylim([1.2*y for y in axis.get_ylim()])
edge_vmax=vmax,
)
main_ax.axis('off')
# 颜色条定位系统
cbar_ax = fig.add_axes([0.86, 0.15, 0.015, 0.3]) # 右边缘86%位置底部15%起占30%高度
sm = plt.cm.ScalarMappable(cmap=cmap, norm=plt.Normalize(vmin=vmin, vmax=vmax))
sm._A = []
position = fig.add_axes([0.75, 0.1, 0.01, 0.2])
cb = plt.colorbar(sm, fraction=0.01, cax=position)
cb.ax.tick_params(labelsize=8)
cb.outline.set_visible(False)
plt.savefig("output_result\\risk\\count_dcp_prod_network")
sm._A = [] # 必需的空数组
# 微调颜色条样式
cbar = fig.colorbar(sm, cax=cbar_ax, orientation='vertical')
cbar.ax.tick_params(labelsize=4,
width=0.3, # 刻度线粗细
length=1.5, # 刻度线长度
pad=0.8) # 标签与条间距
cbar.outline.set_linewidth(0.5) # 边框线宽
# 输出前验证边界
print(f"Colorbar position: {cbar_ax.get_position().bounds}") # 应输出(0.86,0.15,0.015,0.3)
# 专业级保存参数
plt.savefig("output_result/risk/count_dcp_prod_network.png",
dpi=900,
bbox_inches='tight', # 自动裁剪白边
pad_inches=0.05, # 保留0.05英寸边距
metadata={'CreationDate': None}) # 避免时间戳污染元数据
plt.close()

View File

@@ -1,3 +1,5 @@
import pickle
from sqlalchemy import text
from orm import engine, connection
import pandas as pd
@@ -5,107 +7,450 @@ import networkx as nx
import json
import matplotlib.pyplot as plt
# prep data
# Prepare data
Firm = pd.read_csv("input_data/input_firm_data/Firm_amended.csv")
Firm['Code'] = Firm['Code'].astype('string')
Firm.fillna(0, inplace=True)
BomNodes = pd.read_csv('input_data/input_product_data/BomNodes.csv', index_col=0)
# SQL query
with open('SQL_analysis_risk.sql', 'r') as f:
str_sql = text(f.read())
result = pd.read_sql(sql=str_sql,
con=connection)
result.to_csv('output_result\\risk\\count.csv',
index=False,
encoding='utf-8-sig')
result = pd.read_sql(sql=str_sql, con=connection)
result.to_csv('output_result/risk/count.csv', index=False, encoding='utf-8-sig')
print(result)
# G bom
# G_bom
plt.rcParams['font.sans-serif'] = 'SimHei'
exp_id = 1
G_bom_str = pd.read_sql(
sql=text(f'select g_bom from iiabmdb.without_exp_experiment '
f'where id = {exp_id};'),
con=connection)['g_bom'].tolist()[0]
G_bom_df = pd.read_sql(
sql=text(f'select g_bom from iiabmdb.without_exp_experiment where id = {exp_id};'),
con=connection
)
if G_bom_df.empty:
raise ValueError(f"No g_bom found for exp_id = {exp_id}")
G_bom_str = G_bom_df['g_bom'].tolist()[0]
if G_bom_str is None:
raise ValueError(f"g_bom data is None for exp_id = {exp_id}")
G_bom = nx.adjacency_graph(json.loads(G_bom_str))
pos = nx.nx_agraph.graphviz_layout(G_bom, prog="twopi", args="")
node_labels = nx.get_node_attributes(G_bom, 'Name')
# rename node 1
# node_labels['1'] = '工业互联网'
# node_labels['1.1'] = '工业自动化硬件'
# node_labels['1.4'] = '工业互联网安全管理'
# node_labels['1.2.1'] = '网络互联服务'
# node_labels['1.2.2'] = '标识解析服务'
# node_labels['1.2.3'] = '数据互通服务'
# node_labels['1.3.1'] = '设计研发软件'
# node_labels['1.3.2'] = '采购供应软件'
# node_labels['1.3.3'] = '生产制造软件'
# node_labels['1.3.4'] = '企业运营软件'
# node_labels['1.3.5'] = '仓储物流软件'
plt.figure(figsize=(12, 12), dpi=300)
nx.draw_networkx_nodes(G_bom, pos)
nx.draw_networkx_edges(G_bom, pos)
nx.draw_networkx_labels(G_bom, pos, labels=node_labels, font_size=6)
# plt.show()
plt.savefig(f"output_result\\risk\\g_bom_exp_id_{exp_id}.png")
node_labels = {
7: 'Si Raw Mtl.',
8: 'Photoresist & Reagents',
9: 'Etch Solution',
10: 'SiF4',
11: 'Developer',
12: 'PCE Superplasticizer',
13: 'Metal Protectant',
14: 'Deep Hole Cu Plating',
15: 'Thinner',
16: 'HP Boric Acid (Nuc.)',
17: 'E-Grade Epoxy',
18: 'Stripper',
19: 'HP-MOC',
20: 'CMP Slurry & Consumables',
21: 'PR Remover',
22: 'Poly-Si Cutting Fluid',
23: 'Passivation',
24: 'E-Grade Phenolic',
25: 'Surfactant',
26: 'Mag. Carrier',
27: 'Wet Chems.',
28: 'Plating Chems.',
29: 'E-FR Materials',
30: 'LC Alignment Agent',
31: 'Func. Wet Chems.',
32: 'InP',
33: 'SiC',
34: 'GaAs',
35: 'GaN',
36: 'AlN',
37: 'Si3N4',
38: 'SiC Substrate',
39: 'GaN Substrate',
40: 'Si Wafer',
41: 'AlN Substrate',
42: 'DUV LED Substrate',
43: 'InP Substrate',
44: 'Mono-Si Wafer',
45: 'Poly-Si Wafer',
46: 'InP Cryst./Wafer',
47: 'SiC Cryst./Wafer',
48: 'GaAs Wafer',
49: 'GaN Cryst./Wafer',
50: 'Si Epi Wafer',
51: 'SiC Epi Wafer',
52: 'AlN Epi',
53: 'GaN Epi',
54: 'InP Epi',
55: 'LED Epi',
56: 'EDA/IP',
57: 'MPW Service',
58: 'IC Design',
59: 'Track System',
60: 'Wafer Grinder',
61: 'Etcher',
62: 'Ox/Diff Furnace',
63: 'Wafer Metrology',
64: 'Crystal Grower',
65: 'CMP Tool',
66: 'Stepper',
67: 'Wafer Dicer',
68: 'Deposition System',
69: 'Edge Profiler',
70: 'Descum Tool',
71: 'Clean System',
72: 'SAF',
73: 'Plating Eqpt.',
74: 'Implanter',
75: 'Trim/Form',
76: 'Probe Card',
77: 'ATE',
78: 'PCM Eqpt.',
79: 'Inspection Sys.',
80: 'Prober',
81: 'Dicing Saw',
82: 'Handler',
83: 'Backgrinder',
84: 'Die Bonder',
85: 'Reflow Oven',
86: 'FT Tester',
87: 'Wire Bonder',
88: 'BGA Mounter',
89: 'Molding Press',
90: 'Power Devices',
91: 'Diode',
92: 'Transistor',
93: 'Thyristor',
94: 'Rectifier',
95: 'IC Fab',
96: 'IC PKG',
97: 'DV',
98: 'IPM',
99: 'CP Test',
100: 'FT Test',
101: 'Bumping',
102: 'DA Materials',
103: 'Leadframe',
104: 'Solder Ball',
105: 'Substrate',
106: 'EMC',
107: 'Bond Wire',
108: 'Underfill',
109: 'Dicing Tape'
}
plt.figure(figsize=(12, 12), dpi=500)
plt.axis('off') # 关闭坐标轴边框
# 优化节点绘制参数
nx.draw_networkx_nodes(
G_bom, pos,
node_size=100, # 优化节点尺寸
linewidths=0.0 # 去除节点边框
)
# 优化边绘制参数
nx.draw_networkx_edges(
G_bom, pos,
width=0.3, # 更细的边宽
alpha=0.5 # 半透明边
)
# 优化标签参数
nx.draw_networkx_labels(
G_bom, pos,
labels=node_labels,
font_size=3, # 适当增大字号
font_family='sans-serif', # 使用无衬线字体
font_weight='bold', # 增强可读性
)
# 专业级保存参数设置
plt.savefig(
f"output_result/risk/g_bom_exp_id_{exp_id}.png",
bbox_inches='tight', # 去除图像白边
pad_inches=0.1, # 适当内边距
facecolor='white' # 保证背景纯白
)
plt.close()
# G firm
# G_firm
plt.rcParams['font.sans-serif'] = 'SimHei'
sample_id = 1
# G_firm_df = pd.read_sql(
# sql=text(f'select g_firm from iiabmdb.without_exp_sample where id = {sample_id};'),
# con=connection
# )
#
# if G_firm_df.empty:
# raise ValueError(f"No g_firm found for sample_id = {sample_id}")
#
# G_firm_str = G_firm_df['g_firm'].tolist()[0]
# if G_firm_str is None:
# raise ValueError(f"g_firm data is None for sample_id = {sample_id}")
#
# G_firm = nx.adjacency_graph(json.loads(G_firm_str))
G_firm_str = pd.read_sql(
sql=text(f'select g_firm from iiabmdb.without_exp_sample '
f'where id = {exp_id};'),
con=connection)['g_firm'].tolist()[0]
with open("firm_network.pkl", 'rb') as f:
G_firm = pickle.load(f)
print(f"Successfully loaded cached data from firm_network.pkl")
G_firm = nx.adjacency_graph(json.loads(G_firm_str))
# 1. 移除孤立节点
isolated_nodes = list(nx.isolates(G_firm)) # 找出所有没有连接的孤立节点
G_firm.remove_nodes_from(isolated_nodes) # 从图中移除这些节点
# 2. 重新布局和绘图
pos = nx.nx_agraph.graphviz_layout(G_firm, prog="twopi", args="")
# desensitize
node_label = nx.get_node_attributes(G_firm, 'Revenue_Log')
node_label = {key: key for key in nx.get_node_attributes(G_firm, 'Revenue_Log').keys()}
node_label = {
key: key
for key in node_label.keys()
"7": "1",
"9": "2",
"829768": "4",
"863079": "5",
"1452048": "6",
"2010673": "7",
"2624175": "8",
"2728939": "9",
"5278074": "10",
"5849940": "11",
"7299120": "12",
"9746245": "13",
"11807506": "14",
"15613202": "15",
"24284343": "19",
"24673506": "20",
"25036634": "21",
"25685135": "24",
"25945288": "25",
"26162741": "26",
"26516263": "27",
"27075840": "28",
"27731896": "29",
"29954548": "30",
"43407343": "33",
"70634828": "36",
"71271700": "37",
"80158773": "39",
"118882692": "40",
"145511905": "42",
"151606446": "43",
"152008168": "44",
"159511306": "45",
"191912252": "46",
"194210021": "47",
"203314437": "48",
"213386023": "49",
"218633337": "50",
"251189644": "53",
"271860868": "55",
"278221281": "56",
"301209792": "57",
"343012684": "59",
"354897041": "60",
"400488703": "62",
"400692942": "63",
"413274977": "64",
"420984285": "65",
"448033045": "66",
"453289520": "67",
"474279224": "68",
"483081978": "69",
"495782506": "70",
"503176785": "73",
"549184982": "75",
"560866402": "76",
"561545339": "77",
"571058167": "78",
"581407487": "79",
"591452402": "80",
"593312758": "81",
"594378026": "82",
"607512171": "83",
"615763365": "84",
"620220747": "85",
"631449822": "86",
"644292599": "87",
"653528340": "88",
"654825436": "89",
"688155470": "92",
"695995052": "93",
"750610681": "95",
"762985858": "96",
"771821595": "97",
"857978527": "100",
"868012326": "101",
"887840774": "102",
"888356483": "103",
"888395016": "104",
"888478182": "105",
"930767828": "107",
"996174506": "108",
"1033972427": "110",
"1128343125": "111",
"1217957486": "113",
"1307012237": "115",
"1375606900": "116",
"1549474227": "118",
"1606833003": "120",
"1679596339": "121",
"2310825263": "122",
"2311838590": "124",
"2312490120": "125",
"2316990095": "128",
"2317245827": "129",
"2317841563": "131",
"2320102626": "132",
"2320475044": "133",
"2321109759": "134",
"2324787028": "137",
"2324844174": "138",
"2326478786": "139",
"2327031723": "140",
"2327979389": "141",
"2329375731": "142",
"2333843479": "143",
"2337952436": "146",
"2339188563": "147",
"2339684065": "148",
"2341555098": "149",
"2343704209": "150",
"2348941764": "151",
"2352036411": "155",
"2354145351": "157",
"2424229017": "159",
"2545430247": "161",
"2820140348": "163",
"2944892892": "165",
"3025036704": "168",
"3026382513": "169",
"3045721313": "171",
"3047163873": "172",
"3048263744": "173",
"3069206426": "174",
"3070859372": "175",
"3072715478": "176",
"3103797386": "177",
"3111033905": "178",
"3113895788": "179",
"3120341363": "180",
"3122923980": "181",
"3127420424": "182",
"3133307899": "183",
"3147511625": "184",
"3177507356": "185",
"3188903709": "186",
"3195502499": "187",
"3203777710": "188",
"3211956484": "189",
"3215814536": "190",
"3221190269": "191",
"3226664625": "192",
"3267688490": "193",
"3269039233": "194",
"3269940677": "195",
"3271705843": "196",
"3299144127": "197",
"3312358902": "198",
"3344297292": "200",
"3372913783": "201",
"3373311444": "202",
"3384021594": "203",
"3395900897": "205",
"3398677646": "206",
"3407754893": "207",
"3433628561": "209",
"3445244192": "212",
"3445928818": "213",
"4208851809": "216",
"5007015990": "218",
"11164476478": "219",
"517717050": "223",
"737770776": "224",
"872394725": "225",
"2311581270": "226",
"2313209417": "227",
"2347013470": "228",
"2350418059": "229",
"3031009366": "234",
"3089095447": "235",
"3100891962": "236",
"3188352290": "238",
"3288105727": "239",
"3462551351": "240"
}
node_size = list(nx.get_node_attributes(G_firm, 'Revenue_Log').values())
node_size = list(map(lambda x: x**2, node_size))
edge_label = nx.get_edge_attributes(G_firm, "Product")
edge_label = {(n1, n2): label for (n1, n2, _), label in edge_label.items()}
plt.figure(figsize=(12, 12), dpi=300)
nx.draw(G_firm, pos, node_size=node_size, labels=node_label, font_size=6)
nx.draw_networkx_edge_labels(G_firm, pos, edge_label, font_size=4)
# plt.show()
plt.savefig(f"output_result\\risk\\g_firm_sample_id_{exp_id}_de.png")
node_size = [value * 5 for value in nx.get_node_attributes(G_firm, 'Revenue_Log').values()]
edge_label = {(n1, n2): label for (n1, n2, _), label in nx.get_edge_attributes(G_firm, "Product").items()}
plt.figure(figsize=(15, 15), dpi=500)
plt.axis('off') # 完全关闭坐标轴系统
# 分层绘制网络组件
nodes = nx.draw_networkx_nodes(
G_firm, pos,
node_size=node_size, # 保持原始尺寸设置
)
edges = nx.draw_networkx_edges(
G_firm, pos,
width=0.3, # 保持原始线宽设置
)
# 优化节点标签
labels = nx.draw_networkx_labels(
G_firm, pos,
labels=node_label,
font_size=6, # 保持原始字号
)
# 增强边标签可读性
edge_labels = nx.draw_networkx_edge_labels(
G_firm, pos,
edge_labels=edge_label,
font_size=2,
label_pos=0.5, # 标签沿边偏移量
rotate=False, # 禁止自动旋转
)
# 专业级输出配置
plt.savefig(
f"output_result/risk/g_firm_sample_id_{sample_id}_de.png",
bbox_inches='tight',
pad_inches=0.05, # 更紧凑的边距
facecolor='white', # 强制白色背景
metadata={
'Title': f"Supply Chain Risk Map - Sample {sample_id}",
'Author': 'USTB Risk Analytics',
'Copyright': 'Confidential'
}
)
plt.close()
# count firm product
# Count firm product
count_firm_prod = result.value_counts(subset=['id_firm', 'id_product'])
count_firm_prod.name = 'count'
count_firm_prod = count_firm_prod.to_frame().reset_index()
count_firm_prod.to_csv('output_result\\risk\\count_firm_prod.csv',
index=False,
encoding='utf-8-sig')
count_firm_prod.to_csv('output_result/risk/count_firm_prod.csv', index=False, encoding='utf-8-sig')
print(count_firm_prod)
# count firm
# Count firm
count_firm = count_firm_prod.groupby('id_firm')['count'].sum()
count_firm = count_firm.to_frame().reset_index()
count_firm.sort_values('count', inplace=True, ascending=False)
count_firm.to_csv('output_result\\risk\\count_firm.csv',
index=False,
encoding='utf-8-sig')
count_firm.to_csv('output_result/risk/count_firm.csv', index=False, encoding='utf-8-sig')
print(count_firm)
# count product
# Count product
count_prod = count_firm_prod.groupby('id_product')['count'].sum()
count_prod = count_prod.to_frame().reset_index()
count_prod.sort_values('count', inplace=True, ascending=False)
count_prod.to_csv('output_result\\risk\\count_prod.csv',
index=False,
encoding='utf-8-sig')
count_prod.to_csv('output_result/risk/count_prod.csv', index=False, encoding='utf-8-sig')
print(count_prod)
# DCP disruption causing probability
@@ -114,26 +459,33 @@ print(result_disrupt_ts_above_0)
result_dcp = pd.DataFrame(columns=[
's_id', 'up_id_firm', 'up_id_product', 'down_id_firm', 'down_id_product'
])
result_dcp_list = [] # 用列表收集数据避免DataFrame逐行增长的问题
for sid, group in result.groupby('s_id'):
ts_start = max(group['ts'])
while ts_start >= 1:
ts_end = ts_start - 1
while ts_end >= 0:
up = group.loc[group['ts'] == ts_end, ['id_firm', 'id_product']]
down = group.loc[group['ts'] == ts_start,
['id_firm', 'id_product']]
down = group.loc[group['ts'] == ts_start, ['id_firm', 'id_product']]
for _, up_row in up.iterrows():
for _, down_row in down.iterrows():
row = [sid]
row += up_row.tolist()
row += down_row.tolist()
result_dcp.loc[len(result_dcp.index)] = row
result_dcp_list.append([sid] + up_row.tolist() + down_row.tolist())
ts_end -= 1
ts_start -= 1
# 转换为DataFrame
result_dcp = pd.DataFrame(result_dcp_list, columns=[
's_id', 'up_id_firm', 'up_id_product', 'down_id_firm', 'down_id_product'
])
# 统计
count_dcp = result_dcp.value_counts(
subset=['up_id_firm', 'up_id_product', 'down_id_firm', 'down_id_product'])
count_dcp.name = 'count'
count_dcp = count_dcp.to_frame().reset_index()
count_dcp.to_csv('output_result\\risk\\count_dcp.csv',
index=False, encoding='utf-8-sig')
subset=['up_id_firm', 'up_id_product', 'down_id_firm', 'down_id_product']
).reset_index(name='count')
# 保存文件
count_dcp.to_csv('output_result/risk/count_dcp.csv', index=False, encoding='utf-8-sig')
# 输出结果
print(count_dcp)

View File

@@ -0,0 +1,50 @@
import pandas as pd
# 读取数据
df = pd.read_csv('input_data/input_firm_data/firm_amended.csv') # 替换为你的 CSV 文件路径
# 要分析的列
columns = [
"固定资产原值(万元人民币)",
"固定资产净值(万元人民币)",
"资产总和(万元人民币)",
"存货(万元人民币)"
]
# 字段类型定义(可人工定义,也可自动判断)
column_types = {
"固定资产原值(万元人民币)": "连续型",
"固定资产净值(万元人民币)": "连续型",
"资产总和(万元人民币)": "连续型",
"存货(万元人民币)": "连续型"
}
# 统计分析
summary = []
for col in columns:
data = df[col].dropna()
summary.append({
"字段名": col,
"类型": column_types[col],
"计数(非空)": data.count(),
"均值": data.mean(),
"标准差": data.std(),
"最小值": data.min(),
"中位数": data.median(),
"最大值": data.max()
})
# 转为 DataFrame 展示
summary_df = pd.DataFrame(summary)
# 设置列顺序
summary_df = summary_df[["字段名", "类型", "计数(非空)", "均值", "标准差", "最小值", "中位数", "最大值"]]
# 打印结果
print(summary_df)
# 保存为 Excel 文件
output_path = "企业规模数据描述性统计表.xlsx"
summary_df.to_excel(output_path, index=False)
print(f"统计结果已保存为 Excel 文件:{output_path}")

Binary file not shown.

0
执行sql语句.py Normal file
View File

53
查看进度.py Normal file
View File

@@ -0,0 +1,53 @@
from matplotlib import rcParams, pyplot as plt
from sqlalchemy import func
from orm import db_session, Sample
# 创建全局绘图对象和轴
fig, ax = plt.subplots(figsize=(8, 5))
plt.ion() # 启用交互模式
def visualize_progress():
"""
可视化 `is_done_flag` 的分布,动态更新进度条。
"""
# 设置全局字体
rcParams['font.family'] = 'Microsoft YaHei' # 黑体,适用于中文
rcParams['font.size'] = 12
# 查询数据库中各 is_done_flag 的数量
result = db_session.query(
Sample.is_done_flag, func.count(Sample.id)
).group_by(Sample.is_done_flag).all()
# 转换为字典
data = {flag: count for flag, count in result}
# 填充缺失的标志为 0
for flag in [-1, 0, 1]:
data.setdefault(flag, 0)
# 准备数据
labels = ['未完成 (-1)', '计算中(0)', '完成 (1)']
values = [data[-1], data[0], data[1]]
# 清空之前的绘图内容
ax.clear()
# 创建柱状图
ax.bar(labels, values, color=['red', 'orange', 'green'])
ax.set_title('任务进度分布', fontsize=16)
ax.set_xlabel('任务状态', fontsize=14)
ax.set_ylabel('数量', fontsize=14)
ax.tick_params(axis='both', labelsize=12)
# 显示具体数量
for i, v in enumerate(values):
ax.text(i, v + 0.5, str(v), ha='center', fontsize=12)
# 刷新绘图
plt.pause(0) # 暂停一段时间以更新图表
# 关闭窗口时,停止交互模式
# plt.ioff()
visualize_progress()

115
绘制度.py Normal file
View File

@@ -0,0 +1,115 @@
import pickle
import pandas as pd
import networkx as nx
import matplotlib.pyplot as plt
# 1. 读取并处理数据
bom_nodes = pd.read_csv('input_data/input_product_data/BomNodes.csv')
bom_nodes['Code'] = bom_nodes['Code'].astype(str)
bom_nodes.set_index('Index', inplace=True)
bom_cate_net = pd.read_csv('input_data/input_product_data/合成结点.csv')
# 2. 构建图结构
g_bom = nx.from_pandas_edgelist(bom_cate_net, source='UPID', target='ID', create_using=nx.MultiDiGraph())
# 填充每一个结点的具体内容
bom_labels_dict = {}
for index in g_bom.nodes:
try:
bom_labels_dict[index] = bom_nodes.loc[index].to_dict()
except KeyError:
print(f"节点 {index} 不存在于 bom_nodes 中")
# 分配属性给每一个结点
nx.set_node_attributes(g_bom, bom_labels_dict)
# 3. 计算每个节点的度数
degrees = dict(g_bom.degree()) # 总度数(适用于有向图)
# 4. 统计每个度数的节点数量
degree_counts = {}
for degree in degrees.values():
if degree in degree_counts:
degree_counts[degree] += 1
else:
degree_counts[degree] = 1
# 转换为排序后的列表(横坐标:度数,纵坐标:节点数)
sorted_degrees = sorted(degree_counts.keys())
sorted_counts = [degree_counts[d] for d in sorted_degrees]
# 5. 绘制度分布图
plt.figure(figsize=(12, 8)) # 增大画布尺寸
bars = plt.bar(sorted_degrees, sorted_counts, width=0.8)
plt.title('Degree Distribution In Industrial Chain', fontsize=16)
plt.xlabel('Degree', fontsize=14)
plt.ylabel('Number of Nodes', fontsize=14)
plt.grid(True, linestyle='--', alpha=0.5)
plt.xticks(rotation=45) # 如果度数较多可以旋转x轴标签
plt.tight_layout() # 防止标签重叠
# 6. 在每个柱子上方标注数值
for bar in bars:
height = bar.get_height()
plt.text(
bar.get_x() + bar.get_width() / 2, # x坐标柱子中心
height + max(sorted_counts) * 0.02, # y坐标柱子顶部上方留出空间
f'{int(height)}', # 显示数值(转换为整数)
ha='center', # 水平居中
va='bottom', # 垂直底部对齐
fontsize=10, # 字体大小
color='black' # 字体颜色
)
# 7. 保存超高清图片300 DPI
output_path = "degree_distribution_with_labels.png" # 输出文件名
plt.savefig(output_path, dpi=500, bbox_inches='tight') # dpi=300 确保高分辨率
print(f"图片已保存至: {output_path}")
# 1. 加载企业网络数据
with open("firm_network.pkl", 'rb') as f:
G_firm = pickle.load(f)
print(f"Successfully loaded cached data from firm_network.pkl")
# 2. 计算企业网络的度分布
degrees_firm = dict(G_firm.degree()) # 总度数
degree_counts_firm = {}
for degree in degrees_firm.values():
if degree in degree_counts_firm:
degree_counts_firm[degree] += 1
else:
degree_counts_firm[degree] = 1
# 转换为排序后的列表
sorted_degrees_firm = sorted(degree_counts_firm.keys())
sorted_counts_firm = [degree_counts_firm[d] for d in sorted_degrees_firm]
# 3. 绘制企业网络的度分布图
plt.figure(figsize=(12, 6)) # 单独画布尺寸
plt.bar(sorted_degrees_firm, sorted_counts_firm, width=0.8)
plt.title('Degree Distribution of Firm Network', fontsize=16)
plt.xlabel('Degree (Number of Connections)', fontsize=14)
plt.ylabel('Number of Firms', fontsize=14)
plt.grid(True, linestyle='--', alpha=0.5)
plt.xticks(rotation=45)
plt.tight_layout()
# 在柱子上方标注数值
for bar in plt.gca().containers[0]: # 获取当前图中的柱子对象
height = bar.get_height()
plt.text(
bar.get_x() + bar.get_width() / 2,
height + max(sorted_counts_firm) * 0.02,
f'{int(height)}',
ha='center',
va='bottom',
fontsize=10,
color='black'
)
# 保存图片
plt.savefig("degree_distribution_firm.png", dpi=500, bbox_inches='tight')
print("企业度分布图已保存至: degree_distribution_firm.png")