New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a clear method in Facts API #250
Comments
Inference rules engines are not designed to be halted. The idea is to continuously select and run candidate rules until no more rules are applicable. So trying to halt the engine in the middle of the inference process goes against the goal in the first place. I believe a properly configured Do you agree? |
Actually I do want to use the inference engine in this case. The default rules engine applies rules to facts once and only once. I want to be able to repeatedly apply rules to facts in order to generate more facts and fire rules again as necessary, but only until a goal has been reached. I'm able to do that with my toy example above, but it's a hacky solution. |
it's fine to use the inference engine if you need it, you can still use the BTW, I see nothing wrong with clearing facts to halt the execution. By design, a rule's action is not a function in this type of systems, it is an action that might have a side effect on facts: it can add, modify or remove facts to drive the execution flow of subsequent rules. So according to your statement:
do your rules remove facts at some point? I don't know the details of your use case, but:
wdyt? |
Yes, I agree, but directly manipulating the underlying map in the Facts object feels hacky to me (hence my original question). It breaks OO encapsulation. I would expect How do you feel about adding a |
I agree, and I consider this as a bug so I opened #267 (same for
I already tried to introduce a rulesEngine.fire(rules, facts); // blocking call here
rulesEngine.halt(); // too late when reached.. Do you see? It is possible to launch the rules engine in a different thread and halt it from another thread, but I don't like this idea because it forces me to run the engine asynchronously to be able to use a "feature" (I'm a firm believer in "Leave concurrency to the caller" from the the zen of go). I think adding a |
Ah, that makes perfect sense. I agree that adding a |
clear
method to Facts
clear
method to Facts
Is there a recommended way for a
Rule
to halt the firing process ofInferenceRulesEngine
?Currently I'm clearing out the
Facts
map with.asMap().clear()
but this breaks encapsulation and the law of Demeter, so it isn't a satisfactory solution.Example:
The text was updated successfully, but these errors were encountered: