最小行动方案
原能力
为尚未确定的策略设计低代价试行,明确可以观察到的结果。(细化版 p.8–9)
首选项目
OR-Tools(Apache-2.0)。 OR-Tools
匹配范围
离散求解可在已定义目标下寻找省资源试行。
源码
OR-Tools · def solve(
ortools/sat/python/cp_model.py · 1785–1798 行。 在 GitHub 查看源码 · 许可证与声明
源码片段
def solve(
self,
model: CpModel,
solution_callback: Optional["CpSolverSolutionCallback"] = None,
) -> cmh.CpSolverStatus:
"""Solves a problem and passes each solution to the callback if not null."""
with self.__lock:
self.__solve_wrapper = cmh.SolveWrapper()
self.__solve_wrapper.set_parameters(self.parameters)
if solution_callback is not None:
self.__solve_wrapper.add_solution_callback(solution_callback)
if self.log_callback is not None:
- # Copyright 2010-2025 Google LLC
OR-Tools · def add_cumulative(
ortools/sat/python/cp_model.py · 1476–1489 行。 在 GitHub 查看源码 · 许可证与声明
源码片段
def add_cumulative(
self,
intervals: Iterable[IntervalVar],
demands: Iterable[LinearExprT],
capacity: LinearExprT,
) -> Constraint:
"""Adds Cumulative(intervals, demands, capacity).
This constraint enforces that:
for all t:
sum(demands[i]
if (start(intervals[i]) <= t < end(intervals[i])) and
(intervals[i] is present)) <= capacity
- # Copyright 2010-2025 Google LLC
实现与验收要点
决定试行目标、可观察产出及停止、可逆范围。