Search code examples
rule-engineclips

What is the maximum number of facts that can be added to a clips rules engine?


I am building a block which contain Clips Rules Engine inside, The top level of my block is android(java code) and i have native code which speak with the clips engine with the help of "CLIPS4Android" module.

https://github.com/gomezgoiri/CLIPS4Android

Lets suppose i just turn the rules engine on(Create Environment from java). When i am adding the first fact(from java) with some value, the fact numbered as <1>. Because CLIPS4Android doesn't support modify, when need to modify fact i need to retract the fact and than add it again with other value. and now the fact numbered as <2>.

if i do this process many times i can reach the limit of facts.

my question is if there a limit of facts that i can add to my rules engine, if yes what is it? and if there is no limit, what happened after i reach the maximum fact number(i know the maximum of integer on android is 2,147,483,647 and when i add ++ its goes to -2,147,483,647.


Solution

  • Fact indices in CLIPS 6.3 and higher are represented using long long integers. That gives you a maximum value for fact indices of 9,223,372,036,854,775,808. If you modify a billion facts a second, it would take almost three centuries to wrap the fact index.

    Searching by fact index is linear, so you'd be better off taking some time to add support for a modify function in CLIPS4Android.