feat: 完成 issue #79 [Ti-2] 配方优化求解器集成(网格枚举+坐标下降轻量求解器+solve统一入口,求解器无关契约)
This commit is contained in:
@@ -8,6 +8,7 @@ import sys
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
from problem import ConstraintKind, OptimizationProblem, load_problem # noqa: E402
|
||||
from solver import SolverConfig, solve # noqa: E402
|
||||
|
||||
CONFIG = os.path.join(os.path.dirname(os.path.abspath(__file__)),
|
||||
"config", "recipe_optim.template.yaml")
|
||||
@@ -48,12 +49,19 @@ def main() -> int:
|
||||
if [v.name for v in rt.variables] != [v.name for v in p.variables]:
|
||||
failures.append("序列化往返丢失变量")
|
||||
|
||||
# 6) 求解器(#79)端到端:加载模板后能求出可行解
|
||||
sol = solve(p, SolverConfig(grid_steps=7, max_combinations=200000))
|
||||
if not sol.feasible:
|
||||
failures.append(f"求解器未求出可行解: {sol.message}")
|
||||
if sol.strategy != "grid":
|
||||
failures.append(f"求解策略非 grid: {sol.strategy}")
|
||||
|
||||
if failures:
|
||||
print("❌ recipe-optim 自检失败:")
|
||||
for f in failures:
|
||||
print(" -", f)
|
||||
return 1
|
||||
print("✅ recipe-optim 自检通过(5 能力点)")
|
||||
print("✅ recipe-optim 自检通过(6 能力点)")
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user