8.3. 更改 OptaPlanner solver 日志记录级别


您可以在 OptaPlanner solver 中更改日志记录级别,以查看解决器活动。以下列表描述了不同的日志记录级别:

  • 错误 :日志错误,除了以 RuntimeException 格式发送到调用代码的除外。

    如果发生错误,OptaPlanner 通常会快速失败。它将子类 RuntimeException 引发到调用代码的详细消息。为了避免重复的日志消息,它不会以错误的形式将其记录。除非调用代码明确捕获并消除 RuntimeException,否则 Thread's default 'ExceptionHandler 会将它作为错误记录。同时,代码会破坏进一步危害或模糊处理错误。

  • Warn :日志可疑情况
  • info :每个阶段日志和解决方法
  • 调试 :记录每个阶段的每个步骤
  • Trace :记录每个阶段每个步骤的每个步骤
注意

指定 trace 日志记录会显著降低性能。但是,在开发过程中,追踪 日志不足以发现瓶颈。

对于快速步骤算法(如 Late Acceptance 和 Simulated Anneing,但不适用于慢速步骤算法,如 Tabu Search),甚至可能会降低性能的速度。

trace' 和 debug 日志记录都会导致使用大多数附加器进行多线程解决。

在 Eclipse 中,对控制台的调试日志往往会导致拥塞,分数计算速度超过 10000 秒。这个问题都不是 IntelliJ 或 Maven 命令行。

流程

将日志记录级别设置为 debug 日志记录来查看阶段结束的时间以及执行速度。

以下示例显示了 debug 日志记录的输出:

INFO  Solving started: time spent (3), best score (-4init/0), random (JDK with seed 0).
DEBUG     CH step (0), time spent (5), score (-3init/0), selected move count (1), picked move (Queen-2 {null -> Row-0}).
DEBUG     CH step (1), time spent (7), score (-2init/0), selected move count (3), picked move (Queen-1 {null -> Row-2}).
DEBUG     CH step (2), time spent (10), score (-1init/0), selected move count (4), picked move (Queen-3 {null -> Row-3}).
DEBUG     CH step (3), time spent (12), score (-1), selected move count (4), picked move (Queen-0 {null -> Row-1}).
INFO  Construction Heuristic phase (0) ended: time spent (12), best score (-1), score calculation speed (9000/sec), step total (4).
DEBUG     LS step (0), time spent (19), score (-1),     best score (-1), accepted/selected move count (12/12), picked move (Queen-1 {Row-2 -> Row-3}).
DEBUG     LS step (1), time spent (24), score (0), new best score (0), accepted/selected move count (9/12), picked move (Queen-3 {Row-3 -> Row-2}).
INFO  Local Search phase (1) ended: time spent (24), best score (0), score calculation speed (4000/sec), step total (2).
INFO  Solving ended: time spent (24), best score (0), score calculation speed (7000/sec), phase total (2), environment mode (REPRODUCIBLE).

所有消耗值的时间都为毫秒。

所有内容都记录到 SLF4J,它是一个简单的日志 facade,它将每个日志消息委派给 Logback、Apache Commons Logging、Log4j 或 java.util.logging。为您选择的日志记录框架添加依赖项到日志适应器。

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部