Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
OptaPlanner-CloudBalancingHelloWorld.java-无法访问solver.getBestSolution()?_Java_Optaplanner - Fatal编程技术网

OptaPlanner-CloudBalancingHelloWorld.java-无法访问solver.getBestSolution()?

OptaPlanner-CloudBalancingHelloWorld.java-无法访问solver.getBestSolution()?,java,optaplanner,Java,Optaplanner,问题: 在示例-CloudBalancement中,为什么此应用程序无法访问solver.getBestSolution()?应用程序始终运行在solver.solve(云平衡)上 有什么建议吗 这里一些可能的解决方案是在solver.solve(unsolvedCloudBalance)完成,然后获取解算器.getBestSolution() 我假设您没有编辑示例的解算器配置XML文件 如果查看正在加载的XML文件,它没有终止子句。基本上,你是在告诉解算器永远运行 您可以编辑解算器配置XML文

问题:

在示例-CloudBalancement中,为什么此应用程序无法访问
solver.getBestSolution()
?应用程序始终运行在
solver.solve(云平衡)上

有什么建议吗

这里一些可能的解决方案是在
solver.solve(unsolvedCloudBalance)完成,然后获取
解算器.getBestSolution()

我假设您没有编辑示例的解算器配置XML文件

如果查看正在加载的XML文件,它没有终止子句。基本上,你是在告诉解算器永远运行

您可以编辑解算器配置XML文件,使其在给定条件后终止。请参见如何执行此操作


如果您想以编程的方式进行,请查看JavaDoc:SolverConfig类的。加载XML文件后,您需要编辑SolverFactory的SolverConfig:请参见方法。

非常感谢,oskopek,在遵循您的建议后,此问题已得到解决

你的建议是:

您可以编辑解算器配置XML文件,使其在给定条件后终止。请参阅有关如何执行此操作的文档

我所做的是:

修改
cloudBalancingSolverConfig.xml
,使用如下终止。然后应用程序在运行120秒后退出

<termination>
    <secondsSpentLimit>120</secondsSpentLimit>
</termination>

我很高兴它成功了。如果你想感谢我,你能做的最好的事情就是接受和/或投票支持我的答案:)在6.2.0.Final中的Cloudballing示例中,注释掉的终止配置是一个已知问题,将在6.3.0.Beta1.than中修复很多,Geoffrey De Smet。这个补丁对一些刚开始使用OptaPlanner的新手会有很大帮助。这使OptaPlanner变得更好。非常感谢,非常感谢,oskopek。我当然接受你的答案,这个答案肯定是有帮助的。我是OptaPlanner上的一个新人。谢谢。
<termination>
    <secondsSpentLimit>120</secondsSpentLimit>
</termination>
09:57:24.791 [main] INFO  o.d.c.k.b.impl.KieRepositoryImpl - KieModule was added: MemoryKieModule[releaseId=org.default:artifact:1.0.0-SNAPSHOT]
09:57:24.963 [main] DEBUG o.drools.core.impl.KnowledgeBaseImpl - Starting Engine in PHREAK mode
Test - solver - before
09:57:25.182 [main] INFO  o.o.core.impl.solver.DefaultSolver - Solving started: time spent (110), best score (uninitialized/0hard/0soft), environment mode (REPRODUCIBLE), random (JDK with seed 0).
09:57:25.213 [main] DEBUG o.o.c.i.c.DefaultConstructionHeuristicPhase -     CH step (0), time spent (141), score (0hard/-6000soft), selected move count (2), picked move (com.optaplanner.cloudbalancing.domain.CloudProcess@34abdee4 => com.optaplanner.cloudbalancing.domain.CloudComputer@1f130eaf).
09:57:25.228 [main] DEBUG o.o.c.i.c.DefaultConstructionHeuristicPhase -     CH step (1), time spent (156), score (0hard/-6000soft), selected move count (2), picked move (com.optaplanner.cloudbalancing.domain.CloudProcess@1494b84d => com.optaplanner.cloudbalancing.domain.CloudComputer@1f130eaf).
09:57:25.228 [main] DEBUG o.o.c.i.c.DefaultConstructionHeuristicPhase -     CH step (2), time spent (156), score (0hard/-6000soft), selected move count (2), picked move (com.optaplanner.cloudbalancing.domain.CloudProcess@655a5d9c => com.optaplanner.cloudbalancing.domain.CloudComputer@1f130eaf).
09:57:25.244 [main] DEBUG o.o.c.i.c.DefaultConstructionHeuristicPhase -     CH step (3), time spent (172), score (0hard/-6000soft), selected move count (2), picked move (com.optaplanner.cloudbalancing.domain.CloudProcess@1b5bc39d => com.optaplanner.cloudbalancing.domain.CloudComputer@1f130eaf).
09:57:25.244 [main] DEBUG o.o.c.i.c.DefaultConstructionHeuristicPhase -     CH step (4), time spent (172), score (0hard/-6000soft), selected move count (2), picked move (com.optaplanner.cloudbalancing.domain.CloudProcess@bc57b40 => com.optaplanner.cloudbalancing.domain.CloudComputer@1f130eaf).
09:57:25.260 [main] DEBUG o.o.c.i.c.DefaultConstructionHeuristicPhase -     CH step (5), time spent (188), score (0hard/-6000soft), selected move count (2), picked move (com.optaplanner.cloudbalancing.domain.CloudProcess@21362712 => com.optaplanner.cloudbalancing.domain.CloudComputer@1f130eaf).
09:57:25.260 [main] INFO  o.o.c.i.c.DefaultConstructionHeuristicPhase - Construction Heuristic phase (0) ended: step total (6), time spent (188), best score (0hard/-6000soft).
09:57:25.712 [main] DEBUG o.o.c.i.l.DefaultLocalSearchPhase -     LS step (0), time spent (640), score (0hard/-8000soft),     best score (0hard/-6000soft), accepted/selected move count (1000/1000), picked move ([com.optaplanner.cloudbalancing.domain.CloudProcess@2575f671, com.optaplanner.cloudbalancing.domain.CloudProcess@72bca894, com.optaplanner.cloudbalancing.domain.CloudProcess@503d56b5, com.optaplanner.cloudbalancing.domain.CloudProcess@433ffad1, com.optaplanner.cloudbalancing.domain.CloudProcess@1fc793c2, com.optaplanner.cloudbalancing.domain.CloudProcess@324dcd31] => com.optaplanner.cloudbalancing.domain.CloudComputer@758f4f03).
09:59:25.083 [main] DEBUG o.o.c.i.l.DefaultLocalSearchPhase -     LS step (1), time spent (120011), score (0hard/-6000soft),     best score (0hard/-6000soft), accepted/selected move count (0/10162968), picked move ([com.optaplanner.cloudbalancing.domain.CloudProcess@503d56b5, com.optaplanner.cloudbalancing.domain.CloudProcess@72bca894, com.optaplanner.cloudbalancing.domain.CloudProcess@324dcd31, com.optaplanner.cloudbalancing.domain.CloudProcess@433ffad1, com.optaplanner.cloudbalancing.domain.CloudProcess@2575f671, com.optaplanner.cloudbalancing.domain.CloudProcess@1fc793c2] => com.optaplanner.cloudbalancing.domain.CloudComputer@1f130eaf).
09:59:25.083 [main] INFO  o.o.c.i.l.DefaultLocalSearchPhase - Local Search phase (1) ended: step total (2), time spent (120011), best score (0hard/-6000soft).
09:59:25.083 [main] INFO  o.o.core.impl.solver.DefaultSolver - Solving ended: time spent (120011), best score (0hard/-6000soft), average calculate count per second (84692), environment mode (REPRODUCIBLE).
Test - solver - after

Solved cloudBalance with 2 computers and 6 processes: