跳转至

启发式求解器

启发式求解器通过智能搜索策略在有限时间内找到高质量解,适用于大规模组合优化问题。

支持的算法

通过维护禁忌表避免搜索陷入局部最优,适合调度和组合排序问题。

from optagent import solve

solution = solve(
    problem,
    solver="tabu_search",
    config={
        "tabu_tenure": 10,
        "max_iterations": 1000,
        "neighborhood_size": 50
    }
)

从初始解出发,不断在邻域中寻找更优解,速度快但容易陷入局部最优。

模拟退火(Simulated Annealing)

以一定概率接受劣解,概率随温度降低而减小,平衡探索与利用。

大邻域搜索(LNS)

系统性地破坏和修复解的部分结构,适合有明确修复策略的问题。

使用方式

from optagent import solve

# 自动选择最优启发式策略
solution = solve(problem, preset="scheduling_focus")
from optagent import solve

solution = solve(
    problem,
    solver="tabu_search",
    time_limit=60,
    config={
        "tabu_tenure": 15,
        "max_iterations": 5000,
        "diversification": True
    }
)