Fix MIP toggle bug: handle PuLP import gracefully

This commit is contained in:
dmy
2026-01-08 10:01:46 +08:00
parent 4230d2221d
commit 579f8866c4
2 changed files with 17 additions and 10 deletions

View File

@@ -14,11 +14,7 @@ from sklearn.cluster import KMeans
from esau_williams import design_with_esau_williams
from ga import design_with_ga
try:
from mip import design_with_mip
except ImportError:
design_with_mip = None
from mip import design_with_mip
# 设置matplotlib支持中文显示
plt.rcParams["font.sans-serif"] = ["Microsoft YaHei", "SimHei", "Arial"]
@@ -1715,7 +1711,7 @@ def compare_design_methods(
f" [GA] Cost: ¥{eval_ga['total_cost']:,.2f} | Loss: {eval_ga['total_loss']:.2f} kW | Circuits: {n_circuits_ga}"
)
if use_mip and design_with_mip:
if use_mip:
# --- Run 5: Mixed Integer Programming ---
mip_name = f"{name} (MIP)"
conns_mip, turbines_mip = design_with_mip(