I think Young-Jin Lee wrote: [Charset iso-8859-1 unsupported, filtering to ASCII...] > Hi, > I'm new to JESS and I have a few question in the pump example (pump.clp) . > My questions might be too easy, but I'm learning JESS now. So..... :-) > > 1. (deftemplate machine (slot name) (slot class) (slot OBJECT)) > I guess (slot OBJECT) is related to using JavaBeans, but it is not clear > when and how I can use it because some JavaBean object (Pump) used it, but > some others (Tank) did not use it.
Every defclass will have a 'class' slot and an 'OBJECT' slot, and all our machines will have a 'name' slot. SO the 'machine' deftemplate, which we want pump and tank to inherit from, defines these slots so they can be used polymorphically -- the same way a superclass in Java defines methods that all subclasses should share. > > 2. From the rais-rate-if-low rule in the pump.clp > (defrule raise-rate-if-low > ?warning <- (warning low ?name) > (pump (name ?name) (flow ?flow-rate) (OBJECT ?pump)) > (test (< ?flow-rate 25)) > (idle ?n) > ?a <- (adjust-time ?t&:(< ?t (- ?n 20))) > => > ...) > > Why do we need (OBJECT ?pump) in the second condition of LHS? Because we use the bound ?pump variable to call (get ?pump flow) at the end of the RHS. > Why do we need (OBJECT ?*) only in the pump instance, not in the tank > instance? Because we don't need to use the one in the tank instance. We just matched the pump one because we needed to refer to it. > For example, in the warn-if-low rule definition, tank instance did not have > this thing. > (defrule warn-if-low > (tank (name ?name) (low TRUE) (intact TRUE)) // did not use OBJECT > stuff here > ...) > We don't bind it to a variable because we don't need to use it on the RHS, and we don't need to compare it to any other pattern, or test it in anyway. In this rule, we don't care what the value is. > 3. In the same raise-rate-if-low rule definition, if idle is '0', then what > is the value of '?a'? > Since (adjust-time ?t&:(< ?t (- ?n 20))) cannot be satisfied (?n = 0 in this > case), I think '?a' should not be a valid fact id. Therefore, this rule does > not fire and '?' is not important. > Is it correct? Sort of, I guess. It's not that ?a isn't a valid fact id; it's that no fact matches that pattern, so ?a isn't bound to anything. The assignment to ?a doesn't happen until some fact is matched. > > 4. In the notify-if-ok rule definition... > (defrule notify-if-ok > ?warning <- (warning ? ?name) > -- > ....) > What is the first '?'? I guess it is a wildcard variable which can be > matched to anything, but I'm not sure. It's a "blank variable," a variable with no name. it just makes sure there's something in that spot, without bothering to remember what it is, since we don't care. > > Thanks in advance. > > YJ > --------------------------------------------------------- Ernest Friedman-Hill Distributed Systems Research Phone: (925) 294-2154 Sandia National Labs FAX: (925) 294-2234 Org. 8920, MS 9012 [EMAIL PROTECTED] PO Box 969 http://herzberg.ca.sandia.gov Livermore, CA 94550 -------------------------------------------------------------------- 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] --------------------------------------------------------------------
