Noël Huebers wrote:

Hi,

I'm new to the Jess language and have some questions.

1. I work with Java object. I stored them in Jess with store and
assert/fetch commands.
But I could not call there member in the lhs of my rule. No function calls
allowed, right? So, for every object I made a rule to insert a Jess
template. This works fine, but is this way of mapping Java objects to Jess
facts and then discarding the object the best way to work with java objects?
store and fetch are just a way of storing and retrieving arbitrary data. If you want to use Java objects in rules, look into the topic of shadow facts, see section 5.3. Shadow facts: reasoning about Java objects.

2. I am trying to implement a counter-logic for specific slot combinations.
First, everytime a fact is inserted I check if there is already a procounter
fact. If not I create one. This works fine. The next rule should recognize
when a fact (EContext) is inserted and the counter (procounter) already
exists. In this case, the count slot should only be modified. I try to
compare bounded vars ?s ?v ?t from EContext to procounter slots, but I think
Jess simply overwrites the binding. Can you help me with the correct syntax?
Is there a better logic to implement a counter?

If you have one fact (EContext (studentname "Max") (action "bewertet")(value "3")(task "Thesis")) it won't be possible to ever assert another fact just like this one. This might be the cause of modpro failing to fire. Consider adding another slot to EContext such as a date or time stamp, and then you might see an increase. Notice that the rule might benefit from adding the option (declare (no-loop TRUE)).


Best regards,

Noel Huebers

***CODE***

(defrule modpro ; counter erhöhen
   (and
       (EContext
           (studentname ?s)
           (action "bewertet")
           (value ?v)
           (task ?t))
       ?pro <- (procounter
           (name ?s)
           (task ?t)
           (val ?v)
           (count ?x))
   )
=>
(modify ?pro
   (count (+ ?x 1))) ;increase counter
(printout t "Counter für " ?s ?t ?v " erhöhen!!!" crlf))



--------------------------------------------------------------------
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