我尝试使用drools来解决Optaplanner的背包问题。以前有人这么做过吗?这指的是optaplanner的示例。
谢谢你的帮忙
我将这些规则实现如下:
rule "weigth" dialect "java" when
$knapsack : Knapsack($capacity : capacity) $weightTotal : Number(intValue > $capacity) from accumulate( Item( $weight : weight), sum($weight) ) then scoreHolder.addHardConstraintMatch(kcontext, $capacity - $weightTotal.intValue()) end
发布于 2016-03-02 17:20:48
假设Item是您的计划实体,并且它有一个计划变量boolean used,那么您只需要检查属于used == true的项目。
... from accumulate(
Item(used == true,
$weight : weight),
sum($weight)
)https://stackoverflow.com/questions/35720729
复制相似问题