JESS: type of +(number)L etc...
Hi, I have following codes: Jess (+ -1D +1D -1L +1L) -1.0 isNumeric = true typeName = FLOAT 1.0 isNumeric = true typeName = FLOAT 0.0 isNumeric = true typeName = FLOAT -1 isNumeric = true typeName = LONG -1.0 isNumeric = true typeName = FLOAT +1L isNumeric = true typeName = SYMBOL Jess reported an error in routine Value.numericValue while executing (+ -1.0 1.0 -1 +1L). Message: '+1L' is a symbol, not a number. Program text: ( + -1.0 1.0 +1L ) at line 5. Should +(number)L return RU.LONG instead of RU.SYMBOL ? And that single character + or - passes the ReadTokenizer isAnInteger and isALong test. Thanks. Yuping
JESS: iterate (context.getVariableNames) throws exception AND importPackage question
Hi, I have 2 questions: *First Question Jess (bind ?a a) Jess (bind ?b b) Jess (defglobal ?*i* = (call (context) getVariableNames)) Jess (while (call ?*i* hasNext) (printout t (call ?*i* next) crlf)) b a *i* FALSE Jess (bind ?a a) Jess (bind ?b b) Jess (bind ?i (call (context) getVariableNames)) Jess (while (call ?i hasNext) (printout t (call ?i next) crlf)) Jess reported an error in routine call while executing (call ?i next) while executing (printout t (call ?i next) crlf) while executing (while (call ?i hasNext) (printout t (call ?i next) crlf)). Message: Called method threw an exception. Program text: ( while ( call ?i hasNext ) ( printout t ( call ?i next ) crlf ) ) at line 4. (root cause: java.util.ConcurrentModificationException) why the global var runs but local var fails. *Second Question* Why when you importClass, static members of that class get imported. when importPackage, static members of classses inside that package are not imported Thanks a lot. Yuping
Re: JESS: Rule Question
Jim, on LHS of your rule, you are actually testing (test (and(= ?servicecode 847314565)(= ?quantity 1)) ) AND (test(or(= ?amount 4.17))) so make no differenec if you put or or and inside the second test. Maybe that is what you need? (test (or (and (= ?servicecode 847314565)(= ?quantity 1)) (= ?amount 4.17) ) ) Yuping On 4/24/07, Jim Yates [EMAIL PROTECTED] wrote: I don't understand why fact 1 does not match in the following: (watch activations facts) (deftemplate BTransactions (slot amount) (slot quantity) (slot servicecode)) (defrule Jim_Rule Jim Rule Comment (BTransactions (amount ?amount) (quantity ?quantity) (servicecode ?servicecode) ) (test(and(= ?servicecode 847314565)(= ?quantity 1))) (test(or(= ?amount 4.17))) = (printout t Rule Matched crlf) ) (reset) ;Fact 1 No Match Why? (assert (BTransactions (quantity 1) (amount 4.19)(servicecode 847314565))) ; Fact 2 Match (assert (BTransactions (quantity 1) (amount 4.17) (servicecode 847314565))) (run)
JESS: puzzled about (call) behavior
Hi, I have a question regarding to the behavior of the (call) (call arg1 arg2 method_arg_list) why when arg1 is RU.STRING || RU.SYMBOL, it was treated the same way. I am puzzled about this, I think if the (jess-type arg1) returns RU.SYMBOL, the call method should find the class of arg1 instead of treate arg1 as String. if ((jess-type arg1) == RU.STRING) {} if((jess-type arg1) == RU.SYMBOL) { (find-class arg1) } (call StringUtils contains test t) won't throw any exception. Am I missing some big pictures, your input is greatly appreciated. ---Exception when arg1 is a RU.SYMBOL, but treated the same way as RU.STRING-- (clear) (reset) (watch all) (import org.apache.commons.lang.*) (call StringUtils containsNone test t) (fine, StringUtils is RU.SYMBOL String doesn't have containsNone method) (call StringUtils contains test t) (exception, StringUtils is RU.SYMBOL String has the contains method) Thanks. Yuping
JESS: typo in Arithmetic / functions
Ernest: Hi, I am just wondering if there is a typo in the arithmetic functions. Divide() gets added to the hashmap twice even though that shouldn't matter at all. Thanks. Yuping
JESS: Jess equals in ValueVector, Fact, Value
Hi, I am little confused about the equals implementation in the jess. Is the symmetric rule violated? Thanks. Yuping import jess.*; public class EqualTest { public static void main(String[] args) throws JessException { Rete r = new Rete(); r.eval((deftemplate a (slot x (default 0; r.eval((deftemplate b (slot x (default 0; r.eval((deftemplate c (slot x (default 0; r.eval((deftemplate d (slot x (default 0; ValueVector f = new ValueVector(); f.add(new Value(0, RU.INTEGER)); ValueVector f1 = new Fact(a, r); ValueVector f2 = new Fact(b, r); Object vv = new ValueVector(); ((ValueVector) vv).add(new Value(0, RU.INTEGER)); Object vv1 = new Fact(c, r); Object vv2 = new Fact(d, r); System.out.println(f.equals(f1)); System.out.println(f1.equals(f)); System.out.println(f2.equals(f)); System.out.println(vv.equals(vv1)); System.out.println(vv1.equals(vv)); System.out.println(vv1.equals(vv)); } }
JESS: engine aware of defrule created
Hi, I created a Defrule object, created Pattern object, call Defrule.addCE(pattern, engine) method. Just wondering which method i should use to make rules visible to the engine. Thanks for the help. Yuping
JESS: accumulate on backchain-reactive facts/need-facts
Hi, I am just curious are there any specific reasons that accumulate won't work with backchain-reactive facts or any facts that simply starts with pattern (need-???) ( (clear) (reset) (watch all) (deffacts myfacts (need-xyz)) (reset) (defrule rule ?count - (accumulate (bind ?c 0) (bind ?c (+ ?c 1)) ?c (MAIN::need-xyz) ) = (printout t count: ?count crlf) ) Jess Unexpected exception: null
Re: JESS: fuzzy jess GaussianFuzzySet problem
Hi, according to your number, the area under the normal probability curve (mean = 0.5 , standard_deviation = 1.0) within the interval (left = -2.0 , right = 2.0 )has the value of 0.9269831334, that is why you should see the error message. I think in order for your code to work, you have to change it to FuzzyVariable x1 = new FuzzyVariable(x1, -3.5, 4.5, C); Yuping On 7/12/06, S.S.Ozsariyildiz [EMAIL PROTECTED] wrote: Hi,I try to define a Gaussian Fuzzy Set fora variable as:FuzzySet x1f1 = new GaussianFuzzySet( 0.5, 1.0);FuzzyVariable x1 = new FuzzyVariable(x1, -2.0, 2.0, C);x1.addTerm(x1f1, x1f1);when I try to compile gives error:nrc.fuzzy.XValueOutsideUODException: FuzzySet for FuzzyValue has X values outside range of Universe of DiscourseAny suggestions what's wring with it?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].
Re: JESS: FuzzyJess formula for local centre of gravity
Bob: Thanks for providing the 'moment' formulars. Your help is greatly appreciated. Yuping
JESS: FuzzyJess formular for local centre of gravity
Dr. Friedman-Hill: I am trying totest Fuzzy Jess inside my rules and had one question -what is the formular to calculate the localcentre of gravity? Thanks. Yuping momentDefuzzify Moment defuzzification defuzzifies the FuzzySet of the FuzzyValue returning a floating point (double value) that represents the fuzzy set. It calculates the first moment of the area of a fuzzy set about the y axis. The set is subdivided into different shapes by partitioning vertically at each point in the set, resulting in rectangles, triangles, and trapezoids. The centre of gravity (moment) and area of each subdivision is calculated using the appropriate formulas for each shape. The first moment of area of the whole set is then: where xi´ is the local centre of gravity, A i is the local area of the shape underneath line segment (pi-1, pi), and n is the total number of points. As an example, For each shaded subsection in the diagram above, the area and centre of gravity is calculated according to the shape identified (i.e., triangle, rectangle or trapezoid). The centre of gravity of the whole set is then determined:
JESS: Re: FuzzyJess formular for local centre of gravity
Dr. Friedman-Hill: Iattached 3 missingdiagrams. Thanks. Yuping 1.gif Description: GIF image 2.gif Description: GIF image 3.gif Description: GIF image
Re: JESS: problem with slot-specific TRUE reactivations
Hi Ernest: Thank you for your answers. I tried (no-loop TRUE) before and I got f-1 (MAIN::row (y 0) (data b)) as result. The result I want to get is f-1 (MAIN::row (y 0) (data a b)) Do you know how should I change the rule for this to happen without retracting ?word fact. (i.e., other rules might reuse the word facts in the LHS) Thanks. Yuping On 5/22/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: slot-specific means that modifications to slots that are not matched in the conditions of a rule won't cause the rule to be activated. But this rule matches the data slot, and modifies that same slot, so it's an infinite loop -- and it's supposed to be. If you want to break this infinite loop specifically, then that's what the no-loop declaration in defrules is for. Perhaps that's what you were thinking of in the first place. I think yuping he wrote: [Charset iso-8859-1 unsupported, filtering to ASCII...] ** *Hi, I have the following piece of code* It just adds two words to the row template Both are slot-specific TRUE, however, myrule gets reactivated after row templates being modified (infinite loop) *(clear) (reset) (watch all) (deftemplate row (declare (slot-specific TRUE)) (slot y) (multislot data)) (deftemplate word (declare (slot-specific TRUE)) (slot y) (slot text)) (assert (row (y 0))) (assert (word (y 0) (text a))) (assert (word (y 0) (text b))) (defrule myrule ?row - (row (y ?y) (data $?data)) ?word - (word (y ?y) (text ?text)) = (bind $?data (insert$ $?data (+ (length$ $?data) 1) ?text)) (printout t $?data crlf) (modify ?row (data $?data)) ) (run)* ** *Thanks. Yuping* - Ernest Friedman-Hill Advanced Software Research Phone: (925) 294-2154 Sandia National LabsFAX: (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]
JESS: problem with slot-specific TRUE reactivations
Hi, I have the following piece of code It just adds two words to the row template Both are slot-specific TRUE, however, myrule gets reactivated after row templates being modified (infinite loop) (clear)(reset)(watch all)(deftemplate row (declare (slot-specific TRUE)) (slot y) (multislot data))(deftemplate word (declare (slot-specific TRUE)) (slot y) (slot text)) (assert (row (y 0)))(assert (word (y 0) (text a)))(assert (word (y 0) (text b)))(defrule myrule?row - (row (y ?y) (data $?data))?word - (word (y ?y) (text ?text))=(bind $?data (insert$ $?data (+ (length$ $?data) 1) ?text)) (printout t $?data crlf)(modify ?row (data $?data)))(run) Thanks.Yuping
Re: JESS: Using logical 'or' pipes (|) with global variables
Hi, I have several questions. 1. the number of parenthesis of command exit doesn't matter (exit) ((exit)) (((exit))), etc... all works. 2. (ppdeffunctin) is not working 3. (deftemplate factorial(declare (ordered TRUE)(backchain-reactive TRUE)))(backchain-reactive is not working) 4. import java.io.Serializable;import java.beans.*; public class AutoBean implements Serializable{private PropertyChangeSupport pcs = new PropertyChangeSupport(this);private String name = Bob; public String getName(){return name;} public void setName(String name){String oldValue = this.name;this.name = name;pcs.firePropertyChange(name, oldValue, this.name);} public void addPropertyChangeListener(PropertyChangeListener pcl){pcs.addPropertyChangeListener(pcl);} public void removePropertyChangeListener(PropertyChangeListener pcl){pcs.removePropertyChangeListener(pcl);}} (clear)(defclass bean AutoBean)(bind ?bean (new AutoBean))(definstance bean ?bean dynamic)f-0 (MAIN::bean (class Java-Object:java.lang.Class) (name Bob) (OBJECT Java-Object:AutoBean)) However, during my second test (only tested under 70b6)I did not (exit) jess. I just changed property name from name to names and recompile the AutoBean.class and then enter(clear)(defclass bean AutoBean) (bind ?bean (new AutoBean))(definstance bean ?bean dynamic)(facts *)f-0 (MAIN::bean (class Java-Object:java.lang.Class) (name Bob) (OBJECT Java-Object:AutoBean))Jess is not awaring of this change. I have to exit jess and re-enter jess to make it work. 5. (defrule testing=(if (=1 0) then then else (printout t comment test passed crlf))) Jess (run)comment test passed1I realize that jess engine just echoes the second then so no exception is thrown. but still seems strange to me. Thanks. Yuping