我一直在研究带有Drools实现的云平衡演示 of OptaPlanner。
这个演示有2条规则(实际上有4条,但其中3条规则具有相同的逻辑) --
rule "requiredCpuPowerTotal"
when
$computer : CloudComputer($cpuPower : cpuPower)
accumulate(
CloudProcess(
computer == $computer,
$requiredCpuPower : requiredCpuPower);
$requiredCpuPowerTotal : sum($requiredCpuPower);
$requiredCpuPowerTotal > $cpuPower
)
then
scoreHolder.addHardConstraintMatch(kcontext, $cpuPower - $requiredCpuPowerTotal);
end和
rule "computerCost" // "Minimize the total maintenance cost."
when
$computer : CloudComputer($cost : cost)
exists CloudProcess(computer == $computer)
then
scoreHolder.addSoftConstraintMatch(kcontext, - $cost);
end按照这些规则,最优的解决方案是不将任何进程分配给计算机中的任何人。这将完美地满足第一条规则-- cpuPower的容量永远不会耗尽,更不用说过去了。不使用计算机,因此不需要维护费用。
但是系统找到了一种只有这2条规则的解决方案--亚优化将进程分配给计算机。
我错过了什么,在哪里?
OptaPlanner/Drools在哪里被告知分配尽可能多的进程?
新来的口水。原谅这个天真的问题,如果是的话。
//-更新
我认为要初始化的@PlanningEntity()实例并将其放在@PlanningSolution()上是关键。或者显式地在代码中,或者通过@yurloc建议的构造启发式配置,或者。{不知道这里还有什么,如果有的话}
https://stackoverflow.com/questions/60292941
复制相似问题