Forums

Help

&quot;wipe&quot; facts

Hello. Is there any way how to "wipe" all facts at once without reevaluating pattern matching for each single retract - e.g. to prepare the environment for the next independant run? The (reset ) command calls RemoveAllFacts which in a loop calls Retract for every fact. This actually can take quite a long time.

Thanks Vranoch.

If you would like to refer to this comment somewhere else in this project, copy and paste the following link:

Delayed pattern matching for objects is primarily useful if you're making lots of changes to slots. Rather than triggering pattern matching for each slot value change, you make all the changes and then process a single update of the instance. The creation, update, or deletion of instances is still done one instance at a time, so you're not processing all instances at once. Implementing a wipe is feasible, but would require fairly detailed knowledge of the CLIPS internals.

hmm … that is unfortunately not my case :-( . Actually, what I need to do is to repeatedly process new sets of facts against the same set of rules. That is, I need to clean the environment before asserting new set of facts. Since I found out that (reset ) may take quite a long time I create a new environment and (bload ) the rules for every single run. I would still like to avoid repeated reading of rules. Is there any other way?

If you would like to refer to this comment somewhere else in this project, copy and paste the following link:

You'd be better off fully understanding the problem before you start devising solutions to fix it. If retracting all of the facts to return the system to its initial state is computationally expensive, then it's likely that building the state by asserting the facts was also computationally expensive. If you can optimize your rules so that the reset is more efficient, you'll likely optimize your execution performance as well.

For example, suppose you've written a highly inefficient deffunction that is called from the LHS of a rule (and could be invoked either by an assert or retract of a fact). If you add wipe functionality that clears out the system state without performing retractions, you'll bypass this inefficient code when performing a reset, but you'll still end up calling it when your program is executing as it performs asserts and retracts.

There are a number of things you can do to look for performance issues. The profiling command in section 13.16 of the Basic Programming Guide can help you find issues with the procedural portions of your code like deffunctions and can sometimes be helpful when analyzing your rules. If your program is modular and you can easily exclude groups of rules, you can run your program excluding some of your rules and see if performance improves. Another trick is to run your program after issuing a (watch facts) command. If you see facts being quickly asserted and/or retracted and then there's a long pause after a particular assertion or retraction, you can focus on rules with patterns that would match that fact.

After that it becomes a bit more esoteric and you have to have a bit more knowledge about the program in question: number of rules, complexity of rules, number of facts, and how frequently the facts change. Once you're able to identify if there are rules causing issues, there are some general tips on improving performance in Appendix F of the Basic Programming Guide.

If you're using CLIPS 6.24, you should try using version 6.3 as there are some performance improvements primarily for systems with large numbers of facts.

If you would like to refer to this comment somewhere else in this project, copy and paste the following link:

thanks a lot for hints. Coincidentally, I have just finished an upgrade from 6.24 to 6.30 - primarily because of its UTF8 support. Thanks for it, that was a good job.

It is already some time when I tested the cleaning of environment up. Then I decided to re-create it for each run. I should perhaps do some new specific tests to see whether the problem does really exist or not in fact.

If you would like to refer to this comment somewhere else in this project, copy and paste the following link:

Community

Help

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

I agree to receive quotes, newsletters and other information from sourceforge.net and its partners regarding IT services and products. I understand that I can withdraw my consent at any time. Please refer to our Privacy Policy or Contact Us for more details