Drools-嵌套在其他累积中的累积
我想累积一组累积结果的结果。问题如下:Drools-嵌套在其他累积中的累积,drools,Drools,我想累积一组累积结果的结果。问题如下: 我有一个对象集合(SwapAllocation),可以分为不同的组(StockGroup) 如果一组元素的累积值高于给定阈值,则该组被视为“大” 当“大”组的值之和本身高于给定限制时,必须触发该规则 这应该翻译成这样(很抱歉,它是在latex中,我没有足够的代表发布图像) 有“流口水”的方法吗 我尝试的drools规则如下所示: rule "maximalCumulativeWeightLargeWeightStockPerSwap" when
- 我有一个对象集合(SwapAllocation),可以分为不同的组(StockGroup)
- 如果一组元素的累积值高于给定阈值,则该组被视为“大”
- 当“大”组的值之和本身高于给定限制时,必须触发该规则
rule "maximalCumulativeWeightLargeWeightStockPerSwap"
when
$sw : Swap($nominal: nominal,
$largeWeightStockGroupThresh: largeWeightStockGroupThresh,
$maxCumWeightLargeWeightStockGroup:
maxCumWeightLargeWeightStockGroup)
$reqNominal : Number(doubleValue > $maxCumWeightLargeWeightStockGroup*$nominal ) from accumulate(
$sg : StockGroup()
$reqNominalSG : Number( doubleValue > $largeWeightStockGroupThresh*$nominal) from accumulate(
$sa : SwapAllocation(swap == $sw, stock.getStockGroup() == $sg)
sum($sa.nominal())
)
sum($reqNominalSG.doubleValue())
)
then
scoreHolder.addHardConstraintMatch(kcontext, (int) (100 * ($maxCumWeightLargeWeightStockGroup - $reqNominal.doubleValue()/$nominal)));
end
产生
text=[ERR 102] Line 73:27 mismatched input ':' in rule "maximalCumWeightLargeWeightStockPerSwap"]
因为我似乎无法像在规则的when部分那样在累积函数中定义多个元素。据我所知:
"A group is considered "large" if the cumulative value of its elements is above a given threshold."
我建议编写一个规则,对标记该组为“大”的辅助事实进行插入逻辑(请参见“真理维护”)
这将简化“大”群体的积累
(抱歉,我进行了编辑,以降低怪物名称的可读性。)
"A group is considered "large" if the cumulative value of its elements is above a given threshold."