This solution works fine. But I have another problem when I want to use it in another more complex rule.
 
(deftemplate concepts
(slot ID (type INTEGER))
(multislot prerequisite)
(slot ordinalNumber (type INTEGER))
(slot minKnowledgeLevel (type INTEGER)))
 
;;----- TEMPLATE THAT KEEPS LIST OF ALREADY LEARNED CONCEPTS----;;
(deftemplate passed_concepts
(slot ID (type INTEGER) ))
 
;;-----TEMPLATE THAT KEEPS LIST OF CONCEPTS THAT ARE ADDED TO CONCEPT PLAN
(deftemplate concepts_added_in_plan
(slot ID (type INTEGER)))
 
;;----- STUDENT TEMPLATE ---KEEPS DATA ABOUT CURRENT STUDENT KNOWLEDGE LEVEL----;;
(deftemplate student
(slot ID ( type INTEGER )  )
(slot knowledgeLevel ( type INTEGER )))
 
;;----- CHECK CONCEPT RULE --- CHECK IF THE CONCEPT COULD BE INSERT IN INSTRUCTIONAL PLAN----;;
 
(defrule check_concept_new
( concepts (ID ?cID) (prerequisite $?first ?one $?rest) (minKnowledgeLevel ?mKnLev))
( student (knowledgeLevel ?sKnLev))
(passed_concepts  (ID ?one))
(concepts_added_in_plan  (ID ?caipID))
(test   (and (and    (<= ?mKnLev ?sKnLev)  (neq  ?cID ?caipID) ) (not (and (concepts (ID ?cID) (prerequisite $?first ?one $?rest)) (not (passed_concepts (ID ?one)))))))
 =>
(call ?pok addConceptInPlan ?cID ))
 
 

(defrule check_concept_old

 ?fact5 <- ( concepts (ID ?cID) (prerequisite $?pre)(minKnowledgeLevel ?mKnLev)(ordinalNumber ?oN))

?fact6 <- ( student (knowledgeLevel ?sKnLev))

?fact7 <-  ( passed_concepts  (ID $?pcID))

(test   (and  (<= ?mKnLev ?sKnLev) (subsetp $?pre $?pcID)) )

=>

(call ?pok addConceptToPlan ?cID ?oN))

 

 

"check_concept_old" rule and your "all-prerequisites" rule both works fine, but when I try to merge them in another one "check_concept_new" it generates an error:

 

 

 ==> f-24 (MAIN::concepts (ID 140) (prerequisite 122 123) (ordinalNumber 23) (minKnowledgeLevel 2))
 ==> f-25 (MAIN::student (ID 2) (knowledgeLevel 2))
ERROR in addStudentData function, JessException.getmessage : Unimplemented function
ERROR addStudentData function, JessException.getContext :
 while executing (concepts (ID ?cID) (prerequisite ?first ?one ?rest))
 while executing (and (concepts (ID ?cID) (prerequisite ?first ?one ?rest)) (not (passed_concepts (ID ?one))))
 while executing (not (and (concepts (ID ?cID) (prerequisite ?first ?one ?rest)) (not (passed_concepts (ID ?one)))))
 while executing (and (and (<= ?mKnLev ?sKnLev) (neq ?cID ?caipID)) (not (and (concepts (ID ?cID) (prerequisite ?first ?one ?rest)) (not (passed_concepts (ID ?one))))))
 while executing 'test' CE
 while executing rule LHS (Node2)
 while executing rule LHS (Node2)
 while executing rule LHS (Node2)
 while executing rule LHS (TECT)
 ==> f-26 (MAIN::passed_concepts (ID 122))

 
Thank you for your help
regards,
Jeremic Zoran

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 21, 2004 3:00 AM
Subject: Re: JESS: How can I write this rule?

> I think Jeremic Zoran wrote:
> [Charset iso-8859-1 unsupported, filtering to ASCII...]
> > (deftemplate passed_concepts
> > (slot ID (type INTEGER)))
> >
> > (deftemplate concept
> > (slot ID (type INTEGER))
> > (multislot prerequisite)
> > (slot ordinalNumber (type INTEGER))
> > (slot minKnowledgeLevel (type INTEGER)))
> >
> > there could be up to 23 passed_concepts in memory, and every concept could have 1, 2 or 3 prerequisites. I need to write rule that will find concept (fire rule) if all prerequisites exists in working memory.
> > Thank you for help.
>
>
> If I understand you correctly, the multislot in "concept" contains a
> list of ids of "passed_concepts" facts, and you want to identify the
> concepts which point only to existing passed_concepts facts. One way
> to do it would look like this:
>
> (defrule all-prerequisites
>
>   ;; There's a concept...
>
>   (concept (id ?id))
>
>   ;; ... and it's not true that for any prerequsite ?one of this
>   ;; concept, there's no matching passed_concepts fact.
>
>   (not (and (concept (id ?id) (prerequisite $?first ?one $?rest))
>             (not (passed_concepts (id ?one)))))
>   =>
>   (printout t "All prerequisities for concept " ?id " are satisfied." crlf))
>
>
> ---------------------------------------------------------
> Ernest Friedman-Hill 
> Science and Engineering PSEs        Phone: (925) 294-2154
> Sandia National Labs                FAX:   (925) 294-2234
> PO Box 969, MS 9012                
[EMAIL PROTECTED]
> Livermore, CA 94550         http://herzberg.ca.sandia.gov
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users
[EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the list
> (use your own address!) List problems? Notify
[EMAIL PROTECTED].
> --------------------------------------------------------------------

Reply via email to