Note that there are some explanatory texts on larger screens.

plurals
  1. POFind maximum among facts in CLIPS
    text
    copied!<p>I'm a newbie in expert systems and in CLIPS in particular (besides in English language too :-) ).</p> <p>I'm trying to find a maximum (in some meaning) among facts using complicated comparsion predicate. A comparsion predicate is implemented as a function which takes two facts as an arguments. In simple words I need CLIPS to run over all facts, make comparsion using my predicate and give back one fact that is maximum.</p> <p>One solution might be to evaluate next expression using CLIPS rules: </p> <blockquote> <p>( Exists x) and not ((Exists y)(y != x) and (y>x))</p> </blockquote> <p>where ">" stands for my predicate, x and y are facts, like that:</p> <pre><code>(deftemplate fact (slot name ... ) ... ) (deffunction my-predicate "" (?fact1 ?fact2) ... ) (defrule find-max "" ?fact1 &lt;- (fact (name ?name1) ) ( not (test (my-predicate ?fact1 (fact (name ?name2 ))))) =&gt; ... ) </code></pre> <p>But this example isn't working because of error message about 2nd argument in my-predicate function call. </p> <p>Another solution is to make intermediate facts that represents base facts with particular name and value of comparsion function for predicate. But this will need several iterations to accomplish final result.</p> <p>I prefer 1st solution but i don't understand how to code it. I think I need something like in answer to this <a href="https://stackoverflow.com/q/2382648/3047301">question</a>. The difference is that my question is about comparsion of whole fact, not just one slot.</p> <p>Is it possible to find maximum for one activation of rule? If possible, please explain how.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload