How would you query the series of rules that caused Clips to derive a given fact?
To put it simple: I wouldn't, at least in CLIPS. The reason is that CLIPS is a forward chaining system, every single state of the system is derived (inferred, to be exact) from the previous state. In a way, CLIPS maintains no memory of the previous state and at every step it decides what rules have to be fired - possibly using different strategies.
In PyCLIPS, if your system is not particularly complex, I would use a Python function to maintain a list of fired rules. This will cost you an extra line of code for each rule, and a Python call as well. Let's say, for the sake of simplicity, that you have a "linear" sequence of rules to be fired. You'll have the following Python code:
LIST_OF_RULES = 
then, whatever rule you want to track in CLIPS, you add a "side effect" in the RHS;
(defrule duck (duck)
(python-call ins-rule duck) ;; duck is a SYMBOL
the list, at the end, will contain all the rules that have been fired. You'll have to keep different lists for each rule path, or write more complex functions, and anyway the Python call will have a cost in terms of time.
However, this is not a feature of PyCLIPS but of CLIPS itself: maybe a better option is to ask for help in the CLIPSESG group in Google groups. Be careful, a forward chaining system may not be exactly what you need.
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.