0

我正在使用solverManager不断保存最好的分数:

solverManager.solveAndListen(
            SINGLETON_TIME_TABLE_ID,
            this::findById,
            this::save
        )

我的 save() 方法只是更新了对最佳解决方案的全局引用,没有其他任何事情发生。

但是,当我去检索最佳解决方案并获取分数详细信息时,它并不总是得到最佳解决方案:

val solution: MySolution = findById(SINGLETON_TIME_TABLE_ID)

println(solution.score) // prints 1100

scoreManager.updateScore(solution) // Sets the score

println(solution.score) // prints 1020 (it's now worse than before)

简单地调用scoreManager.updateScore(solution)似乎会带来更糟糕的解决方案。在上面的例子中,分数可能从 1100 下降到 1020。对此有明显的解释吗?

我正在使用SimpleScore,并且在分配了所有计划变量后,这种情况发生得很好。

我正在使用变量 listener ArrivalTimeUpdatingVariableListener : VariableListener

不确定还有什么相关的。谢谢

4

1 回答 1

2

这具有分数损坏的所有警告信号。请运行您的求解器几分钟<environmentMode>FULL_ASSERT</environmentMode>。如果您看到抛出异常,您就知道您的约束中有错误。除非我看到这些限制,否则我不可能知道那个错误是什么。

于 2021-12-16T07:06:22.950 回答