1

我将 Jess 规则引擎与 java 一起使用,并且我有一个包含许多事实的模板人员。我执行有关人员的规则,我想获得满足规则并使其触发的事实数量。这可能吗; egCommand engine.executeCommand("(run)") 仅返回 0 或 1 以防触发规则

4

1 回答 1

0

Depending on what exactly you need, there are several things you might do. The function (run) actually returns the number of rules that fired, so if each fact activates one rule, then the return value of (run) would do it.

If you need to do anything more complex, then you can register a JessEventListener to be notified when each rule fires. The JessEvent will contain the whole activation record for the rule, so you can walk through it and count the facts however you like. Since rules can match the non-existence of facts, or the existence of at least one fact that fits a pattern, etc, the question of "how many facts activated a rule" isn't completely straightforward. But with the activation record in hand, you can count them however you like.

于 2013-08-29T20:56:12.560 回答