0
我'试图通过资源加载XML文件来建立与optaplanner的解决方案。当我在单元测试中运行它时,它工作得很好。但是当我在Spring引导应用程序运行时尝试运行它时,我认为它没有正确读取资源。Optaplanner弹簧引导加载资源问题(仅适用于单元测试)
这是我们的配置XML文件
<!-- Domain model configuration -->
<solutionClass>be.infofarm.backend.domain.Internship.solution.InternshipSolution</solutionClass>
<entityClass>be.infofarm.backend.domain.Internship.Student</entityClass>
<!--<environmentMode>FAST_ASSERT</environmentMode>-->
<!-- Score configuration -->
<scoreDirectorFactory>
<scoreDefinitionType>HARD_SOFT</scoreDefinitionType>
<scoreDrl>InternshipCalculator.drl</scoreDrl>
<initializingScoreTrend>ONLY_DOWN</initializingScoreTrend>
</scoreDirectorFactory>
<constructionHeuristic>
<constructionHeuristicType>FIRST_FIT_DECREASING</constructionHeuristicType>
</constructionHeuristic>
<localSearch>
<forager>
<acceptedCountLimit>800</acceptedCountLimit>
</forager>
</localSearch>
<localSearch>
<acceptor>
<entityTabuSize>20</entityTabuSize>
</acceptor>
</localSearch>
<termination>
<secondsSpentLimit>10</secondsSpentLimit>
</termination>
欢迎计算器!不幸的是,这里没有足够的信息来帮助你。我建议阅读[我如何问一个好问题](http://stackoverflow.com/help/how-to-ask),然后回来编辑您的文章以包含其他信息。 – DaveyDaveDave
打开'DEBUG'记录(见它optaplanner文档部分),并检查如果你正在运行相同的步数(=迭代)。如果您比较2次运行,则输出在相同的迭代中应该具有相同的分数。 –
我们已经把它放在DEBUG日志上,当我们比较2次迭代时,有一个显着的区别。通过Spring引导运行,LS的步骤要比单元测试运行多得多。 另外,Spring的启动运行并没有增加我们在我们的流口水文件中初始化的软分数。当我们运行单元测试时,它只会将我们在流水号文件中初始化的软分数加起来,但它忽略了严格的限制。我们已将替换为和。当我们运行应用程序 –
user3360938