Note that there are some explanatory texts on larger screens.

plurals
  1. POAggregating Facts in the CLIPS Expert System to Find a Maximum
    primarykey
    data
    text
    <p>I'm trying to clarify my understanding of semantics in the Clips expert system, so I'm trying to write some simple rules to aggregate a list of facts to find the fact with the highest slot value. The metaphor I'm using is that of a simple agent trying to decide whether it should eat or sleep. Facts describing the agent's states are expanded into potential actions, and then a rule tries to find the final action with the highest utility. </p> <p>This is my code: </p> <pre><code>(clear) (deftemplate state (slot name) (slot level (type NUMBER)) ) (deftemplate action (slot name) (slot utility (type NUMBER)) (slot final (type INTEGER) (default 0)) ) (defrule eat-when-hungry "" (state (name hungry) (level ?level)) =&gt; (assert (action (name eat) (utility ?level))) ) (defrule sleep-when-sleepy "" (state (name sleepy) (level ?level)) =&gt; (assert (action (name sleep) (utility ?level))) ) (defrule find-final-action "" ?current_final &lt;- (action (name ?current_final_action) (utility ? current_final_utility) (final 1)) (action (name ?other_action) (utility ?other_utility) (final 0)) (neq ?current_final_action ?other_action) (&lt; ?current_final_action ?other_action) =&gt; (modify ?current_final (name ?other_action) (utility ? other_utility)) ) (assert (action (name none) (utility 0.0) (final 1))) (assert (state (name hungry) (level 0.5))) (assert (state (name sleepy) (level 0.1))) (run) (facts) </code></pre> <p>After running this, I would expect the final action to be: </p> <pre><code>(action (name eat) (utility 0.5) (final 1)) </code></pre> <p>However, Clips evaluates it to: </p> <pre><code>(action (name none) (utility 0.0) (final 1)) </code></pre> <p>indicating the find-final-action rule never activates. Why is this? How would you iterate over a group of facts and find the one with the min/max slot value?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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