diff --git a/.gitignore b/.gitignore index 34733d7..eb890d2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ latex/ +__pycache__/ + diff --git a/p1/__pycache__/combined_scenario.cpython-313.pyc b/p1/__pycache__/combined_scenario.cpython-313.pyc index 83b5917..d6586a9 100644 Binary files a/p1/__pycache__/combined_scenario.cpython-313.pyc and b/p1/__pycache__/combined_scenario.cpython-313.pyc differ diff --git a/p1/__pycache__/pareto_optimization.cpython-313.pyc b/p1/__pycache__/pareto_optimization.cpython-313.pyc index fdd6a6d..137df4c 100644 Binary files a/p1/__pycache__/pareto_optimization.cpython-313.pyc and b/p1/__pycache__/pareto_optimization.cpython-313.pyc differ diff --git a/p1/lambda_cost_analysis.py b/p1/lambda_cost_analysis.py index 4ead3b9..da9c493 100644 --- a/p1/lambda_cost_analysis.py +++ b/p1/lambda_cost_analysis.py @@ -840,5 +840,63 @@ def main(): return df, sensitivity_results +def plot_total_cost_standalone( + df: pd.DataFrame = None, + save_path: str = '/Volumes/Files/code/mm/20260130_b/p1/total_cost_curves.png' +): + """ + 单独绘制总成本曲线图 + - 长宽比 0.618 + - 删去标题 + - 删去 λ=500,添加目标 λ=504 + - 低偏中饱和度色系 + """ + if df is None: + df = generate_tradeoff_curve() + + # 使用0.618黄金比例 + fig_width = 8 + fig_height = fig_width * 0.618 + fig, ax = plt.subplots(figsize=(fig_width, fig_height)) + + years = df['years'].values + + # 低偏中饱和度配色(删去500,添加504) + lambda_colors = [ + (450, '#6B9B78'), # 灰绿色 + (480, '#B87B6B'), # 灰橙红色 + (504, '#8B7BA8'), # 灰紫色(目标λ) + (550, '#5B8FA8'), # 灰蓝色 + ] + + for lam, color in lambda_colors: + total_cost = calculate_total_cost(df, lam) + linewidth = 2.5 if lam == 504 else 2 + linestyle = '-' + label = f'λ={lam} PJ/year' if lam != 504 else f'λ={lam} PJ/year (target)' + + ax.plot(years, total_cost / 1000, color=color, linestyle=linestyle, + linewidth=linewidth, label=label) + + # 标记最小值点 + opt = find_optimal_point(df, lam) + markersize = 11 if lam == 504 else 9 + ax.plot(opt['years'], opt['total_cost'] / 1000, 'o', color=color, + markersize=markersize, markeredgecolor='#333333', markeredgewidth=1.5) + + ax.set_xlabel('Construction Timeline T (years)', fontsize=11) + ax.set_ylabel('Total Cost J = E + λT (×10³ PJ)', fontsize=11) + ax.legend(loc='upper right', fontsize=9) + ax.grid(True, alpha=0.3) + ax.set_xlim(95, 200) + ax.set_ylim(95, 130) + + plt.tight_layout() + plt.savefig(save_path, dpi=150, bbox_inches='tight') + print(f"Total cost curves saved to: {save_path}") + + return fig + + if __name__ == "__main__": df, results = main() diff --git a/p1/total_cost_curves.png b/p1/total_cost_curves.png new file mode 100644 index 0000000..836800c Binary files /dev/null and b/p1/total_cost_curves.png differ