我想积累累积结果集合的结果。问题如下:
应该翻译成类似的东西(抱歉它是在乳胶中我没有足够的代表发布图像)
\sum _{G \in \Gamma} \left( \left\{\begin{matrix} &\text{if } \sum _{S \in G} S.nominal > 5 \text{ then } 1
\\
&\text{else } 0
\end{matrix}\right \right ) \leq 40
是否有" drools"这样做的方法?
我对drools规则的尝试如下:
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部分那样在累积函数中定义多个元素。
答案 0 :(得分:0)
据我所知:
"A group is considered "large" if the cumulative value of its elements is above a given threshold."
我建议编写一个规则来执行insertLogical(参见“Truth Maintenance”)的辅助事实,将该组标记为“大”。
这应该简化“大”群体的积累。
(抱歉,我编辑了将怪物名称缩小为可读性。)