Fix MIP toggle bug: handle PuLP import gracefully
This commit is contained in:
8
main.py
8
main.py
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user