13.8. 日志记录
完成红帽构建的 OptaPlanner school Timetable 项目后,您可以使用日志信息来帮助微调 ConstraintProvider
中的限制。查看 info
日志文件中的分数计算速度,以评估更改对您的限制的影响。以 debug 模式运行应用程序,以显示应用程序接受的每个步骤或使用 trace 日志记录来记录每个步骤和每次移动。
流程
- 为固定时间(如五分钟)运行 button Timetable 应用程序。
查看日志文件中的分数计算速度,如下例所示:
... Solving ended: ..., score calculation speed (29455/sec), ...
... Solving ended: ..., score calculation speed (29455/sec), ...
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
更改约束,再次运行计划应用程序以获得相同时间,并查看日志文件中记录的分数计算速度。
以 debug 模式运行应用程序,记录应用程序所做的每个步骤:
-
要从命令行运行调试模式,请使用
-D
系统属性。 要永久启用调试模式,请在
application.properties
文件中添加以下行:quarkus.log.category."org.optaplanner".level=debug
quarkus.log.category."org.optaplanner".level=debug
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 以下示例显示了在 debug 模式中的
日志文件
的输出:... Solving started: time spent (67), best score (-20init/0hard/0soft), environment mode (REPRODUCIBLE), random (JDK with seed 0). ... CH step (0), time spent (128), score (-18init/0hard/0soft), selected move count (15), picked move ([Math(101) {null -> Room A}, Math(101) {null -> MONDAY 08:30}]). ... CH step (1), time spent (145), score (-16init/0hard/0soft), selected move count (15), picked move ([Physics(102) {null -> Room A}, Physics(102) {null -> MONDAY 09:30}]). ...
... Solving started: time spent (67), best score (-20init/0hard/0soft), environment mode (REPRODUCIBLE), random (JDK with seed 0). ... CH step (0), time spent (128), score (-18init/0hard/0soft), selected move count (15), picked move ([Math(101) {null -> Room A}, Math(101) {null -> MONDAY 08:30}]). ... CH step (1), time spent (145), score (-16init/0hard/0soft), selected move count (15), picked move ([Physics(102) {null -> Room A}, Physics(102) {null -> MONDAY 09:30}]). ...
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
要从命令行运行调试模式,请使用
-
使用
trace
logging 来显示每个步骤以及每个步骤的每个移动。