feat: 完成 issue #81 [Ti-2] 优化建议生成与可解释性(整合求解结果+跨工序权重+约束依据,输出可溯源建议报告)
This commit is contained in:
@@ -10,6 +10,7 @@ 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
|
||||
from cross_process import CrossProcessModel, CrossProcessModelConfig, CrossProcessSample # noqa: E402
|
||||
from advisor import generate_advice # noqa: E402
|
||||
|
||||
CONFIG = os.path.join(os.path.dirname(os.path.abspath(__file__)),
|
||||
"config", "recipe_optim.template.yaml")
|
||||
@@ -71,12 +72,24 @@ def main() -> int:
|
||||
if not (report.get("r2_down", 0.0) > 0.99):
|
||||
failures.append(f"跨工序模型 R² 过低: {report}")
|
||||
|
||||
# 8) 优化建议生成(#81)端到端:可解释、可溯源建议
|
||||
advice = generate_advice(p, sol, cross_process_weights={
|
||||
"Ti_purity": {"clf_temp": 0.8, "cl2_ratio": 1.2}})
|
||||
if not advice.feasible:
|
||||
failures.append("建议生成器标记不可行")
|
||||
if len(advice.items) != len(p.variables):
|
||||
failures.append("建议条目数与变量数不一致")
|
||||
if not all(it.evidence for it in advice.items):
|
||||
failures.append("存在无依据的建议条目(违反可溯源要求)")
|
||||
if not advice.trace:
|
||||
failures.append("溯源链路为空")
|
||||
|
||||
if failures:
|
||||
print("❌ recipe-optim 自检失败:")
|
||||
for f in failures:
|
||||
print(" -", f)
|
||||
return 1
|
||||
print("✅ recipe-optim 自检通过(7 能力点)")
|
||||
print("✅ recipe-optim 自检通过(8 能力点)")
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user