P1: add data and agents.md
This commit is contained in:
@@ -8,6 +8,7 @@ k_min为实数:如2.7表示70%站点最低2次,30%站点最低3次
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import math
|
||||
import os
|
||||
|
||||
try:
|
||||
import matplotlib
|
||||
@@ -28,6 +29,7 @@ ALPHA = 0.5
|
||||
BETA = 0.2
|
||||
N_SIMS = 2000
|
||||
RANDOM_SEED = 42
|
||||
OUTPUT_DIR = "data"
|
||||
|
||||
|
||||
def gini_coefficient(values):
|
||||
@@ -393,7 +395,8 @@ def plot_results(results):
|
||||
axes[3, 1].axis('off')
|
||||
|
||||
plt.tight_layout()
|
||||
plt.savefig('kmin_effectiveness.png', dpi=150)
|
||||
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
||||
plt.savefig(os.path.join(OUTPUT_DIR, 'kmin_effectiveness.png'), dpi=150)
|
||||
plt.close(fig)
|
||||
|
||||
return selected_k, selected_eff
|
||||
@@ -443,9 +446,10 @@ def main():
|
||||
print(f" 访问次数: [{df_opt['AllocatedVisits'].min()}, {df_opt['AllocatedVisits'].max()}]")
|
||||
|
||||
# 6. 保存
|
||||
results.to_csv('kmin_effectiveness_data.csv', index=False)
|
||||
sites_out.to_csv("kmin_effectiveness_sites.csv", index=False)
|
||||
print("\n已保存: kmin_effectiveness.png, kmin_effectiveness_data.csv, kmin_effectiveness_sites.csv")
|
||||
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
||||
results.to_csv(os.path.join(OUTPUT_DIR, 'kmin_effectiveness_data.csv'), index=False)
|
||||
sites_out.to_csv(os.path.join(OUTPUT_DIR, "kmin_effectiveness_sites.csv"), index=False)
|
||||
print("\n已保存到 data/: kmin_effectiveness.png, kmin_effectiveness_data.csv, kmin_effectiveness_sites.csv")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user