JESS: [EXTERNAL]
7]) by mailgate2.sandia.gov (8.14.4/8.14.4) with ESMTP id r0559c8F004910 for jess-users@sandia.gov; Fri, 4 Jan 2013 22:09:38 -0700 Received: from sentry-four.sandia.gov (localhost.localdomain [127.0.0.1]) by localhost (Email Security Appliance) with SMTP id B61E913EE057_E7B592B for jess-users@sandia.gov; Sat, 5 Jan 2013 05:09:38 + (GMT) Received: from sentry.sandia.gov (mm03snlnto.sandia.gov [132.175.109.20]) by sentry-four.sandia.gov (Sophos Email Appliance) with ESMTP id 8F5EB13EB= 683_E7B592F for jess-users@sandia.gov; Sat, 5 Jan 2013 05:09:38 + (GMT) Received: from [132.175.109.17] by sentry.sandia.gov with ESMTP (SMTP Relay 01 (Email Firewall v6.3.2)); Fri, 04 Jan 2013 22:09:29 -0700 X-Server-Uuid: AF72F651-81B1-4134-BA8C-A8E1A4E620FF X-WSS-ID: 0MG4ZNQ-0C-0P1-02 X-TMWD-Spam-Summary: TS=3D20130105050926; ID=3D1; SEV=3D2.4.4; DFV=3DB2013010506; IFV=3DNA; AIF=3DB2013010506; RPD=3D7.03.0049; ENG=3DNA; RPDID=3D7374723D303030312E30413031303230322E35304537423538382E303033432C73= 733D312C72653D302E3030302C6667733D30; CAT=3DNONE; CON=3DNONE; SIG=3D0VXSqwAAAg=3D=3D X-TMWD-IP-Reputation: SIP=3D209.85.210.171; IPRID=3D7469643D303030312E30413031303330322E35304537423538372E30303146; CTCLS=3DR5; CAT=3DUnknown Received: from mail-ia0-f171.google.com (mail-ia0-f171.google.com [209.85.210.171]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by sentry-three.sandia.gov ( Postfix) with ESMTP id 2B0E84643FF for jess-users@sandia.gov; Fri, 4 Jan 2013 22:09:25 -0700 ( MST) Received: by mail-ia0-f171.google.com with SMTP id k27so14445348iad.16 for jess-users@sandia.gov; Fri, 04 Jan 2013 21:09:27 -0800 (PST) DKIM-Signature: v=3D1; a=3Drsa-sha256; c=3Drelaxed/relaxed; d=3Dgmail.com; s=3D20120113; h=3Dmime-version:x-received:sender:date:x-google-sender-auth:message-id : subject:from:to:content-type; bh=3DNbWHpPWjsr1y3psWS5nSuCyIanVTGrw/ueEn4B3ZJ30=3D; b=3DcVyPc3IMqmwgJkt5lk+Znbf16baGRo0KZj5VNxwmKZyeNz9Wa1O1LOiJewL99QrV3W oLr6QKuTmzFllAncgeNZ4T8bC74wtC7qj/fNsxdES29w/fpJIS6JeFoX0Q3SbxaRuCRu iDOJeyVr5YbQFLPjI26LuzNXmJ5wrS7CSjbzlSAzmaCjy+GKjcRfAH+h8XPs9/0LEH/h 3AUjltDhtX64K02XlIl6GP1tMp21ZLb+uSXFflStUNnyNzPAm1aRtRlHwkHPQyd25j/9 VYJGRoEwqjLuc0Yu35h1U9K4OK7+OOcrPNO2ek60E7USjW62BYa15lVdX1WclXKMIfm8 YDjQ=3D=3D MIME-Version: 1.0 X-Received: by 10.50.163.98 with SMTP id yh2mr782401igb.2.1357362567526; Fri, 04 Jan 2013 21:09:27 -0800 (PST) Sender: gret...@gmail.com Received: by 10.64.45.201 with HTTP; Fri, 4 Jan 2013 21:09:27 -0800 ( PST) Date: Fri, 4 Jan 2013 23:09:27 -0600 X-Google-Sender-Auth: bGz_8nfUup2r7jFexVK35HW9BME Message-ID: CAAjq1mffGb0CD11w+VTSjCXCb6oSM9_rtw0BjPj0vPOPqDn--g@mail.gmail= .com Subject: Slowly documenting project setup steps From: Grant Rettke gret...@acm.org To: jess-users@sandia.gov X-TMWD-Spam-Summary: TS=3D20130105050932; ID=3D2; SEV=3D2.3.1; DFV=3DB2012110920; IFV=3DNA; AIF=3DB2012110920; RPD=3D5.03.0010; ENG=3DNA; RPDID=3D7374723D303030312E30413031303230322E35304537423538422E303032302C73= 733D312C6667733D30; CAT=3DNONE; CON=3DNONE; SIG=3DfQ=3D=3D X-MMS-Spam-Filter-ID: B2012110920_5.03.0010 X-WSS-ID: 7CF96A030I89503247-01-01 Content-Type: multipart/alternative; boundary=3De89a8f642ec6ab384004d2839972 X-Sophos-ESA: [sentry-four.sandia.gov] 3.7.6.0, Antispam-Engine: 2.7.2.1390= 750, Antispam-Data: 2013.1.5.45414 --e89a8f642ec6ab384004d2839972 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=3Dutf-8 http://www.wisdomandwonder.com/article/6891/jess-sample-java-setup-project-= mission-statement --e89a8f642ec6ab384004d2839972 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=3Dutf-8 a href=3Dhttp://www.wisdomandwonder.com/article/6891/jess-sample-java-set= up-project-mission-statementhttp://www.wisdomandwonder.com/article/6891/j= ess-sample-java-setup-project-mission-statement/a --e89a8f642ec6ab384004d2839972-- To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: [EXTERNAL] How to persist the fact and rule base from a given session?
Hi Grant, Sorry nobody answered this earlier. The bsave and bload commands save and restore the binary state of a Jess engine to a file, and they're probably just what you're looking for. On Mon, Nov 26, 2012 at 5:21 PM, Grant Rettke gret...@acm.org wrote: Hi, I would like to be able to turn off a Jess session so that all of its rules and facts would be persisted so that later I could start it up again. The scenario is something like... there are things we want to handle but the user has stopped the program, so we turn it off, but when we turn it back on, those events should be handled. I did read the docs but just didn't... maybe I missed something. Best wishes, -- Grant Rettke | ACM, AMA, COG, IEEE gret...@acm.org | http://www.wisdomandwonder.com/ Wisdom begins in wonder. ((λ (x) (x x)) (λ (x) (x x)))
Re: JESS: Would like to know why runQueryStar would not return any results
I believe the issue is the classic one that RU.SYMBOL and RU.STRING are different data types. Your DimmerSwitch properties are quoted strings (RU.STRING) but your query parameters are created using new ValueVector().add(Ceiling Light) which creates a Value of type RU.SYMBOL. You want to explictly create STRINGS: new ValueVector().add(new Value(Ceiling Light, RU.STRING)) and that should fix the problem. On Jul 17, 2011, at 8:30 PM, Felix Chan wrote: Hi all, I am wondering if someone could help me understand why runQueryStar would not work for me in a certain scenario. Thank you in advance! First, I have the following script. It works as expected: (deftemplate DimmerSwitch (slot label) (slot brightness)) (defquery search-dimmer-switch (declare (variables ?lbl)) (DimmerSwitch (label ?lbl) (brightness ?b)) ) (defrule set-brightness-to-10-and-15 (not (DimmerSwitch)) = (assert (DimmerSwitch (label Ceiling Light) (brightness 10))) (assert (DimmerSwitch (label Bathroom Light) (brightness 5))) ) (reset) (run) (facts) (bind ?result (run-query* search-dimmer-switch Ceiling Light)) (while (?result next) (printout t (?result getString lbl) | (?result getInt b) crlf) ) The output is as follows. No problem there. f-0 (MAIN::initial-fact) f-1 (MAIN::DimmerSwitch (label Ceiling Light) (brightness 10)) f-2 (MAIN::DimmerSwitch (label Bathroom Light) (brightness 5)) For a total of 3 facts in module MAIN. Ceiling Light | 10 --- Then I delete the portion of the script from (reset) on down, with just the following: (deftemplate DimmerSwitch (slot label) (slot brightness)) (defquery search-dimmer-switch (declare (variables ?lbl)) (DimmerSwitch (label ?lbl) (brightness ?b)) ) (defrule set-brightness-to-10-and-15 (not (DimmerSwitch)) = (assert (DimmerSwitch (label Ceiling Light) (brightness 10))) (assert (DimmerSwitch (label Bathroom Light) (brightness 5))) ) Then I use java to run the query as follows. test.clp contains the above script obviously. package control; import jess.*; public class TestApp { public static void main(String[] args) throws JessException { Rete engine = new Rete(); engine.batch(C:\\Users\\Administrator\\workspace\\ShadowFactTest\ \src\\control\\test.clp); engine.reset(); engine.eval((facts)); engine.run(); engine.eval((facts)); QueryResult result = engine.runQueryStar(search-dimmer-switch, new ValueVector().add(Ceiling Light)); while (result.next()) { System.out.println(result.getString(lbl) + | + result.getInt(b)); } } } The output is as follows. The Rete Engine ran fine. The rule fired. But there's nothing coming back from runQueryStar. f-0 (MAIN::initial-fact) For a total of 1 facts in module MAIN. f-0 (MAIN::initial-fact) f-1 (MAIN::DimmerSwitch (label Ceiling Light) (brightness 10)) f-2 (MAIN::DimmerSwitch (label Bathroom Light) (brightness 5)) For a total of 3 facts in module MAIN. - Now I change the query parameter to brightness, an integer field. (deftemplate DimmerSwitch (slot label) (slot brightness)) (defquery search-dimmer-switch (declare (variables ?b)) (DimmerSwitch (label ?lbl) (brightness ?b)) ) (defrule set-brightness-to-10-and-15 (not (DimmerSwitch)) = (assert (DimmerSwitch (label Ceiling Light) (brightness 10))) (assert (DimmerSwitch (label Bathroom Light) (brightness 5))) ) - and use the following java program instead: package control; import jess.*; public class TestApp { public static void main(String[] args) throws JessException { Rete engine = new Rete(); engine.batch(C:\\Users\\Administrator\\workspace\\ShadowFactTest\ \src\\control\\test.clp); engine.reset(); engine.eval((facts)); engine.run(); engine.eval((facts)); QueryResult result = engine.runQueryStar(search-dimmer-switch, new ValueVector().add(10)); while (result.next()) { System.out.println(result.getString(lbl) + | + result.getInt(b)); } } } --- Now the output looks normal: f-0 (MAIN::initial-fact) For a total of 1 facts in module MAIN. f-0 (MAIN::initial-fact) f-1 (MAIN::DimmerSwitch (label Ceiling Light) (brightness 10)) f-2 (MAIN::DimmerSwitch (label Bathroom Light) (brightness 5)) For a total of 3 facts in module MAIN. Ceiling Light | 10 -- Could someone explain why this query won't work? QueryResult result = engine.runQueryStar(search-dimmer-switch, new ValueVector().add(Ceiling Light)); Many thanks. Felix - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y
Re: JESS: Time-varying methods inside a and in a test
Although they do compile into different networks, the effect should be basically the same. What's the difference you're observing? On Jul 18, 2011, at 11:00 AM, Skeptic . wrote: Hi, Is there a good reason why a rule like this : (defrule r1 [...] (test (and (time-varying call1) (time-varying call2)) = [...]) behave differently than one like this : (defrule r1b [...] (test (time-varying call1)) (test (time-varying call2)) = [...]) Thanks ! - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Is www.jessrules.com down
The server is back up now. On Jul 6, 2011, at 2:43 PM, Felix Chan wrote: Hi all, I have not been able to access jessrules.com for a couple of days. I am wondering if this is just me. Thanks. Felix To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: question on slot specific
Oooh, that's a bad example; I'll have to fix the manual. If you type (watch all) before your code, you'll see that the rule actually fires twice; once when B is nil, and once when it's 3. But the second time it fires, the modify has no effect, since the slot is being modified to contain the value it already contains. Try this rule instead, both with and without no-loop (and use (watch all) so you can see what's going on:) (defrule R (declare (no-loop TRUE)) ?d - (D (A 1)) = (modify ?d (B (+ ?d.B 1 Note that your initial assert needs to have a number in the B slot, or you'll get an error. On Jun 12, 2011, at 8:08 PM, Felix Chan wrote: Hi, I have been trying to understand the slot-specific functionality which is described in the JESS manual as follows: --- 6.18. The 'slot-specific' declaration for deftemplates Deftemplate definitions can now include a declare section just as defrules can. There are several different properties that can be declared. One is slot-specific. A template with this declaration will be matched in a special way: if a fact, created from such a template, which matches the left-hand-side of a rule is modified, the result depends on whether the modified slot is named in the pattern used to match the fact. As an example, consider the following: Jess (deftemplate D (declare (slot-specific TRUE)) (slot A) (slot B)) Jess (defrule R ?d - (D (A 1)) = (modify ?d (B 3))) Without the slot-specific declaration, this rule would enter an endless loop, because it modifies a fact matched on the LHS in such a way that the modified fact will still match. With the declaration, it can simply fire once. This behavior is actually what many new users expect as the default; the technical term for it is refraction. -- I tried the following without the slot-specific declaration, expecting an infinite loop to occur: (reset) (deftemplate D (slot A) (slot B)) (defrule R ?d - (D (A 1)) = (modify ?d (B 3))) (bind ?f (assert (D (A 1 (facts) (run) (facts) But I got the following outcome with no infinite loop: f-0 (MAIN::initial-fact) f-1 (MAIN::D (A 1) (B nil)) For a total of 2 facts in module MAIN. f-0 (MAIN::initial-fact) f-1 (MAIN::D (A 1) (B 3)) For a total of 2 facts in module MAIN. It seems slot-specific makes no difference in the outcome. I suspect I am missing a key concept here. Could someone explain? Thanks. Felix To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: question on slot specific
Argh, sorry, I used no-loop in my example, but I meant slot- specific. On Jun 12, 2011, at 11:12 PM, Ernest Friedman-Hill wrote: Oooh, that's a bad example; I'll have to fix the manual. If you type (watch all) before your code, you'll see that the rule actually fires twice; once when B is nil, and once when it's 3. But the second time it fires, the modify has no effect, since the slot is being modified to contain the value it already contains. Try this rule instead, both with and without no-loop (and use (watch all) so you can see what's going on:) (defrule R (declare (no-loop TRUE)) ?d - (D (A 1)) = (modify ?d (B (+ ?d.B 1 Note that your initial assert needs to have a number in the B slot, or you'll get an error. On Jun 12, 2011, at 8:08 PM, Felix Chan wrote: Hi, I have been trying to understand the slot-specific functionality which is described in the JESS manual as follows: --- 6.18. The 'slot-specific' declaration for deftemplates Deftemplate definitions can now include a declare section just as defrules can. There are several different properties that can be declared. One is slot-specific. A template with this declaration will be matched in a special way: if a fact, created from such a template, which matches the left-hand-side of a rule is modified, the result depends on whether the modified slot is named in the pattern used to match the fact. As an example, consider the following: Jess (deftemplate D (declare (slot-specific TRUE)) (slot A) (slot B)) Jess (defrule R ?d - (D (A 1)) = (modify ?d (B 3))) Without the slot-specific declaration, this rule would enter an endless loop, because it modifies a fact matched on the LHS in such a way that the modified fact will still match. With the declaration, it can simply fire once. This behavior is actually what many new users expect as the default; the technical term for it is refraction. -- I tried the following without the slot-specific declaration, expecting an infinite loop to occur: (reset) (deftemplate D (slot A) (slot B)) (defrule R ?d - (D (A 1)) = (modify ?d (B 3))) (bind ?f (assert (D (A 1 (facts) (run) (facts) But I got the following outcome with no infinite loop: f-0 (MAIN::initial-fact) f-1 (MAIN::D (A 1) (B nil)) For a total of 2 facts in module MAIN. f-0 (MAIN::initial-fact) f-1 (MAIN::D (A 1) (B 3)) For a total of 2 facts in module MAIN. It seems slot-specific makes no difference in the outcome. I suspect I am missing a key concept here. Could someone explain? Thanks. Felix To unsubscribe, send the words 'unsubscribe jess-users y...@address.com ' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: On the Performance of Logical Retractions
On Jun 11, 2011, at 6:11 AM, Oliya wrote: But still I have a question: what type of truth maintenance is supported in Jess? Can you provide links to more information please. The logical conditional element is the only form of truth maintenance in Jess. I thought you said you were already using it? Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: On the Performance of Logical Retractions
on knowledge base systems. it's also been discussed on JESS mailing list numerous times over the years, so I would suggest searching JESS mailing list to learn from other people's experience. It's better to intelligently load knowledge base into memory as needed, rather than blindly load everything. Even in the case where someone has 256Gb of memory, one should ask why load all that into memory up front. If the test is using RDF triples, it's well known that RDF triples produces excessive partial matches and often results in OutOfMemoryException. The real issue isn't JESS, it's how one tries to solve a problem. I would recommend reading Gary Riley's book on expert systems to avoid repeating a lot of mistakes that others have already documented. On Thu, Jun 9, 2011 at 11:41 AM, Md Oliya md.ol...@gmail.com wrote: Thank you Ernest. I am experimenting with the Lehigh university benchmark, where i transfer OWL TBox into their equivalent rules in Jess, with the logical construct. Specifically, I am using the dataset and transformations, as used in the OpenRuleBench. As for the runtimes, I missed a point about the retractions. The fact is, even if the session does not contain any rules (no defrules, just assertions), loading the same set of retractions takes a considerable time. This indicates that the high runtime is mostly incurred by jess internal operations. but still, when the number of changes grows high (say more than 10%) the runtime is not acceptable, and rerunning with the retracted kb would be faster. I have another question as well: what type of truth maintenance method is implemented in jess? Do you solely rely on the Rete memory nodes and tokens for this purpose? --Oli. On Mon, Jun 6, 2011 at 7:37 PM, Ernest Friedman-Hill ejfr...@sandia.gov wrote: I don't think there's a particular reason in general. Retracting a fact takes only a little longer than asserting one, on average. But if we assume liberal use of logical, retracting a single fact could result in a sort of cascade effect whereby retracting a single fact would result in many other facts, and many activations, being removed also due to dependencies. Â All of that would take time. Â Still, your case seems extreme. Maybe there's something pathological about this particular case. On Jun 5, 2011, at 3:18 PM, Md Oliya wrote: Hi, I am doing some experiments with a set of rules which contain the logical CE. I intend to see the performance of Jess on a set of assertions as well as retractions. After some experiments, I found that the runtime for assertions is much less than that of retractions. In fact, the performance on retractions is so bad that I would rather re (run) jess on a retracted kb. A sample test case: The KB size, Â number of assertions, number of retractions, and number of rules are 100K, 50K, 1k, and 100, respectively. runtimes are initial run: 860ms, Â assertions:320ms -- Â retractions: 4s. Would you please give some hints on the reason? Thanks in advance. --Oli. - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov. To unsubscribe, send the words 'unsubscribe jess-users y...@address.com ' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov. To unsubscribe, send the words 'unsubscribe jess-users y...@address.com ' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com
Re: JESS: On the Performance of Logical Retractions
I think I need to see the actual test program, or otherwise we need to get on the same page somehow. As a counter example, here's a little program with no rules that asserts about 10,000 facts one at a time and then retracts them. It takes 1.9 seconds (including JVM startup) on my Macbook. If I comment out the retract part, it takes 1.6 seconds. These would be faster if the facts weren't being parsed out of strings this way, twice, but regardless of that, this doesn't bear out the idea that retractions are pathologically slow. (foreach ?a (create$ a b c d e f g h i j k l m nn o p q r s t u v w x y z) (foreach ?b (create$ a b c d e f g h i j k l m n o p q r s t u v w x y z) (foreach ?c (create$ a b c d e f g h i j k l m n o p q r s t u v w x y z) (bind ?x (str-cat ?a ?b ?c)) (assert-string (str-cat ( ?x )) (foreach ?a (create$ a b c d e f g h i j k l m nn o p q r s t u v w x y z) (foreach ?b (create$ a b c d e f g h i j k l m n o p q r s t u v w x y z) (foreach ?c (create$ a b c d e f g h i j k l m n o p q r s t u v w x y z) (bind ?x (str-cat ?a ?b ?c)) (retract-string (str-cat ( ?x )) On Jun 9, 2011, at 11:41 AM, Md Oliya wrote: Thank you Ernest. I am experimenting with the Lehigh university benchmark, where i transfer OWL TBox into their equivalent rules in Jess, with the logical construct. Specifically, I am using the dataset and transformations, as used in the OpenRuleBench. As for the runtimes, I missed a point about the retractions. The fact is, even if the session does not contain any rules (no defrules, just assertions), loading the same set of retractions takes a considerable time. This indicates that the high runtime is mostly incurred by jess internal operations. but still, when the number of changes grows high (say more than 10%) the runtime is not acceptable, and rerunning with the retracted kb would be faster. I have another question as well: what type of truth maintenance method is implemented in jess? Do you solely rely on the Rete memory nodes and tokens for this purpose? --Oli. On Mon, Jun 6, 2011 at 7:37 PM, Ernest Friedman-Hill ejfr...@sandia.gov wrote: I don't think there's a particular reason in general. Retracting a fact takes only a little longer than asserting one, on average. But if we assume liberal use of logical, retracting a single fact could result in a sort of cascade effect whereby retracting a single fact would result in many other facts, and many activations, being removed also due to dependencies. All of that would take time. Still, your case seems extreme. Maybe there's something pathological about this particular case. On Jun 5, 2011, at 3:18 PM, Md Oliya wrote: Hi, I am doing some experiments with a set of rules which contain the logical CE. I intend to see the performance of Jess on a set of assertions as well as retractions. After some experiments, I found that the runtime for assertions is much less than that of retractions. In fact, the performance on retractions is so bad that I would rather re (run) jess on a retracted kb. A sample test case: The KB size, number of assertions, number of retractions, and number of rules are 100K, 50K, 1k, and 100, respectively. runtimes are initial run: 860ms, assertions:320ms -- retractions: 4s. Would you please give some hints on the reason? Thanks in advance. --Oli. - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: On the Performance of Logical Retractions
I don't think there's a particular reason in general. Retracting a fact takes only a little longer than asserting one, on average. But if we assume liberal use of logical, retracting a single fact could result in a sort of cascade effect whereby retracting a single fact would result in many other facts, and many activations, being removed also due to dependencies. All of that would take time. Still, your case seems extreme. Maybe there's something pathological about this particular case. On Jun 5, 2011, at 3:18 PM, Md Oliya wrote: Hi, I am doing some experiments with a set of rules which contain the logical CE. I intend to see the performance of Jess on a set of assertions as well as retractions. After some experiments, I found that the runtime for assertions is much less than that of retractions. In fact, the performance on retractions is so bad that I would rather re (run) jess on a retracted kb. A sample test case: The KB size, number of assertions, number of retractions, and number of rules are 100K, 50K, 1k, and 100, respectively. runtimes are initial run: 860ms, assertions:320ms -- retractions: 4s. Would you please give some hints on the reason? Thanks in advance. --Oli. - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: random strategy
. - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Truth Maintenance
I don't see where page 139 says anything about dependencies between facts. It does talk about how the state of the *agenda* is maintained -- the list of rules that haven't fired yet. But the effects of rules that fired in the past are not, by default, undone. By default, there's no relationship between (aaa) and (bbb). Jess has the logical conditional element to specify dependencies among facts, and it can be used to easily implement your example below: (defrule simpleRule (logical (aaa)) = (bbb)) It's discussed on pages 114-116 of Jess in Action. On Jun 3, 2011, at 7:33 AM, Md Oliya wrote: Hi, I am doing some experiments with regards to truth maintenance. Assume that I have a rule like: (defrule simpleRule (aaa) =(bbb)) Asserting an (aaa) fact and (run)ning the rule will result in a new fact (bbb). Nevertheless, retracting (aaa) will not retract (bbb) as well, and I found it quite contrary to what was mentioned on page 139 of the book Jess in Action. Am I missing some config options? Thanks for your comments in advance. --Oli - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Jess and Clojure
It's been mentioned that It Would Be Cool (R) to integrate Jess and Clojure; I think that would ultimately have to mean that all of Jess's Lisp(esque) interpreter would be thrown out and replaced by Clojure's REP loop, Jess constructs would be defined as special forms in Clojure, etc. It would indeed be cool, as Clojure is a much better Lisp than JessLisp. The downside would be that you'd lose all semblance of CLIPS language compatibility, as the various quoting rules and other language minutae are different. That would make it minimally a candidate for Jess 8, or more likely a new product (CloJess, or something?) But honestly, I hadn't thought too much about the kind of integration you're experimenting with here. I'd be afraid someone would suffer a brain injury trying to keep all the levels of meta straight! Not to mention the cognitive dissonance of working with two similar-looking but uncomfortably different languages at once. If you like that sort of thing, though (and I historically do -- I've written systems that generate code that generates code) then it could be a lot of fun. On Jun 1, 2011, at 5:26 AM, Jason Morris wrote: Hi All, I was wondering if anyone else has experimented with (or is actually using) Jess with Clojure? I've been hacking around with it, and I've actually gotten Jess 7.2 to run on the latest Clojure build with a standard Sun 1.6 JVM. I'm attaching a little toy app for illustration purposes. For those who long to have the full power of a JVM LISP behind Jess, running it on Clojure seems promising. Ernest: Do you know of any potential snags? Cheers, Jason -- Morris Technical Solutions LLC consult...@morris-technical-solutions.com (517) 304-5883 clojure.zip - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Is Jess still alive, and Jess In Action
Jess in Action is still valid; there are some newer features since then, and some newer best practices, but nothing in the book is *wrong*. The release notes in the Jess 7.0 manual explicitly address the 6.x - 7.x transition and things that you might want to change, so they serve as a nice addendum to the book. Jess is still supported, and occasional updates are still being made, but active development of new features is on hiatus for now. On May 31, 2011, at 5:35 PM, Paul Gifford wrote: Hi, We're looking at a couple of Java rules engines, Jess among them. It's been a couple of years since the site has been updated - is Jess still under active development? I've started reading through Jess In Action. The book was published in 2003 - is it still applicable to the 2008 version of Jess? Thanks, Paul - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Creating identical independent engines in Java
You can use Rete.bsave() to write a copy of an engine to a stream, and then use Rete.bload() on a new instance of jess.Rete to turn it into a copy of the original. On May 7, 2011, at 4:04 PM, Theodore Patkos wrote: Hey all, I was wondering if there is a way to make an exact, yet independent, copy of a Rete engine's instance in Java (i.e., including the ruleset, working memory, agenda, activation order etc). Peering an engine only copies the ruleset; if, afterwards, one attempts to copy each fact from the initial engine to the peer, apart from matters of efficiency, there exists the possibility of activating rules that have already been activated in the initial engine before the peering. Thanx! Theodore To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Print Jess rule in detail using Java code
See http://www.jessrules.com/jess/docs/71/library.html#prettyprinting On Apr 23, 2011, at 1:47 PM, Vu Le wrote: In my Java code, I have: Rete engine = new Rete(); engine.batch(myrule.clp); … Now how do I print out, by Java code, LHS and RHS of the rules that are in myrule.clp? I had tried to use this to print the LHS: for (Iterator iterator = engine.listDefrules(); iterator.hasNext();) { Defrule rule = (Defrule) iterator.next(); for (Iterator iterator2 = rule.getNodes(); iterator2.hasNext();) { Node node = (Node) iterator2.next(); if (node.getNodeType() == 1) { System.out.println(-- + node); } } System.out.println(Action: + rule.getAction(0)); } But the output looks really annoying. Can anyone help me? - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Problem in Modfying a java Object
Read all of section 5.3 in the Jess manual, especially sections 5.3.3 and 5.3.4 . This is covered in detail. http://www.jessrules.com/jess/docs/71/memory.html#shadow_facts On Apr 3, 2011, at 11:44 AM, chownikhil wrote: Hello All, I have an object called Request in java. I am trying to modify the object by firing a jess rule but i don't find any changes in the object Request class: package proto; import java.io.*; public class Request implements Serializable { public String destination; public int passengerAge; public void setDestination(String dest) { destination } public void setPassengerAge(int personAge) { passengerAge} public String getDestination() { return destination; } public int getPassengerAge() { return passengerAge; } } Java code for accessing the jess rules : final Rete engine engine.eval((deftemplate Request (declare (from-class proto.Request; engine.eval((deftemplate Proposal (declare (from-class proto.Proposal; FileReader fp FileReader(C:\\Users\\Venkat\ \workspace\\nnayuni_contract-net_p5\\src\\SellerRules.clp); final Context context final Jesp parser Object result while(! result.equals(Funcall.EOF)) { try { result System.out.println(result); } catch (JessException e) { e.printStackTrace(); } } try { Request req Proposal temp Fact f f.setSlotValue(passengerAge, new Value(req.getPassengerAge())); f.setSlotValue(destination, new Value(req.getDestination())); engine.assertFact(f); engine.reset(); engine.run(); System.out.println(req.getPassengerAge()); } catch (JessException e) { e.printStackTrace(); } catch (UnreadableException e) { e.printStackTrace(); } jess rule : (defrule welcome-toddlers Give a special greeting to young children ?fact - (Request {passengerAge 3}) (modify ?fact (passengerAge 14))) -- View this message in context: http://old.nabble.com/Problem-in-Modfying-a-java-Object-tp31306294p31306294.html Sent from the Jess mailing list archive at Nabble.com. To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Function Parameters
Hi Derek, I'm trying to figure out where the problem might lie. Is the problem that eq an overloaded method, and Jess is calling the wrong overload? Jess can correctly call a method that takes a char as an argument, and in fact, it's smart enough to prefer the char overload if the argument is a one-character string. Or is it something else? I'm not sure what throws the ClassCastExcepton and why. Some code would help me understand! On Feb 16, 2011, at 3:14 PM, Derek Adams wrote: Hello Jess-Users, I have small jess/java issue that is causing quite a big problem. (call (call ?hcu joinTo projectStatus) eq active Y) The jess code above is performing the following: 1. In the inner call, it is calling the joinTo function on the instance of the HibernateCritieriaUtil object, with a parameter of projectStatus. 2. That call returns another HibernateCritieriaUtil instance to be used in the outer call. 3. The outer call is calling the eq function with 2 parameters, active and Y. The problem is coming when the function interprets Y as a string. active represents a column in the bean mapping and has a type of char. So when it compares active with a string Y, it throws a ClassCastException: type String cannot be cast to type char Suggestions? -- Derek Adams Lead Developer Arahant LLC Work: 615-376-5500 ext. 314 Cell: 270-543-0920 - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Rule firing during execution of RHS
It is atomic with respect to other rules firing; only one rule can be firing at a time. It's not atomic with respect to working memory changes, though; working memory can be changed by other threads while the RHS of a rule is executing. On Jan 7, 2011, at 12:47 PM, Nguyen, Son wrote: Hi, Execution of a rule RHS is sequential. But is it atomic? In other words, during that time, is it possible that other activated rules get fired? These activated rules include those that had been on the agenda or newly activated rules due to pattern matching caused by the RHS invocation of modify, assert or retract. Any feedback is greately appreciated. Son Nguyen - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Jess Access Control
On Jan 7, 2011, at 8:06 PM, Michael Eugene Artz wrote: It's a casting error but it doesn't make any sense to me why I would be getting that. userProfiles is a java.util.Set. The method Set.add() returns boolean (true means the add() succeeded, false means the object was already in the set.) So here you're mapping Integer to Boolean. profiles.put(new Integer(1), userProfiles.add(new Profile(1, Mike, Artz))); profiles.put(new Integer(2), userProfiles.add(new Profile(2, Suzy, Kolber))); profiles.put(new Integer(3), userProfiles.add(new Profile(3, Stan, Mikita))); profiles.put(new Integer(4), userProfiles.add(new Profile(4, Nikita, Kruschev))); Here you're assuming that the values in profiles are Profile objects, but as we said, they're Booleans. public Profile getProfile(int profileNumber) { //return new Profile(1, Mike, Artz); return (Profile)profiles.get(new Integer(profileNumber)); } Which is what the error says: the values are Booleans, not Profiles. The trace tells you exactly what line causes the errors, so a println() or two would have easily told you the whole story. java.lang.ClassCastException: java.lang.Boolean cannot be cast to Profile at DemoDatabase.getProfile(DemoDatabase.java:49) at Demo.processRole(Demo.java:31) at Demo.main(Demo.java:13) I wonder if I could this all much simpler and Im just wasting my time completely:( When I assemble a large program like this, I start with a small program that does one little thing, and I test it. I then add a little more, and test that, and so on. At each step, I make sure all the new code does what it's supposed to do. I keep all the test code so it can be run at any time to verify that the program still works. That way, you never find yourself looking at a big pile of code and wondering where the problem is: the problem is always just in that last little bit you just coded. Good luck! - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Rule with Java Object Issue in Eclipse Editor
Well, taken by itself, the Jess code doesn't define the template com_cts_bfs_tcg_bre_dto_BizObject. That definition happens in your Java code, as you said, so it's available at runtime, but the editor, left on its own to figure out your code, knows nothing about that. This is precisely the kind of thing that require* is made for. Put a defclass into a file, use require* to include it, and make that file available during editing. It can be missing at runtime, and require* won't complain. But that file will provide the hint that the editor needs to understand your code. On Jan 3, 2011, at 10:33 PM, debasish.da...@cognizant.com wrote: Hi all, Happy new year to all of you... I need one help. I was trying the following rule example, using the Java object model, and working absolutely fine as expected... ;; -- (defrule CalcInsuranceRiskHigh add rule comment here. (declare (salience 10)) (and (com_cts_bfs_tcg_bre_dto_BizObject (OBJECT ?driverObj)(noOfClaims ?noOfClaims )) (test ( ?noOfClaims 4 )) ) = (call ?driverObj setInsuranceRisk High) ) ;; -- (defrule CalcInsuranceRiskMedium add rule comment here. (declare (salience 10)) (and (com_cts_bfs_tcg_bre_dto_BizObject (OBJECT ?driverObj)(noOfClaims ?noOfClaims )) (test (= ?noOfClaims 2 )) (test (= ?noOfClaims 4 )) ) = (call ?driverObj setInsuranceRisk Medium) ) Note that, I am doing the following steps from Java code, and not having anything extra inside the .clp file other than the rule (i.e. defrule). a.) Adding the Java class () to engine classpath, Rete engine = new Rete(); engine.reset(); engine.defclass(com_cts_bfs_tcg_bre_dto_BizObject, com.cts.bfs.tcg.bre.dto.BizObject, null); b.) Creating the fact in working memory by providing the Java object (com.cts.bfs.tcg.bre.dto.BizObject) engine.definstance(com_cts_bfs_tcg_bre_dto_BizObject, bizObject, true, engine.getGlobalContext()); c.) Load and fire the rules. engine.batch(CalculateGrade.clp); engine.run(); Issue is while I am opening the rule in Eclipse editor (installed with JESS Eclipse plugin). The ERROR (Red Cross Mark in the left side of editor) is showing at (OBJECT ?driverObj) definition in Editor as follows - Undefined function or construct at token 'age' No such slot OBJECT in template MAIN::com_cts_bfs_tcg_bre_dto_BizObject at token 'OBJECT' No such variable driverObj Expected a '(', constant, or global variable at token ')' Could anyone please tell me, what might be the issue? Is there something, which I am still missing in order to comply with Jess Eclipse editor standard, although not creating any issue during rule firing time? I am using the JESS 7.1.0 evaluation version. Regards DEBASISH DALUI (122816) -- Cognizant Technology Solutions US Corp Cell : +1-216-835-2902 This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. Any unauthorised review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this e-mail is strictly prohibited and may be unlawful. - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Hello To Jess User Group and How Is Jess Doing?
On Jan 2, 2011, at 4:19 PM, James Owen wrote: Jess comes with source code for an extra $100 but commercial applications have to be worked out with Sandia Labs. Unfortunately, Jess is NOT available (legally) outside the USA but is totally free (with source code) to military, government and/or students/teachers at approved universities. Jim, I just wanted to clarify a bit, as there does seem to be a lot of misinformation out there concerning how Jess is licensed. Jess is available under one of four main licensing agreements. Three of these options are available worldwide -- it is not true that Jess is unavailable outside the US. Source code is indeed available as part of many agreements, but in no case is it specifically available for $100. First, Sandia offers a commercial license, comparable in cost to other commercial offerings; you can indeed license the source code, or just the binary. This is the most common arrangement. Second, Jess is available free of charge for academic use at accredited institutions. This was Jess's original audience and we are happy to continue to serve them. Third, Jess is available for a nominal fee to consultants and third- party solution developers. Fourth, because Jess is a product of a US government agency, it is available at no cost to other such agencies, subject to various rules and regulations. - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Hello To Jess User Group and How Is Jess Doing?
Happy holidays to all! On Dec 31, 2010, at 5:02 AM, Wolfgang Laun wrote: On 30 December 2010 21:14, Ross Mohan rmoh...@yahoo.com wrote: So it's jess us folks here, until the thaw, eh? Jess and snow ;-) To Jess, her Father and all midhusbands and midwifes: continuing success and no stack dumps in 2011! -W -ross --- On Thu, 12/30/10, Wolfgang Laun wolfgang.l...@gmail.com wrote: From: Wolfgang Laun wolfgang.l...@gmail.com Subject: Re: JESS: Hello To Jess User Group and How Is Jess Doing? To: jess-users@sandia.gov Date: Thursday, December 30, 2010, 2:56 PM At this time of the year, on the northern hemisphere, it's more likely to be a white hole. Just wait until the thaw sets in ;-) -W On 30 December 2010 20:02, Donald Paul Winston satchwins...@yahoo.com wrote: I think the mailing list is on vacation for the holidays. I sent one message a couple of days ago and it fell into a black hole. On Dec 30, 2010, at 11:26 AM, dc tech wrote: Rejoining the Jess community after a multi-year hiatus and notice that the mailing list has been very quiet. I am curious to see how Jess is doing now a days? Any impact from things like jBoss rules or other engines? Is the community still pretty active? Happy Holidays to everyone ! To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: representation of deftemplate from deffacts
On Nov 22, 2010, at 3:38 AM, debasish.da...@cognizant.com wrote: Hi Jess-users, Note that Jess comes with a fairly detailed manual, and it's worth reading it all the way through. Everything I'll cover here is explained in the manual. Just trying to understand, how the following deffacts can represent in deftemplate? (deffacts MAIN::opposites (opposite-of shore-1 shore-2) (opposite-of shore-2 shore-1)) There are two kinds of templates: ordered and unordered. These facts use an ordered template. You can tell because there are no slot names being used. Jess is creating a *implied* template for this as below. (deftemplate MAIN::opposite-of (Implied) (multislot __data)) Yes. Ordered templates are almost always created automatically by Jess, and their single multislot -- whose name is never normally displayed -- is named __data. In fact, that's how Jess can tell which is an ordered template: because it has a single slot named __data. Here the term *__data* is not very much clear, since if I keep this as template explicitly as follows – (deftemplate MAIN::opposite-of (multislot __data)) Not sure what's not clear -- that's the name of the slot. The ruleset is running fine as expected, and JESS is not creating again the *implied* template in this case. Yes, because it already exists. But, if I change it to some other name, say *data* instead of *__data*, JESS engine throwing a exception (Jess reported an error in routine Jesp.parseFact.)while parsing the above fact. Yes, because when Jess parses the facts, it expects to find an ordered template by that name, but it does not: it finds an unordered template whose single multislot has some other name. There's no slot named __data, and so Jess has no idea how to use this template in this situation. Also, if I create the template as follows using *slot*. (deftemplate MAIN::opposite-of (slot shore-1) (slot shore-2)) This is now an unordered template. For this kind of template, the slots names are always shown in facts and in rule patterns. You have to change everything. But in this case, the deffacts needs to be defined as follows, which seems not same as mentioned above, and the rule is not working as expected. Yes. If you change the data structure, then you have to change how the data is initialized, as well as changing the code that works with the data. This situation should be familiar in any programming language. - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Lisp quote() an ' function
In many forms of Lisp, an unadorned symbol is taken to be a variable; (quote) lets it evaluate to itself. In the CLIPS language used by Jess, variables always have a wart of some kind (? or $?) and so a plain symbol is unambigiously just a symbol. On Nov 21, 2010, at 3:59 AM, Donald Winston wrote: Some things are coming back to me from my college AI class several years ago when we dabbled in Lisp (on a mainframe). I remember having to use the quote function frequently. I believe an apostrophe was syntatic sugaring for the same thing. How come this not necessary in Jess? Donald Paul Winston satchwins...@yahoo.com - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: assertFact() and java.lang.String
STRING and SYMBOL are two different data types; here's one of the many forum threads where this has been discussed: http://www.mail-archive.com/jess-users@sandia.gov/msg07900.html Calling 'new Value(a)' creates a value of type STRING, while the values in your retract-string call are SYMBOLs. Check out the other constructors of jess.Value; they are documented extensively. On Nov 9, 2010, at 12:23 PM, kartik tadanki wrote: Hi, Question How can I use Value object to put in simple strings instead of java.lang.String instances.? -I wish to be able to assert facts from Java such that the rules in the knowledge base can apply to them. -Currently, I use assertString(). -When I use assertFact() the rules do not apply to the fact as with assertString() This is because the slot values are now java.lang.String instances. How can I avoid building the string for assertString() and use assertFact() such that the rules process facts thus asserted? My code: = // (deftemplate Authorization (slot subject ) (slot predicate) (slot object)) //create fact Fact fact = new Fact(Authorization, r); set values Value va = new Value(a); fact.setSlotValue(subject, va); Value vb = new Value(b); fact.setSlotValue(predicate, vb); Value vc = new Value(c); fact.setSlotValue(object, vc); //assert the fact rete.assertFact(fact); // this retractString has no effect. rete.retractString((Authorization (subject a) (object c) (predicate b))); = Thank you, -Kartik Tadanki - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Unruly rules
On Nov 7, 2010, at 3:00 AM, Donald Winston wrote: This works but seems to me to defeat the purpose of using a rule engine. Is this where predicate constraints are used? I did the following and it appears to work: (defrule set-dataset-isFree (page show-dataset.xslt) (dataset (nobs ?nobs)) ?x - (dataset (nvars ?nvars)) (subscription-prices (maxDataElements ?y: ( ?y (* ?nobs ? nvars = (modify ?x (isFree FALSE))) Am I going down the right path here? It looks like I'll be doing a lot of this. Yes, you're going down the right path -- this is definitely the right way to do it. However, there's a mistake here. By using two different dataset patterns in the above, you've written a rule that can match using the nobs slot from one dataset, and nvars from another. If there's more than one dataset fact this is unlikely to be what you want. Instead, you want to just use the single pattern from the original version: ?x - (dataset (nobs ?) (nvars ?)) - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Strange behaviour of defadvice
Yes, a function can have only one advice. This wasn't originally the case, but experience showed that allowing multiple advice per function caused problems -- it was too easy to create infinite loops, for example. You can solve your problem with a before-advice which unbinds the variables, calls bsave explicitly, rebinds the variables, and then returns. If you check the documentation, it explains that explicitly returning from a before-advice will result in the adviced function not being called automatically. On Oct 7, 2010, at 8:44 AM, Gaëtan Pruvost wrote: Hi everybody, I have a problem with defadvice's behavior. It looks like you can't add both a before and an after advice to the same function. Here is an example that demonstrates it (deffunction f () (printout t during f crlf)) (defadvice before f (printout t before f crlf)) (defadvice after f (printout t after f crlf)) (f) It prints: Jess (batch test.clp) during f after f Jess Looks like the after overwrote the before one and there is no way to define both at the same time... I'm new to Jess so I hope this question is not stupid but i looked in documentation and in the old mailling-list messages and found no explaination for it. Is it the intended behaviour (in which case it would be good to precise it in the doc) or a bug? I'm using the last Jess71p2. I needed this to unbind global variables before a bsave and rebind after the bsave (this variable refers to a java Logger which is not serializable). I've found another solution wihtout using defadvice but I find the defadvice more elegant. Best regards -- *** Gaëtan PRUVOST LIMSI-CNRS BP 133 91403 Orsay Cedex France Tel:+33 1 69858110 http://www.limsi.fr/Individu/pruvost/ *** gaetan_pruvost.vcf - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: defquery
That URL is the manual for Jess 5.2 (from May 2001, almost ten years ago!) The current version is 7.1, and the current manual is at http://www.jessrules.com/jess/docs/71 . Modern query documentation is at http://www.jessrules.com/jess/docs/71/queries.html . On Oct 6, 2010, at 3:04 PM, kartik tadanki wrote: Hi, I just noticed that the defquery example doesn't work as listed on the site. http://www.jessrules.com/jess/docs/52/language.html Is there a newer version somewhere that I am unaware of? Just came by the error, will try to handle it and post a working code on the mailing list. -Kartik Tadanki - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Re: JESS on android device
Unfortunately the Android platform is missing the entire java.beans package, which is rather important to Jess; that's the source of the error you're seeing here. If you Google java.beans and Android, you will find forum threads where people discuss backporting java.beans to Android; it's apparently possible, although there are potentially licensing issues there. Alternatively, you could modify Jess itself not to use java.beans; that would be a worthwhile project for us to do at some point, in any event. In any case, Jess can't be used on Android out of the box. On Oct 5, 2010, at 3:40 AM, PramodJagtap wrote: I tried to use JESS jar files (jess.jar and jsr94.jar) in android application. Somehow it is having issue while creating instance of Rete and it is throwing following exception: ** I/System.out( 397): *** FATAL ***: Can't initialize Jess W/System.err( 397): Jess reported an error in routine Funcall.loadIntrisics. W/System.err( 397): Message: Missing non-optional function class. W/System.err( 397):at jess.Funcall.goto(Unknown Source) W/System.err( 397):at jess.Funcall.clinit(Unknown Source) W/System.err( 397):at jess.ValueFactory.init(Unknown Source) W/System.err( 397):at jess.Rete.init(Unknown Source) W/System.err( 397):at jess.Rete.init(Unknown Source) W/System.err( 397):at gov.sandia.jess.example.pricing.PricingEngine.init( PricingEngine.java:17) W/System.err( 397):at gov.sandia.jess.example.pricing.demo.TestJESS.onCreat e(TestJESS.java:24) W/System.err( 397):at android.app.Instrumentation.callActivityOnCreate(Inst rumentation.java:1047) W/System.err( 397):at android.app.ActivityThread.performLaunchActivity(Acti vityThread.java:2627) W/System.err( 397):at android.app.ActivityThread.handleLaunchActivity(Activ ityThread.java:2679) W/System.err( 397):at android.app.ActivityThread.access$2300(ActivityThread .java:125) W/System.err( 397):at android.app.ActivityThread$H.handleMessage(ActivityTh read.java:2033) W/System.err( 397):at android.os.Handler.dispatchMessage(Handler.java:99) W/System.err( 397):at android.os.Looper.loop(Looper.java:123) W/System.err( 397):at android.app.ActivityThread.main(ActivityThread.java:4 627) W/System.err( 397):at java.lang.reflect.Method.invokeNative(Native Method) W/System.err( 397):at java.lang.reflect.Method.invoke(Method.java:521) W/System.err( 397):at com.android.internal.os.ZygoteInit$MethodAndArgsCalle r.run(ZygoteInit.java:868) W/System.err( 397):at com.android.internal.os.ZygoteInit.main(ZygoteInit.ja va:626) W/System.err( 397):at dalvik.system.NativeStart.main(Native Method) W/System.err( 397): Caused by: java.lang.VerifyError: jess.d9 W/System.err( 397):at jess.du.a(Unknown Source) W/System.err( 397):at jess.Funcall.a(Unknown Source) W/System.err( 397):... 20 more I/AndroidRuntime( 397): AndroidRuntime onExit calling exit(0) I/ActivityManager( 66): Process gov.sandia.jess.example.pricing.demo (pid 397) has died. ** I am not sure if this is the correct way of using JESS in an android app. Can someone please tell me how to do that ? Thanks, Pramod PramodJagtap wrote: Hello, I am trying out existing rule engines on android devices (specifically Android OS 2.2 devices) . While searching I came across Jena, JESS and JTP as suitable candidates. I tried porting Jena on android but somehow it's ARQ support is causing some issues. So I was wondering if it's possible to use JESS on android devices and if yes, can someone provide me few pointers? Thanks in advance. Pramod -- View this message in context: http://old.nabble.com/JESS-on-android-device-tp29885003p29885044.html Sent from the Jess mailing list archive at Nabble.com. To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: addSlot without any default value
Every slot always has a default value. Slots aren't like entries in a map, that either exist or not; slots are like member variables in a Java class: they always have some value associated with them. If you have slots you want to store numbers in, then set the default to a number like new Value(0, RU.INTEGER). On Oct 2, 2010, at 7:13 PM, Santiago Almirón wrote: Hello, First, excuse me for my English. My native languaje is Spanish. I am writing to you because I have a little problem with Jess's API, especially with addSlot from Class Deftemplate. I do not know how I add a new slot without any default value. The main problem is with FLOAT and INTEGER types. Because, some Facts which I work do not have this slot instanced. If a give a default value, some rules will be fired . I usually add SYMBOL slots in this way: addSlot(Name, Funcall.NIL, SYMBOL); And then, when I assert a new Fact, a (Name nil) appears if I do not give any value. SYMBOL type is not a problem, but FLOAT and INTEGER types is a problem for me. I appreciate your time. Thanks in advance. Best regards Santiago To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Jess clp, JessML and Strings with embedded XML
Looks like XMLPrinter isn't (properly) escaping your embedded XML. Thanks for the report. On Oct 1, 2010, at 12:10 PM, Nguyen, Son wrote: Hi I ran into an issue with String having embedded XML content. Jess clp and JessML behave differently. I have a clp function that prints out the String parameter. I use the Jess XMLPrinter to transform the clp file into JessML. They yield different results. In the clp case, the string is properly handled, that is untouched. Well, at least I think it is. In the JessML case, the string is 'interpreted' and the escaped XML becomes real XML. Any feedback is greatly appreciated. Son Nguyen Here is the clp: (deffunction aaa (?string) (printout t This is what I got crlf ?string)) (defrule rule1 = (aaa ?xml version=\1.0\ encoding=\UTF-8\? xmlDoc version=\1.0\ value name=\data\ lt;Values version=\2.0\gt; lt;value name=\xml\gt;set in cell lt;/valuegt; lt;/Valuesgt; /value /xmlDoc )) (reset) (run) The ouput for the clp run: ?xml version=1.0 encoding=UTF-8? xmlDoc version=1.0 value name=data lt;Values version=2.0gt; lt;value name=xmlgt;set in cell lt;/valuegt; lt;/Valuesgt; /value /xmlDoc The output for the JessML run: ?xml version=1.0 encoding=UTF-8? xmlDoc version=1.0 value name=data Values version=2.0 value name=xmlset in cell /value /Values /value /xmlDoc - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Setting slot values using Java api
ANY is a slot type, not a Value type. The concept you're looking for simply doesn't exist in Jess; you can't have a Value of unknown or unspecified type, any more than a Java object can have unknown type. A Java object always knows its exact class, just as a jess Value always knows its exact type. A method like the one below should throw an exception if the value of the type argument is unrecognized. A couple of Jess programming tips: the FLOAT type is actually a Java double, so I'd use Double.parseDouble() here (the Jess type name comes from CLIPS). Also, you have to use the LongValue class to construct a Value of type long, or you'll get a runtime error. Finally, a Java tip: you can (and should) just write else if (STRING.equals(type)) Comparison to a boolean literal is never necessary. On Sep 22, 2010, at 1:04 AM, Donald Winston wrote: When the slotType is ANY my value is UNKNOWN. So the RU.ANY data type cannot be used this way and I have to use one of the others? ... fact.setSlotValue(name, getJessValue(slotType, value)); ... private Value getJessValue(String type, String value) throws JessException { if (ANY.equals(type) == true) return new Value(value, RU.ANY); else if (STRING.equals(type) == true) return new Value(value, RU.STRING); else if (INTEGER.equals(type) == true) return new Value(Integer.parseInt(value), RU.INTEGER); else if (FLOAT.equals(type) == true) return new Value(Float.parseFloat(value), RU.FLOAT); else if (SYMBOL.equals(type) == true) return new Value(value, RU.SYMBOL); else if (LONG.equals(type) == true) return new Value(Long.parseLong(value), RU.LONG); else return new Value(value, RU.ANY); } - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: ordered facts slotName=__data and slotType = ?
Don't go by slot data types, which are, indeed, not used by Jess and by default contain the meaningless value ANY. Use the slot type, which is always relevant. Note that a regular slot (i.e., not a multislot) could still contain a Value of type RU.LIST. On Sep 21, 2010, at 3:52 AM, Donald Winston wrote: Is it true that unordered facts always have a slot name of __data and a slot type of RU.ANY? How come the slot type is not RU.LIST? So If I'm iterating through the fact list and I encounter a slot name of __data it will always be a list and I don't need to fetch the slot type? (I think I remember somewhere that the types are not really used at the moment) - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Setting slot values using Java api
It's as dangerous in Java as it is in other languages. Just the other day I helped somebody on JavaRanch who spent days trying to figure out why their loop never ran: boolean loopWhileFalse = false; while (loopWhileFalse = false) { ... On Sep 22, 2010, at 2:05 PM, Donald Winston wrote: Yeah, I know. It's one of my quirky things. I think it's easier to read. I also refuse to use the ++ operator. I prefer i = i + 1. Pascal forever! On Sep 22, 2010, at 7:28 AM, Ernest Friedman-Hill wrote: Finally, a Java tip: you can (and should) just write else if (STRING.equals(type)) - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Lisp is maddening
That's extremely close; the only problem is on the last line of the defglobal: (?hash-set) is an attempt to call the function whose name is in ?hash-set. That's not a function name, it's a map, so it doesn't work (the error is method name expected, as Jess tries to call a method on that object). You want the progn to return ?hash-set, not (?hash-set) -- just drop those parentheses and you're good to go. Another way to do this that would involve less typing: Jess lists turn into arrays when passed to Java functions. So you could do this: (import java.util.*) (defglobal ?*usps-state-code* = (new HashSet (call Arrays asList (list AL AK AS ... On Sep 18, 2010, at 9:24 AM, Donald Winston wrote: Why doesn't this work? (defglobal ?*usps-state-codes* = (progn (bind ?hash-set (new java.util.HashSet 59)) (call ?hash-set add AL) (call ?hash-set add AK) (call ?hash- set add AS) (call ?hash-set add AZ) (call ?hash-set add CA) (call ?hash-set add CO) (call ?hash- set add CT) (call ?hash-set add DE) (call ?hash-set add DC) (call ?hash-set add FM) (call ?hash- set add FL) (call ?hash-set add GA) (call ?hash-set add GU) (call ?hash-set add HI) (call ?hash- set add ID) (call ?hash-set add IL) (call ?hash-set add IN) (call ?hash-set add IA) (call ?hash- set add KS) (call ?hash-set add KY) (call ?hash-set add LA) (call ?hash-set add ME) (call ?hash- set add MH) (call ?hash-set add MD) (call ?hash-set add MA) (call ?hash-set add MI) (call ?hash- set add MN) (call ?hash-set add MS) (call ?hash-set add MO) (call ?hash-set add MT) (call ?hash- set add NE) (call ?hash-set add NV) (call ?hash-set add NH) (call ?hash-set add NJ) (call ?hash- set add NM) (call ?hash-set add NC) (call ?hash-set add ND) (call ?hash-set add MP) (call ?hash- set add OH) (call ?hash-set add OK) (call ?hash-set add OR) (call ?hash-set add PW) (call ?hash- set add PA) (call ?hash-set add PR) (call ?hash-set add RI) (call ?hash-set add SC) (call ?hash- set add SD) (call ?hash-set add TN) (call ?hash-set add TX) (call ?hash-set add UT) (call ?hash- set add VT) (call ?hash-set add VI) (call ?hash-set add VA) (call ?hash-set add WA) (call ?hash- set add WV) (call ?hash-set add WI) (call ?hash-set add WY) (?hash-set))) (printout t (call ?*usps-state-codes* contains VA) crlf) I need to have a global variable that will contain state code values after a (reset). list AL AK ... works but a HashSet would be more efficient. A jess list is not a collection so I can't use the HashSet(Collection) constructor. - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Retrieving slot and multislot values
I don't know the context (sorry) in which you're doing this, so you'll have to make up your own mind. Read this for some info: http://www.jessrules.com/jess/docs/71/library.html#resolution You can always use the global context for a Rete object by calling Rete.getGlobalContext() . If you absolutely, positively know that a value contains no variables, and no function calls that produce a variable or reference a Rete object, then you can get away with passing null -- but getGlobalContext() is safer, of course. On Sep 15, 2010, at 11:02 AM, Donald Winston wrote: /* I need to retrieve slot and multislot values. */ Value v1 = fact.getSlotValue(slotName).toString()); /* Assuming above is ok */ Value v2 = fact.getSlotValue(multiSlotName); ValueVector vv = v2.listValue(context); where or how do I construct an appropriate context? Do I need to do this for v1 also or is toString() good enough? - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: JessWiki Problems
Well, the problem with Wiki spam is that whenever you edit something, the previous version is preserved. Deleting the spam leaves it still Google-accessible. Sandia does not like this in the least, especially given the content of the spam we were seeing. The current Wiki software would have to be modified to provide some kind of doomsday button that truly removed spam content, completely. That's really the deal. On Sep 13, 2010, at 2:45 AM, Jason Morris wrote: Hi Ernest, I can off-load you from having to admin the wiki if you can rig it notify me by email of changes. The reason I couldn't keep up with it either was that I simply didn't have time to check every thing for spam. Can we quarantine edits until they are moderated? If so, I'll lend a hand. The wiki was too nice a community to have it shut down. Cheers, Jason On Mon, Sep 13, 2010 at 12:52 AM, Ernest Friedman-Hill ejfr...@sandia.gov wrote: No, those pages don't exist. The NPE is because the Wiki storage is currently read-only, so the pages can't be created. The Wiki is read- only because I simply couldn't keep up with the spammers fast enough. On Sep 12, 2010, at 11:07 PM, Donald Winston wrote: http://www.jessrules.com/jesswiki/view?UsingRegularExpressions http://www.jessrules.com/jesswiki/view?AdvancedPatternMatching http://www.jessrules.com/jesswiki/view?PatternBindings and some others are returning NullPointerExceptions. Something must be missing. - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . -- Cheers, Jason -- Morris Technical Solutions LLC consult...@morris-technical-solutions.com (517) 304-5883 - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: CE can't be bound to a variable
Your and/or version is actually not equivalent to the /|| version. and and or, when nested outside of patterns, match separate facts -- i.e., (and (f (s 1) (f (s 2)) means a fact 'f' with 1 in the slot 's', and another fact 'f' with 2 in the slot 's'. Your or can't be bound to a variable because each branch contains two patterns and so will match two facts (although the two might actually not be distinct -- i.e., it could still match the same fact twice.) There are also predicate functions named and and or which are distinct from these conditional elements of the same names. They are what you want to use, perhaps in a test CE for clarity: (contactInfo (street ?s) (pob ?p)) (test (or (and (eq ?s ) (eq ?p )) (and (neq ?s ) (neq ?p On Sep 12, 2010, at 1:33 AM, Donald Winston wrote: I got the following rule to work: (defrule validate-contactInfo-street validate contactInfo's street ?fact - (contactInfo {street == pob == || street != pob != }) = (modify ?fact (streetError street xor po box is required))) But I can't get the old style version of this to work. I don't know why. (defrule validate2-contactInfo-street validate contactInfo's street ?fact - (or (and (contactInfo (street )) (contactInfo (pob ))) (and (contactInfo (street ~)) (contactInfo (pob ~ = (modify ?fact (streetError street xor po box is required))) It says CE can't be bound to a variable. The ((( look ok to me. - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: JessWiki Problems
No, those pages don't exist. The NPE is because the Wiki storage is currently read-only, so the pages can't be created. The Wiki is read- only because I simply couldn't keep up with the spammers fast enough. On Sep 12, 2010, at 11:07 PM, Donald Winston wrote: http://www.jessrules.com/jesswiki/view?UsingRegularExpressions http://www.jessrules.com/jesswiki/view?AdvancedPatternMatching http://www.jessrules.com/jesswiki/view?PatternBindings and some others are returning NullPointerExceptions. Something must be missing. - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Nested not conditional element with slots referring to facts
It's definitely a bug, and no patch has been released yet. To work around it, you could add an extra pattern to the rule right before the test and after the or: (defrule r3 (s) (or (not (a)) (and ?x - (a) (b ?x) ) ) (initial-fact) (test (= qwe asd)) = ... Alternatively you could move the test before the or. On Sep 7, 2010, at 5:10 AM, Henrique Lopes Cardoso wrote: Hi, Is there any update on this issue? Since I did not get any answer to my last question in the previous e-mail (below), I am asking again: - Is there a way to stop Jess from transforming rules and keep the original coding, possibly with some loss of performance? Or even better: is the bug solved? Thanks, Henrique Henrique Lopes Cardoso wrote: Hi again, In the sequel of this problem, I've fond another (possibly related) situation where the rule does not seem to compile correctly. I managed to simplify the example to the following rule: (defrule r3 (s) (or (not (a)) (and ?x - (a) (b ?x) ) ) (test (= qwe asd)) ; stupid test, just to expose the problem = (printout t t! crlf) ) Using (ppdefrule), we see that this rule compiles to: (defrule MAIN::r3 (or (and (s) (not (a))) (and (s) ?x - (a) (and (b ?x) (test (= qwe asd) = (printout t t! crlf)) Therefore, the test is not done in the first branch of (or). Is there a way to stop Jess from transforming rules and keep the original coding, possibly with some loss of performance? The point here is to avoid the apparently buggy transformations that are being made. Thanks. Henrique Ernest Friedman-Hill wrote: Indeed, the rule doesn't seem to compile correctly; the two ?x's are not merged. Jess (ppdefrule r) (defrule MAIN::r (initial-fact) (not ?x - (and ?x - (a ?_021__blank_2) (not (b ?_0022_x = (printout t \sure thing!\ crlf)) On Jul 20, 2010, at 4:04 PM, Henrique Lopes Cardoso wrote: Actually, asserts do work, because (deffacts) are added to working memory by a call to (reset). This is wy I am calling (facts) before (run), to make sure facts are in working memory as intended. Anyway, I tried (assert)ing them one by one and it still does not work as expected. It must be something else. Henrique To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: If else enhanced into Jess7.1
Didn't we just answer this question the other day on this list? Yes, in older versions of Jess, that last else would be interpreted as one of the elements of the first else clause, and taking the else would execute both function calls. But Jess 7.1 parses if-then-else more carefully, and the repeated else is caught and reported as an error. On Sep 6, 2010, at 2:15 AM, avdheshdi...@hsbc.co.in wrote: I observed a difference between 7.1 and 7.0 where an if can have multiple else was not result an error into 7.0 but 7.1 can catch this wrong block. Is this true or I have misunderstood the thing. Sample code : (if ( 5 9) then (printout t Test -1 ) else (printout t Test -2 ) else (printout t Test - 3 ) ) In 7.0 the code results in :: Test-2 Test-3 While 7.1 :: Exception in thread main Jess reported an error in routine Jesp.Jesp.parseFuncall. Message: No new blocks after 'else' block in 'if' at token 'else'. Avdhesh DIXIT Consultant Specialist | HSBC Technology and Services - Global Technology HSBC Software Development (India) Private Limited - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Difference between dates
I don't know how this could be; if you have a time difference in milliseconds, and you divide it by 8640, you have a time difference in days. The number of days in a month does not enter into it at all. On Sep 3, 2010, at 6:05 AM, ANA TANASESCU wrote: Hallo again, I have read on JessWiki about working with Dates and I have found a few interesting functions. I need in my program to calculate the difference between two dates (number of days). Therefore, I have converted the date in milisecond, I have used the diff-time function (http://www.jessrules.com/jesswiki/view?DiffTime) and converted the result in days. First it seems to work, but if I use month like february it looks that this function considers that all months have 30 days. I thought that after converting in miliseconds I could use this function like datediff in ACCESS. What shall I do? Best regards, Ana - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Get the current year
On Aug 31, 2010, at 11:58 PM, Donald Winston wrote: int year = Calendar.getInstance().get(Calendar.YEAR); But you have to use static methods. Jess doesn't appear to let you do this. Sure it does! Two different ways to write this: 1) (import java.util.Calendar) (bind ?year ((Calendar.getInstance) get (Calendar.YEAR))) 2) (import java.util.Calendar) (bind ?year ((call Calendar getInstance) get (get-member Calendar YEAR))) - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Clear screen
You could check out this link on clearing the text console from Java: http://faq.javaranch.com/java/HowToClearTheConsole On Aug 30, 2010, at 6:28 AM, ANA TANASESCU wrote: Hello everyone, I am writing a program that uses the WHILE function. When the user select a certain option the program displays a message and fires some rules. My question is which is the function in Jess for clearing the screen so that my screen could be clear whenever I choose a new option. Best regards, Ana - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: is this a bug in Jess71p2?
Yes, this is a bug in Jess 7.1p2. Any test CE can always be rewritten by simply attaching the condition to the previous CE; equivalently, you could rewrite this rule by putting the test before the or. On Aug 23, 2010, at 10:36 AM, tony.n.tar...@us.hsbc.com wrote: Hi, In the following code, the buy-car rule should not fire. It does not fire in Jess 7.0, but it fires in Jess71p2. Is there an issue with the 'or' condition causing the 'test' to succeed incorrectly in 7.1? Thanks, Tony (watch all) (deftemplate car ( slot price) ) (deffunction get-false() (return FALSE) ) (defrule buy-car ?candidate - (or ( car ( price ?m: ( ?m 2) ) ) ( car ( price ?m: ( ?m 10) ) )) (test (get-false)) = (printout t this rule should not have fired crlf) ) (assert (car (price 18000))) (run) - ** This E-mail is confidential. It may also be legally privileged. If you are not the addressee you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return E-mail. Internet communications cannot be guaranteed to be timely, secure, error or virus-free. The sender does not accept liability for any errors or omissions. ** SAVE PAPER - THINK BEFORE YOU PRINT! - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Get the current year
The java.util.Calendar class is available for this purpose. On Aug 24, 2010, at 12:08 PM, ANA TANASESCU wrote: Hello everybody, I want to define a rule that makes the difference between the year of the current date and the year from a slot in my ontology. Is there a function that gets the current date or the year from the current date? I am looking forward for your answer. Best regards, Ana - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Rule Translators?
Be careful to distinguish RuleML, which is a proposed standard rule language, from JessML, which is an XML-based rule format natively supported by Jess. The point of JessML, really, is that it's easier to manipulate XML than the Lisp-like Jess rule language in code, so if you want to write some kind of translator, GUI, or other tool for manipulating Jess code, using JessML will make it much easier to do. So in any case, JessML exists so that's it's very simple for you to create your own special-purpose front ends like what you describe. On Aug 24, 2010, at 12:42 PM, Donald Winston wrote: What's the possibility of some sort of rule translator for Jess. One of the reasons for using a rule engine in a typical business app is to separate the business rules from the rest of the application so non programmers can work with the rules. (Although in my experience we end up with programmers developing the rules anyway) I think it's going to be difficult to convince my clients to let me use Jess if this is a priority for them. I believe most will be put off by the Lisp language that Jess uses. Even if software engineers will be writing the rules from some sort of documentation they might not like it. I know there's a RuleML effort. But to be really good the translation would have to go both from ML - Lisp and Lisp - ML. In addition the rules developer would not be editing the ML directly but an english like language to express the rules. This would probably put a straight jacket on how Jess is used in these kinds of apps(which may be a good thing). (I've decided I like Jess especially because these days Blaze Advisor costs six figures! Drools is a frigging elephant) I'm going to use it for a prototype app I've had in mind. To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: How do I assert ordered facts from a map
Basically for the same reason that you can't say something like this in Java: String theMethodName = toString; String myString = myObject.(theMethodName)(); but instead you have to use reflection to find the method toString and call it using the Method object. The compiler needs to know the correct template to use to compile the code, and it can't do that if the name of the template is in a variable. Now, you may ask *could* it work the way you want? Indeed, it could -- but it doesn't at this time. We've talked in the past about allowing this kind of thing, and it has its pros and cons. On Aug 13, 2010, at 11:05 AM, Donald Winston wrote: Can anyone explain to me why this does not work? Why can't I use (deffacts initial-facts Facts to trigger a few appropriate salient initialization rules. (assert-request-parameters)) (defrule assert-request-parameters-rule Assert stored data one time. (declare (salience 100)) ?x - (assert-request-parameters) = (foreach ?key (((fetch request-parameter-map) keySet) iterator) (build str-cat (assert ( ?key ((fetch request- parameter-map) get ?key) ; why not (assert (?key ((fetch request-parameter-map) get ?key (retract ?x)) (bind ?map (new java.util.HashMap)) (?map put one 1) (?map put two 2) (?map put three 3) (store request-parameter-map ?map) (reset) (facts) (run) (facts) Jess, the Rule Engine for the Java Platform Copyright (C) 2008 Sandia Corporation Jess Version 7.1p2 11/5/2008 This copy of Jess will expire in 207 day(s). f-0 (MAIN::initial-fact) f-1 (MAIN::assert-request-parameters) For a total of 2 facts in module MAIN. f-0 (MAIN::initial-fact) For a total of 1 facts in module MAIN. - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: How do I assert ordered facts from a map
Java classes are totally optional in Jess -- in fact, templates and facts created directly from the Jess language are always more efficient. If Jess were to store the properties of an object in a Map -- so that they were dynamic and extensible at runtime -- then it would be considerably slower, for the same reason that fully dynamic languages in which objects are maps of code and variables are slower than compiled languages. Construction of a fast Rete network requires knowing what properties are being dealt with. Think of a database in which all the data was stored as object-attribute-value triples -- would it be as fast as a database with fixed tables and columns? On Aug 13, 2010, at 11:41 AM, Donald Winston wrote: So I have to create a template and know all the identifiers before loading data into the fact base? This means I'll have to create java bean objects for all my data. Every time the data changes I'll have to modify the java classes. I don't believe in creating objects for things that have little or no behavior. That's what Maps and Lists are for. I suppose I could generate a init-facts.clp file when my app starts up and load it along with the rules. On Aug 13, 2010, at 11:18 AM, Ernest Friedman-Hill wrote: Basically for the same reason that you can't say something like this in Java: String theMethodName = toString; String myString = myObject.(theMethodName)(); but instead you have to use reflection to find the method toString and call it using the Method object. The compiler needs to know the correct template to use to compile the code, and it can't do that if the name of the template is in a variable. Now, you may ask *could* it work the way you want? Indeed, it could -- but it doesn't at this time. We've talked in the past about allowing this kind of thing, and it has its pros and cons. On Aug 13, 2010, at 11:05 AM, Donald Winston wrote: Can anyone explain to me why this does not work? Why can't I use (deffacts initial-facts Facts to trigger a few appropriate salient initialization rules. (assert-request-parameters)) (defrule assert-request-parameters-rule Assert stored data one time. (declare (salience 100)) ?x - (assert-request-parameters) = (foreach ?key (((fetch request-parameter-map) keySet) iterator) (build str-cat (assert ( ?key ((fetch request- parameter-map) get ?key) ; why not (assert (?key ((fetch request-parameter-map) get ?key (retract ?x)) (bind ?map (new java.util.HashMap)) (?map put one 1) (?map put two 2) (?map put three 3) (store request-parameter-map ?map) (reset) (facts) (run) (facts) Jess, the Rule Engine for the Java Platform Copyright (C) 2008 Sandia Corporation Jess Version 7.1p2 11/5/2008 This copy of Jess will expire in 207 day(s). f-0 (MAIN::initial-fact) f-1 (MAIN::assert-request-parameters) For a total of 2 facts in module MAIN. f-0 (MAIN::initial-fact) For a total of 1 facts in module MAIN. - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com ' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: How to use a Userfunction returning boolean in a LHS of a Jess rule
Hi Ana, First let me note that this isn't at all the way Jess is intended to work. It's supposed to be used to match data, not the results of calling functions. If you want to monitor the status of a function's return value over time, a simple Java loop would be far more convenient! But assuming your actual intended application is more nuanced: in (1), the rule won't fire because pattern matching is always driven by working memory changes; if you write a rule like this one which matches no working memory elements, then Jess automatically makes it match (initial-fact), the fact that is asserted by the reset function, so you'll need to call that at some point. Also, rules only fire when you call run. So your Java code might look like engine.executeCommand((load-project file:/M:/MyJessTest/ osgi.myjesstest.test/simple-owl.pprj)); Batch.batch(myrules.clp, engine); engine.addUserfunction(new ReturnTrue()); engine.reset(); engine.run(); (You might need to call load-project before the reset(), and it would make sense to define the function before loading the rules, although that's not required.) Now, for question (2), the only way to re-evaluate the function is to force re-evaluation of the (initial-fact) pattern. Calling reset would do that, but it would also empty out working memory. In a real rule, you might have some real patterns, and re-evaluating one of those would do the trick -- modifying a fact that was matched on the rule's LHS before the function call. PropertyChangeEvents have nothing directly to do with your question -- that's a mechanism for telling Jess that a working memory element (i.e., a fact) has changed. On Jul 28, 2010, at 5:42 AM, Ana Rossello Busquet wrote: Hi, I am beginner in Jess. I have a java application that uses jess.Rete. I want to define a rule in jess that calls a Userfunction in LHS. If the Userfunction returns true, the rule should be fired. I have mainly two problems: 1- how do I write this rule in jess 2- how do I notify my engine that the return value of the function has changed. 1- How do I write the rule in jess: I have created a this class that implements Userfunction: public class ReturnTrue implements Userfunction { @Override public Value call(ValueVector arg0, Context arg1) throws JessException { return new Value(Funcall.TRUE); } @Override public String getName() {return returnTrue;} } My main code, where jess.Rete is initialized and my rules and Userfunctions are loaded: Rete engine = new Rete(); engine.addUserpackage(new JessTabFunctions()); try { //my database is an ontology created with protege engine.executeCommand((load-project file:/M:/MyJessTest/ osgi.myjesstest.test/simple-owl.pprj)); Batch.batch(myrules.clp, engine); engine.addUserfunction(new ReturnTrue()); } catch (JessException e) { e.printStackTrace(); } I have write my rule like this, but it does not seem to be working: (defrule trueFunction True Function (test (returnTrue)) = ((System.out) println True)) What am I doing wrong? 2- - how do I notify my engine that the return value of the Userfunction has changed I have found a post that actually talks about this: Userfunction on LHS called only once. In this post ejfried suggests two options: idle-rule or JavaBean which support PropertyChangeEvents. Can some on give more information on how to use PropertyChangeEvents or even better an example code? Thanks! Ana - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Can't use funcalls in backchained patterns?
It would, but then you'd need a second rule to actually act on the alert. I think Henrique was looking for a way to do it in one rule, imagining that there would be many triggers like this. On Jul 21, 2010, at 10:05 AM, Wolfgang Laun wrote: Why wouldn't a simple (defrule r (k (when ?w)) = (schedule-timer-alert (+ ?w 3000)) ) be sufficient? -W - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Checking status: backward-chaining or logical?
That seems like an excellent solution. On Jul 2, 2010, at 6:35 AM, Henrique Lopes Cardoso wrote: Hi, I was trying to figure out a way of checking the status of some system. To make things simpler, I have two kinds of facts, start and end, which are added along time: (deftemplate start) (deftemplate end) Then I want to say that I have an active system if it has started and not ended yet. However, I want to avoid doing like (start) (not (end)) in every rule where I need to check if the system is active. My first approach was to try backward chaining. In Prolog I would do something like: active :- start, not(end). However in Jess this gets more complicated, since doing something like: (deftemplate active (declare (backchain-reactive TRUE)) ) (defrule do-active (need-active) (start) (not (end)) = (assert (active)) ) will assert the active fact, but then I need another rule to retract active when end occurs... I then turned to using the logical conditional element, which seems to work fine: (defrule active-ctx (logical (not (end))) (start) = (assert (active)) ) Is this the best way of doing it? Thanks. Henrique To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: My rule is not fired -- Jess and JavaBeans
If the problem is something subtle, then we're not going to be able to help you unless you show us the real code, because most likely the problem is in something you're not showing here. As far as this goes, it looks more or less OK, but as they say, the devil is in the details. On Jul 1, 2010, at 12:28 PM, mco...@boninc.com wrote: BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px; } Please help, my *very simple* rule in JEss is not fired. I follow the HVAC example, chapter 14 of the book Jess in Action. But my simple rule never fired. Example rule: if a person with age 24 months then it is a toddler. The exercise is written in Java with the rule in Jess IDE environement: Eclipse Java class public class Person { private String m_name; private int m_age; // set and get funciton // in order to test out the different rules, a method is writen to increase the age of an object. public void increaseAge() { } } // same code from the Jess Action book, chater 14. The class is to add / remove property change listener and public abstract class BeanSupport { } // class PersonStageReasoner. This class will start a thread with a forever-loop to change a person age public class PersonStageReasoner extends BeanSupport implements Runnable { // constructor that will instantiage a person object and start a thread public PersonStageReasoner (Person p) { m_person = new Person(p); new Thread(this).start(); } public int getAge() {return m_person.getAge()); } public void run() { while (true) { prev_age := m_person.getAge(); m_person.increaseAge(); int age_now = m_person.getAge() m_pcs.firedPropertyChange(age, prev_age, age); try { Thread.sleep (1000); } catch (InterruptedException ie) { return; } } // end while true } } Jess: !! Add rules (bind?p(new person.Personfirstname lastname 0)) ( defclassPersonStageReasoner person.PersonStageReasoner) (definstancePersonStageReasoner (new person.PersonStageReasoner?p)) (defruleperson-stage-todler (PersonStageReasoner(age?a:( ?a 12))) = (printout t toddler crlf) (halt)) (run-until-halt) (exit) I know that defclass, definstance are fine, because the Java code, espeically the PersonStageReasoner thread is spawn in is in the forever loop (while true), the person age is changing. But the rule in defrule was never fired. I thank you for any and all help. My Coyne mco...@boninc.com (cel): 301-399-6351 - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: My rule is not fired -- Jess and JavaBeans
I added a call to (facts) in the Jess code right before run-until- halt, and I see: From Person: name My Coyne From Person: age 0 Finish initialize in BeanSupport, add property change in PersonStageReasoner.run() prev_age=0 age now=12 f-0 (MAIN::PersonStageReasoner (age 12) (class Java- Object:java.lang.Class) (OBJECT Java- Object:person.PersonStageReasoner)) For a total of 1 facts in module MAIN. in PersonStageReasoner.run() prev_age=12 age now=24 in PersonStageReasoner.run() prev_age=24 age now=144 Look at the new line in the output, starting with f-0 (MAIN::PersonSta... I highlighted (age 12) in red. Basically what's happening is that the instant you create your PersonStageReasoner, it increments the age to 12. By the time Jess sees it, it's already 12, and the rule (which matches ages below 12) never fires. If you change PersonStageReasoner.run() to put the sleep at the beginning rather than the end, you'll find the program works as you expect! Threads are tricky things... On Jul 1, 2010, at 1:26 PM, mco...@boninc.com wrote: BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px; } Attached please find all the codes in java and Jess rule. This is the first time I use the forum and not sure if the attachements will going through. Please let me know if I should cut-and-paste the codes, directly here. My Coyne mco...@boninc.com (cel): 301-399-6351 On Thu 01/07/10 1:14 PM , Ernest Friedman-Hill ejfr...@sandia.gov sent: If the problem is something subtle, then we're not going to be able to help you unless you show us the real code, because most likely the problem is in something you're not showing here. As far as this goes, it looks more or less OK, but as they say, the devil is in the details. On Jul 1, 2010, at 12:28 PM, mco...@boninc.com wrote: BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px; } Please help, my *very simple* rule in JEss is not fired. I follow the HVAC example, chapter 14 of the book Jess in Action. But my simple rule never fired. Example rule: if a person with age 24 months then it is a toddler. The exercise is written in Java with the rule in Jess IDE environement: Eclipse Java class public class Person { private String m_name; private int m_age; // set and get funciton // in order to test out the different rules, a method is writen to increase the age of an object. public void increaseAge() { } } // same code from the Jess Action book, chater 14. The class is to add / remove property change listener and public abstract class BeanSupport { } // class PersonStageReasoner. This class will start a thread with a forever-loop to change a person age public class PersonStageReasoner extends BeanSupport implements Runnable { // constructor that will instantiage a person object and start a thread public PersonStageReasoner (Person p) { m_person = new Person(p); new Thread(this).start(); } public int getAge() {return m_person.getAge()); } public void run() { while (true) { prev_age := m_person.getAge(); m_person.increaseAge(); int age_now = m_person.getAge() m_pcs.firedPropertyChange(age, prev_age, age); try { Thread.sleep (1000); } catch (InterruptedException ie) { return; } } // end while true } } Jess: !! Add rules (bind?p(new person.Personfirstname lastname 0)) ( defclassPersonStageReasoner person.PersonStageReasoner) (definstancePersonStageReasoner (new person.PersonStageReasoner?p)) (defruleperson-stage-todler (PersonStageReasoner(age?a:( ?a 12))) = (printout t toddler crlf) (halt)) (run-until-halt) (exit) I know that defclass, definstance are fine, because the Java code, espeically the PersonStageReasoner thread is spawn in is in the forever loop (while true), the person age is changing. But the rule in defrule was never fired. I thank you for any and all help. My Coyne mco...@boninc.com (cel): 301-399-6351 - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . Person .java BeanSupport .javaPersonStageReasoner.javaPersonClassificationRules.clp - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com
Re: JESS: Explicit pattern bindings when using dotted notation in slots with fact reference
On Jun 29, 2010, at 6:42 AM, Henrique Lopes Cardoso wrote: Does this mean that when using dotted variables a pattern binding should always be included before they are used? This isn't really limited to dotted variables; you'd see the same issue if you wrote the code using fact-slot-value, or reflection. For a match to be made or unmade, the particular Rete node that performs the test needs to be notified that the relevant fact(s) have changed. That won't happen unless those relevant facts are explicitly matched by patterns. If the facts are dynamic -- i.e., if the slot values will change at runtime -- then I'd prefer to write this rule as (defrule r2 (a (b ?b)) ?b - (b (s ?s)) (c (s ?s)) = - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Explicit pattern bindings when using dotted notation in slots with fact reference
I think that text is referring to dotted variables used to access properties of Java objects, as opposed to slot values of facts. On Jun 29, 2010, at 10:09 AM, Henrique Lopes Cardoso wrote: Thanks for the clarification. By the way, in section 3.7.1 of the Jess manual: You can use dotted variables in any procedural code, but they won't generally work in the pattern matching parts of a rule. Does this mean that the use of dot notation is discouraged in the LHS of rules? Section 6.2.1 seems to provide an example where it is used in the LHS, although with a Java pattern. Henrique Ernest Friedman-Hill wrote: On Jun 29, 2010, at 6:42 AM, Henrique Lopes Cardoso wrote: Does this mean that when using dotted variables a pattern binding should always be included before they are used? This isn't really limited to dotted variables; you'd see the same issue if you wrote the code using fact-slot-value, or reflection. For a match to be made or unmade, the particular Rete node that performs the test needs to be notified that the relevant fact(s) have changed. That won't happen unless those relevant facts are explicitly matched by patterns. If the facts are dynamic -- i.e., if the slot values will change at runtime -- then I'd prefer to write this rule as (defrule r2 (a (b ?b)) ?b - (b (s ?s)) (c (s ?s)) = - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: AW: Static root reference to custom classloader through jess.ReflectFunctions.s_descriptors avoids garbage collection
I can't think of any reason why this would be bad; it's just a cache, and the code works fine with the cache completely disabled, too. We should be able to include a method to clear all of these caches in the next release. On Jun 11, 2010, at 3:10 AM, Jörg Henschel wrote: Hi, I have just the same problem as described here (a custom classloader that cannot be finalized). The proposed solution looks promising and works in a local prototype. However, before I finally adopt this fix - could somebody pleaser confirm that clearing the static maps this way won't raise any other issues? And are there anym plans to incorporate this into future Jess releases? thanks, Joerg -Ursprüngliche Nachricht- Von: owner-jess-us...@sandia.gov [mailto:owner-jess-us...@sandia.gov] Im Auftrag von Grube, Ralf Gesendet: Freitag, 28. Mai 2010 13:48 An: jess-users@sandia.gov Betreff: JESS: Static root reference to custom classloader through jess.ReflectFunctions.s_descriptors avoids garbage collection Hi, we face to a problem where our classloader can't be finalized by the garbage collector. Let me shortly explain our context. We have an endless running application which has the Jess library in its classpath. Additionally we load classes with a custom classloader from separate jar files. These classes are used in deftemplate from-class statements to be used in the engine. The custom classloader is provided to the Rete (Rete.setClassLoader()). I've analyzed the heap dump and found a lot of root reference chains to our custom classloader. All of them contain the static map jess.ReflectFunctions.s_descriptors. As far as I understand the code, there is some kind of Bean introspection for classes used in deftemplate from-class statements. The results of this introspection seem to be cached in this static map. jess.ReflectFunctions is loaded by our application classloader and holds static references to the deftemplate classes and hence to our custom classloader. The missing classloader finalization is critical in our scenario, because all of its loaded classes remain in the PermGenSpace of the heap. As a result the application will run into OutOfMemoryExceptions over time. At the moment I have fixed this by implementing a static clean method in jess.ReflectFunctions, which clears the map: public static void clearDescriptorsCache(){ ReflectFunctions.s_descriptors.clear(); } As jess.ReflectFunctions is a package protected class, I call this new function from the Rete.clear() method: m_deffacts.clear(); m_defglobals.clear(); m_classSource.clear(); //clear descriptor cache in ReflectFunctions to destroy root references to business model classloader ReflectFunctions.clearDescriptorsCache(); broadcastEvent(JessEvent.CLEAR, this, m_globalContext); Two question, I have: Might there be problems doing it this way? If the answer is no, is it possible to include this as part of the next release? Regards, Ralf To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Debugging
Hi Jan, Encouraged by your partial success, I gave this a try and after a little debugging of my own, I was able to make it work! The trick is related to the fact that Eclipse doesn't deal with files but rather resources, and sometimes the relationship between a file and its corresponding resource can get a little unclear. If you're willing to live with one more modification to your program, then the debugger will work transparently. What you have to do is use the full filesystem path as your argument to batch or however you invoke the Jess code. Use the file that's in your Eclipse workspace -- i.e., for me, on my MacBook, I needed to use engine.batch(/Users/ejfried/workspace/DebugExperiment/code.clp); This, together with the steps below, then works like a charm. Knowing that, I think I can improve the next version of the debugger so that this dodge is unnecessary. Good luck! On Jun 4, 2010, at 8:26 AM, Jan Willem Lokin wrote: Ernest, It sort of works. That is, I can see in my log output that execution stops at the breakpoint. However, the Debugger does not get notified of this, i.e. the Resume button stays disabled, and no information is displayed in the Variables view. I'm wondering if it has to do with the fact that I now have to specify my .clp file twice, both in my Java code and in the Debug launch configuration. -+- JW -+- 2010/6/3 Ernest Friedman-Hill ejfr...@sandia.gov: If your program is a Java application and you can modify main(), then it's possible that the following will work. I've never tried it, or explained this to anyone else before, so please do let us know if it works for you. In your main() routine, do this: import jess.Main; import jess.Rete; public static void main(String[] args) { Rete engine = new Rete(); Main main = new Main(); main.initialize(args, engine); // Then use engine in your program } In the JessDE, use Debug... to create a Jess debug configuration, and modify the main program class name to point to the main class of your application. When the debugger launches your program, it will pass some arguments to it, including -debugPorts x y where x and y are integers. That call to Main.initialize() should see those flags and open sockets to connect to those ports in background threads. Breakpoints in the debugger should then work. On Jun 3, 2010, at 8:24 AM, Jan Willem Lokin wrote: Hi, My setup is a Java program which loads Jess code using jess.Rete.batch(). I am developing my program in Eclipse using JessDE. Is there a way to fool the JessDE Debugger so that it will actually break on a breakpoint that I set in my .clp files? Any pointers as to how it could be achieved are appreciated. -+- JW -+- - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com ' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Rete.reset() and working memory
Definstances are like deffacts -- reset resets them, it doesn't delete them. Use (undefinstance *) to remove all definstances. On Jun 4, 2010, at 4:59 PM, Nguyen, Son wrote: Hi, I use Jess in a Java program. My clp file has the following template definition and a few rules but no asserts, no deffacts, no definstances. (deftemplate moduleName::JavaObjecType (declare (from-class JavaObjecType))) The clp file is batched by the Java program. I then set the current module to 'moduleName' and set the focus to 'moduleName' I instantiate Java objects and add them to the working memory using Rete.add(). After Rete.run(), I retrieve the Java objects using Rete.getObject(). All is well until I call Rete.reset() before I start something new. I expect to see nothing in the working memory but, to my surprise, I see all the objects I added. Rete.clear() does clear the working memory but would also require that I batch the clp file again, taking substantially more time. Another way to remove these Java objects is to retrieve them using Rete.getObjects() followed by Rete.removeAll(javaObjectCollection). Did I miss anything? Or is reset() not working as documented? Any feedback will be greatly appreciated. Son Nguyen. - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Rete.reset() and working memory
On Jun 4, 2010, at 6:56 PM, Nguyen, Son wrote: The only facts that I indirectly add are shadow facts created when the Java objects are added to the working memory. Rete.reset() does not seem to remove the Java objects. Java objects in working memory == definstances; same thing. add is just a shorter synonym for definstance with all the options defaulted. Is this the expected behavior? The documentation seems to indicate otherwise. 16.151. (reset) Arguments: None Returns: TRUE Description: Removes all facts from working memory, removes all activations, then asserts the fact (initial-fact), then asserts all facts found in deffacts, asserts a fact representing each registered Java object, and (if the set-reset-globals property is TRUE) initializes all defglobals. - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Engine Pooling Mechanism and Its Behavior
Generally, each jess.Rete object is completely independent of all others. If you construct a Rete object by passing another one as a constructor argument, however, then the two are peers, and they will share a Rete network, so loading rules into one will load the rules for both (they will still have separate working memories, though.) This is the design that's intended for use in a server environment. Reloading a clp file will only do whatever the code in the clp file does. In other words, no facts will be retracted unless the file contains a reset or clear. Rules in the file will be redefined, potentially resulting in a lot of computation. Most likely what you'll want to do is create a bunch of peered engines, and load your rules just once from a clp file. After that, you'll interact with the individual engines by calling reset, for example, to get back to the initial state. In general, there's no magic: what you see is what you get, On Jun 3, 2010, at 5:23 AM, debasish.da...@cognizant.com wrote: Hi, I have one query regarding the creating of multiple instance of Jess Engine using standard object pool-mechanism, or using JCA 1.5 specification. If I do this, and load the same rules (the “.clp”) for each instance (not sure whether there is a mechanism (using Jess Rule API) to load the rules only once for all instances) – a.) Does it mean, engine will create separate Rete network for each engine instance? b.)If so, in runtime, how the “knowledge (the conclusions of the rules)” will be sharing between multiple instances. c.) If reload the same ruleset (the “.clp”) after the its execution complete one/multiple time using a engine instance - does this means, because of the 2nd time reload, the engine will remove/ clean all the old “knowledge (the conclusions of the rules)” from both the fact-base and the rule-base, and load it as it did at the first time? Also, how the behavior will be (as per answer on #b). Ext - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Debugging
If your program is a Java application and you can modify main(), then it's possible that the following will work. I've never tried it, or explained this to anyone else before, so please do let us know if it works for you. In your main() routine, do this: import jess.Main; import jess.Rete; public static void main(String[] args) { Rete engine = new Rete(); Main main = new Main(); main.initialize(args, engine); // Then use engine in your program } In the JessDE, use Debug... to create a Jess debug configuration, and modify the main program class name to point to the main class of your application. When the debugger launches your program, it will pass some arguments to it, including -debugPorts x y where x and y are integers. That call to Main.initialize() should see those flags and open sockets to connect to those ports in background threads. Breakpoints in the debugger should then work. On Jun 3, 2010, at 8:24 AM, Jan Willem Lokin wrote: Hi, My setup is a Java program which loads Jess code using jess.Rete.batch(). I am developing my program in Eclipse using JessDE. Is there a way to fool the JessDE Debugger so that it will actually break on a breakpoint that I set in my .clp files? Any pointers as to how it could be achieved are appreciated. -+- JW -+- - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Order of execution of RHS, evaluation of LHS
For the LHS, no, the true order of execution is fairly complex. The chapter on the Rete algorithm in the Jess manual will give you some idea about how it's done. Jess tries hard to do the minimum amount of work needed to determine whether a given fact matches a pattern; there's a tremendous amount of short-circuiting. Furthermore, each fact is evaluated when it is added to working memory, which means that the patterns of a rule are executed in an order than depends not only on how the Rete network is built, but also the order in which data is injected. For the RHS -- yes, it's just like a computer program in any other language. Statements are executed in order. On Jun 2, 2010, at 10:04 AM, Nguyen, Son wrote: Hi, I am wondering what the order of evaluation of the LHS is when there are multiple patterns. Is it as they appear, top to botton and left to right? How about the order of execution of the RHS assuming there are many function calls. Is it sequential? Any feedback is greatly appreciated. Son Nguyen. - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: problem: user-defined commands working with javax.rules API
As the error message suggests, MyUpcase needs to implement the marker interface java.io.Serializable. On May 26, 2010, at 10:04 AM, Amandine Bellenger wrote: Hi, I am using a file of jess rules in a Java application through the javax.rules API (JSR-94 API). However I would like to add some additional Jess commands written in Java. Therefore I have followed the manual with the ExMyUpcase example. Here is the following code that I am using to create a RuleExecutionSet: // Get a RuleRuntime RuleRuntime runtime = serviceProvider.getRuleRuntime(); // Create a StatelessRuleSession StatelessRuleSession session = (StatelessRuleSession)runtime.createRuleSession(URI, new HashMap(),RuleRuntime.STATELESS_SESSION_TYPE); // Execute the rules List input = new ArrayList(); List results = session.executeRules(input); This code works properly when calling non-user defined commands and the ExMyUpcase command works when launching the rules file alone. But when calling the rules file, containing the ExMyUpcase command, through the javax.rules API, it throws the following exception: RuleException(javax.rules.RuleSessionCreateException: Problem creating rule session), root cause(java.io.NotSerializableException: builtinsJess.MyUpcase) at jess.jsr94.h.init(Unknown Source) at jess.jsr94.c.init(Unknown Source) at jess.jsr94.l.createRuleSession(Unknown Source) at rules.Handler.execute(Handler.java:76) at rules.Handler.run(Handler.java:19) at principal.Main.main(Main.java:64) Caused by: java.io.NotSerializableException: builtinsJess.MyUpcase at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source) at java.io.ObjectOutputStream.writeSerialData(Unknown Source) at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.writeObject(Unknown Source) at java.util.HashMap.writeObject(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source) at java.io.ObjectOutputStream.writeSerialData(Unknown Source) at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source) at java.io.ObjectOutputStream.defaultWriteObject(Unknown Source) at java.util.Collections$SynchronizedMap.writeObject(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source) at java.io.ObjectOutputStream.writeSerialData(Unknown Source) at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.writeObject(Unknown Source) at jess.Rete.bsave(Unknown Source) at jess.jsr94.j.clone(Unknown Source) ... 6 more Is there something I am doing wrong? Thanks in advance, Amandine To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: JESS JCL ClassLoader: problems with getResource()
I don't think there's any reason not to just change the code to use getResourceAsStream(); the standard implementation just defers to getResource() anyway, and I can see how for some ClassLoaders, implementing getResource() to return a URL might not be possible. Thanks for the suggestion; we'll incorporate this in the next release. On May 21, 2010, at 5:08 AM, Voigt, Michael wrote: Hi, For specific reasons we want to use a special classloader (JCL, http://jcloader.sourceforge.net ) to load jar files that contain fact classes and jessML files. We use Rete.setClassLoader() to make Jess aware of this classloader. One characteristic of JCL is that it loads the jar file as stream so that it is not aware of the real location/URL of the underlying jar file. Therefore it is not possible to return a proper URL when jclClassLoader.getResource() is called for a jessML file that is part of the jar file (it always returns null). On the other hand jclClassLoader.getResourceAsStream() works fine. Using this classloader with Jess works fine except that loading a jessML file from the classloader fails. The reason is that Rete.batch() internally uses classloader.getResource() to get the URL of the given file (which in this case returns null). If that URL is null an exception is thrown, if not a stream is opened; see Batch.findDocument(Rete engine, String filename, String charset). I wonder why Jess doesn’t try to use the classloader.getResourceAsStream() as another alternative before throwing the exception. I tried this and changed the lines to: URL u = engine.getResource(filename); InputStream is; if (u != null) { is = u.openStream(); } else { try { is = engine.getClassLoader().getResourceAsStream(filename); } catch (Exception e2) { throw new JessException(batch, Cannot open file, e); } } fis = new PushbackReader(new InputStreamReader(is, charset)); In my first simple tests this works very well. Do you see any objections? Could this be integrated into the next release of Jess? Or are there any other possibilities to achieve the described functionality without changes in Jess source code? Thanks! Michael - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: How we can search for a specific fact after RuleEngine ran???
Of course the best way is with another rule that runs last; the rule could use (store) and your Java code could use fetch() to transfer the information (look that up in the manual). Otherwise, if you really can't make that work, then use a defquery (again, well documented in the manual.) On May 20, 2010, at 5:00 AM, Burhan wrote: Please ,How we can search for a specific fact by its name if possible after RuleEngine ran??? I need a boolean variable to tell me (TRUE)if the fact exists or (False)if it doesn't, what is the way or method that i should take?? I'll appreciate any help. -- View this message in context: http://old.nabble.com/How-we-can-search-for-a-specific-fact-after-RuleEngine-rantp28618702p28618702.html Sent from the Jess mailing list archive at Nabble.com. To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: defquery revisited
On May 20, 2010, at 9:13 AM, Wolfgang Laun wrote: BUT: you can't provide parameters the way Jess does with this form of query. Oh,but you can! What you describe is just how Jess queries work. When the rule is compiled, an extra pattern is added to match a special fact which will hold the query parameters. When you execute a query, that special fact is created and asserted; this completes the LHS matches and activations are created for the specific matches. All the intermediate indexing that's done for a normal rule is done for queries, too, so they can be quite efficient. That's why it's a big win to define queries early and reuse them; if you define them just-in- time, then all the matching and indexing has to be done right then as the query is being compiled. - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Java-Jess store/fetch issue
THe arguments to a function in Jess never have parentheses around them, so (fetch (A)) should be (fetch A). On May 20, 2010, at 3:12 PM, Tessa wrote: Hi, I'm new to Jess, and sadly not too good in java, I have read posts about this topic, but just couldn't find what could be wrong with my code.:-( This application should pass input from java to jess to evaluate circuit gates, then pass the result back to java. (school project) Jess file: (deffunction AND(?a ?b) (if (or (= ?a 0)(= ?b 0))then (return 0)else (return 1))) (deffunction OR(?a ?b) (if (and (= ?a 0) (= ?b 0))then (return 0)else (return 1))) (deffunction NOT(?x) (if (= ?x 1)then (return 0)else (return 1))) (deffunction XOR(?a ?b) (if ( ?a ?b) then (return 1)else (return 0))) (reset) Java code: import jess.*; public class MainCircuit { public static void main(String[] argv)throws JessException, java.io.IOException{ int a=1,b=0,c=1; try { Rete engine = new Rete(); engine.clear(); engine.batch(Circuit evaluator.clp); engine.store(A, new jess.Value(a)); engine.executeCommand((bind ?x (fetch(A; engine.store(B, new jess.Value(b)); engine.executeCommand((bind ?y (fetch(b; engine.store(C, new jess.Value(c)); engine.executeCommand((bind ?z (fetch(c; Value d = engine.executeCommand((NOT (OR (AND ?y ?z) ? x))); Value e = engine.executeCommand((AND (XOR ?x ?z) ?y)); System.out.println(The given circuit's Output values are : ); System.out.println(d.intValue(engine.getGlobalContext())); System.out.println(e.intValue(engine.getGlobalContext())); } catch (JessException ex) { System.err.println(ex); } } } Error msg: Jess reported an error in routine Funcall.execute while executing (A) while executing (fetch (A)) while executing (bind ?x (fetch (A))). Message: Undefined function A. Program text: ( bind ?x ( fetch ( A ) ) ) at line 1 in file eval pipe. Sry if it's stupid ... and thanks in advance if you answer! Tessa -- View this message in context: http://old.nabble.com/Java-Jess-store-fetch-issue-tp28625638p28625638.html Sent from the Jess mailing list archive at Nabble.com. To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Jesstab error
When you put *what* in the same rule? Can you show us the rule? On May 17, 2010, at 6:29 PM, ANA TANASESCU wrote: Hello everybody, I have constructed an ontology and now I want to use Jess to process the facts imported from the ontology. I have a strange rule that returns me the following error: Jess reported an error in routine ValueVector.set while executing rule LHS (TECT) while executing (batch JO.clp). Message: Bad index 11 in call to set() on this vector: (mapare::object (is-a Probe_echipa) (is-a-name Probe_echipa) (OBJECT Java- Object:edu.stanford.smi.protege.model.DefaultSimpleInstance) (probaE ) (medalie ) (loc_ocupat ) (selectionata ) (apartine Java- Object:edu.stanford.smi.protege.model.DefaultSimpleInstance) (denumire Echipa Sprint Masculin) (descriere nil) (numar_membri 2)). It is strange because if I split the rule in two and run them in 2 independent applications everything works well. The problem is when I put them in a single complex rule. Why? Best regards, Ana - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: creating defqueries at runtime
Obviously if something can't be parameterized, then it can't be parameterized. Don't make queries that return everything under the sun, and then sort through the results after running them, I was talking about, for example, queries that check for specific value in specific slots. Using variables for those instead of hard-coding those values into the queries -- that's what I was talking about. On May 16, 2010, at 12:50 AM, Skeptic . wrote: Of course, as more generic queries would get many more partial matches, mainly because I don't have the most specific class to match on at compile time, I thought that generating specific ones could do better... I guess that if the cost is that high, I could cache them on the first run. From: ejfr...@sandia.gov To: jess-users@sandia.gov Subject: Re: JESS: creating defqueries at runtime Date: Sun, 16 May 2010 00:37:11 -0400 On May 14, 2010, at 12:10 PM, Skeptic . wrote: Hi, I'm asking myself if I should use more generic (def)queries that I can create at compile-time or more specific ones that I can create only at run-time. In both case, they would be run at the same frequency, which is not that high (definitly more than once). Thanks for any suggestion / hindsight. Gagnez 10 000 $ avec Hotmail! Participez ici Generally you want to use a few queries that you can compile ahead of time and parameterize as needed at runtime; compiling new queries is an unnecessary expense. - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com ' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . _ 30 jours de prix à gagner avec Hotmail. Participez ici. http://go.microsoft.com/?linkid=9729717 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: How to match a multislot which does not contain a given value?
Hi Adam, There's no especially elegant way to do it. You can bind the whole multislot with a multifield, and then test it using the member$ function: (example (code $?m:(not (member$ n $?m On May 6, 2010, at 3:20 PM, Adam Malik wrote: how could Jess match a fact whose multislot doesn't contain a given value? In the following example (code) is a multislot. I would like to do the opposite of that (example (code $? n $?)) that is: find all (example)-facts whose (code)-multislot does not contains n. - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: inference / rule engine
They're more or less the same thing. Sometimes rule engine is used for very simple software that's more of a lookup-table sort of thing; but a real rule engine and an inference engine are indeed two terms for the same thing. On May 1, 2010, at 10:52 AM, Sashi Kumar wrote: i have doubt, are rule engine and inference engine same thing??? or rule engine is a inference engine?? -Sashi - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: inference / rule engine
OK, so now you've got three answers, which I might summarize as 1) They're the same 2) A rule engine is a kind of inference engine 3) An inference engine is a kind of rule engine Take your pick! :) On May 1, 2010, at 10:52 AM, Sashi Kumar wrote: i have doubt, are rule engine and inference engine same thing??? or rule engine is a inference engine?? -Sashi - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: question about adopting jess
Felix -- The bottom line is that Sandia Laboratories stands behind its commitments. Jess would continue to be supported with or without me. On Apr 27, 2010, at 10:37 AM, Felix Chan wrote: All, I have been thinking about how to overcome potential objections in adopting Jess. I would like to get your suggestions on one such objection. It seems Jess has been built, maintained and improved by Ernest. What would happen to Jess if something happens to him? (I love Jess and I hope Ernest will live to a ripe old age.) I can think of a few responses. For example, Jess is very good as it stands, so we can still benefit greatly by using it even if nothing will be done to it from now on. We can improve the software ourselves by modifying the source code, etc. Responses like these seem like dodging the question. What I hope is an answer along the line that there are people in the Jess community who can step up and fill Ernest's role. But I don't know if that's the case. Thoughts? Many thanks. Felix - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: logical - why is it the way it is?
On Apr 26, 2010, at 10:41 PM, David Holz wrote: Btw, if you really want to know why is it the way it is with regards to the logical syntax, you might try asking Gary Riley. CLIPS (afaik) implemented the logical CE before Jess started, and Jess used CLIPS as its starting point. David certainly hits the short answer dead on, here: the syntax and semantics of Jess's logical are directly modeled after CLIPS. I just confirmed that mplementing assert-with-unconditional-support would be simple enough, but as things stand it can't be implemented externally. Have a better name for this function, in case I decide to implement it? - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Real Life Applications
Yes, of course. Many Jess-based applications are in use in the manufacturing, financial, insurance, transportation, defense and security industries. On Apr 22, 2010, at 3:15 PM, Sashi Kumar wrote: Are there any Real Life Application that are developed using Jess at their background? Sashi To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Internal Working of Jess
The appendix in the manual which describes the Rete algorithm goes into a fair amount of detail; but if you have *specific* questions beyond what's covered there, I'd be happy to answer them. P.S. Jess is *not* an acronym for Java Expert System Shell. On Apr 22, 2010, at 2:47 PM, Rakesh Jain wrote: sir, I want to know, what exactly is happening inside jess when we enter a fact or run a rule, how does jess work apart from this that it uses RETE Algorithm. Is there anything else we should know as a jess user. we have gone through the FAQ and the manual available on the website but we couldn't find the answer. Can you please elaborate the working of JAVA EXPERT SYSTEM SHELL (JESS) ? How data is handled inside JESS when user enters the data? Are there any demerits of this Engine? - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Multiplication to 1000000 is not working fine.
Jess is giving the right answer in the sense that that's the Java answer for that math problem; if you run the following Java code, you'll get the same answer: System.out.println(4.1d * 100); Floating-point math is inherently inaccurate. There are many decimal numbers -- 4.1 being one of them -- that can't be represented exactly, and that's what leads to this slightly incorrect result. This is a fact of life in C, C++, Java, and many other languages that use IEEE floating-point math. The solution, both in Java and in Jess, is to use one of the several number-formatting tools to round to an appropriate number of decimal places; for instance (printout t (format nil %.2f (* 4.1 100)) crlf) gives 410.00 On Apr 20, 2010, at 4:18 AM, Jenish wrote: I have a simple program (bind ?lastqty -4.1) (if ( ?lastqty 0) then (bind ?lastqty (- 0 ?lastqty))) (printout t Hello, world! ?lastqty crlf) (bind ?res (* ?lastqty 100)) (printout t Hello, world! ?res crlf) But output of this program 409.95 instead of 4100. Can anybody please tell me why JESS is not able to give right value when I do 4.1 * 100? Thanks, Jenish -- View this message in context: http://old.nabble.com/Multiplication-to-100-is-not-working-fine.-tp28287814p28287814.html Sent from the Jess mailing list archive at Nabble.com. To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Problem: Can't retract facts.
Looks perfect, and should work fine. The only way it might not work -- that I can think of -- would be if some of the slots of those facts are populated with Java objects with bad (i.e., changing over time) hashcode values, in which case working memory can be corrupted. You say you know the rule is firing; did you use watch all and if so, do you see something like this, where you can see both the rules firing and the facts being retracted? FIRE 1 MAIN::remove-end-mill-non-indexable f-4, f-3 == f-3 (MAIN::end_mill_non_indexable (name n4) (diameter nil) (length nil) (flutelength nil) (flutes nil) (cornerradius nil) (material nil)) FIRE 2 MAIN::remove-end-mill-non-indexable f-4, f-2 == f-2 (MAIN::end_mill_non_indexable (name n3) (diameter nil) (length nil) (flutelength nil) (flutes nil) (cornerradius nil) (material nil)) FIRE 3 MAIN::remove-end-mill-non-indexable f-4, f-1 == f-1 (MAIN::end_mill_non_indexable (name n2) (diameter nil) (length nil) (flutelength nil) (flutes nil) (cornerradius nil) (material nil)) FIRE 4 MAIN::remove-end-mill-non-indexable f-4, f-0 == f-0 (MAIN::end_mill_non_indexable (name n1) (diameter nil) (length nil) (flutelength nil) (flutes nil) (cornerradius nil) (material nil)) On Apr 15, 2010, at 9:16 AM, Adam Malik wrote: Dear Jess users, My JESS-code contains two templates, (deftemplate MAIN::end_mill_non_indexable (slot name) (slot diameter) (slot length) (slot flutelength) (slot flutes) (slot cornerradius) (slot material)) and (deftemplate MAIN::face (slot length) (slot width) (slot roughness)). The working memory contains end_mill_non_indexable facts. This is the rule I want to fire: (defrule MAIN::remove-end-mill-non-indexable removes some tools ?f - (face) ?t - (end_mill_non_indexable) = (retract ?t) ) If I assert a face-fact the rule is firing but the retract-command seems not to be working correctly. The working memory still contains all end_mill_non_indexable facts. Why? The rule should remove ALL end_mill_non_indexable facts! Thanks in advance for your help. Adam To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Problem: Can't retract facts.
Rules are activated by facts, but they don't actually fire until a call to run. Looks like everything is fine -- the rule is being activated for each fact that needs deleting. When you type (run), the facts will all disappear. On Apr 15, 2010, at 3:27 PM, Adam Malik wrote: Hi Mr. Friedman-Hill! I'm using (watch all). I'm sorry, it seems that the rule is not firing. The output is: Jess (assert (face)) == f-72 (MAIN::face (length nil) (width nil) (roughness nil)) == Activation: MAIN::remove-end-mill-non-indexable : f-72, f-40 == Activation: MAIN::remove-end-mill-non-indexable : f-72, f-1 == Activation: MAIN::remove-end-mill-non-indexable : f-72, f-41 == Activation: MAIN::remove-end-mill-non-indexable : f-72, f-2 == Activation: MAIN::remove-end-mill-non-indexable : f-72, f-42 - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Comparing slots
On Apr 12, 2010, at 10:19 AM, Kumar, Amitesh wrote: StD out as you can see the result of the rule give me two facts with java.lang.String as the partyid == f-2 (MAIN::party1ID (partyId Java-Object:java.lang.String)) == f-3 (MAIN::party2ID (partyId Java-Object:java.lang.String)) I think that's the problem right there. These are of RU.JAVA_OBJECT type instead of RU.STRING. Jess can work with String like this just fine in many contexts, but they're not considered equal for pattern matching. Generally, you want to write UserFunctions so that they return Jess types whenever possible. Change the Value object constructed by your UserFunction to explicitly use RU.STRING as the type, and you should be all set. - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Defrule Help
Hi Robert, There are two, possibly three issues here. The error message is telling you the main problem: the infix notation -- the pattern matching that uses curly braces -- can't be used in multislots, and most if not all of the slots created by JessTab are multislots. So the first pattern probably has to look something like ?softwareRequirement1 - (object (is-a http://pluto.cse.msstate.edu/rae20/SRSontology#SoftwareRequirement)) I say probably because that URL might need to be quoted. It depends on how JessTab defines things (this is the possible second issue). The third issue is that I can't quite tell what you're trying to accomplish in your second pattern, and in particular I can't tell what this is supposed to be: ?softwareRequirement1.http://pluto.cse.msstate.edu/rae20/SRSontology#SoftwareRequirementName Normally the thing to the right of the dot would be the name of a slot, but that's certainly not a valid slot name, so I'm not sure what your intention is. As a result I can't show you what the whole rewritten rule should look like. On Mar 21, 2010, at 7:57 PM, Robert A. Elliott,Sr. wrote: All, I'm trying to define this one simple rule using the Jess Tab in Protege 3.4.3: (defrule duplicate_requirement This rule will search by requirement name to find duplicates ?softwareRequirement1 - (object {is-a == http://pluto.cse.msstate.edu/rae20/SRSontology#SoftwareRequirement }) ?softwareRequirement2 - (object {is-a == http://pluto.cse.msstate.edu/rae20/SRSontology#SoftwareRequirement http://pluto.cse.msstate.edu/rae20/SRSontology#SoftwareRequirementName == ?softwareRequirement1.http://pluto.cse.msstate.edu/rae20/SRSontology#SoftwareRequirementName }) =(printout t Found Duplicate Requirements ?person1.http://pluto.cse.msstate.edu/rae20/SRSontology#SoftwareRequirementName crlf)) Jess returns this error: Message: Can't use infix expressions with multislots at token http://pluto.cse.msstate.edu/rae20/ SRSontology#SoftwareRequirementName. I'm simply trying to compare two object facts of a 'is-a' type and seeing if the RequirementName slots are identical. Thanks for the help. __ Robert - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: shadow facts which contains collections
Jess doesn't have any special support for collections as JavaBeans properties, and in fact, I'd go so far as to say it doesn't work very well. There's no way for Jess to be notified when your List is modified by code outside of Jess, for example, or, as you note, if the objects it contains are modified. If (and only if) the objects in the list support proper equals() methods, then you could call Rete.updateObject() to tell Jess that something in the object has changed, and that should work out properly. On Mar 18, 2010, at 4:07 PM, Skeptic . wrote: Hi, Let's say I have this class wich instances will be added to a Rete engine : public class A { public int getI() {return i;} public ListB getBs() {return Collections.unmodifiableList(bs);} private int i;private ListB bs; A(int i) {this.i = i;this.bs = new ArrayListB(bs);bs.add(1);bs.add(2); bs.add(3);} public void change(int p) {bs.add(new B(p));} } And the following .clp file : (defclass A xxx.yyy.zzz.A) (defrule rule1 (A (i ?i) (bs ?bs))= (printout t i: ?i crlf) ) (reset) and the following test code : Rete r = new Rete(); try { r.batch(.../TestJess.clp); A a = new A(5); r.add(a); r.run(); a.change(); r.updateObject(a); r.run(); } catch (JessException e) { e.printStackTrace(); } The rule will fire twice, once with i=5 and once with i=6. However, if I comment the line where i is modified in the changemethod, the rule will only fire once, because even if the list is modified, the value of bs is unchanged. If the desired behavior is to have the rule firing twice, is there a way to have it ? In fact, I know that I can add the list itself in the engine and match it in the LHS, but I would prefer to avoid that. Thanks. _ Accès direct à Messenger depuis votre téléphone http://go.microsoft.com/?linkid=9712962 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Jess, CORBA Integration
I'm not quite sure what you're looking for -- can you elaborate? On Mar 16, 2010, at 2:04 AM, xlrai wrote: Hello all, I am new to Jess. I would like to test some programs in Jess, which in turn run java-based Corba programs within. I just wonder can someone give me some information regarding this. Thanks in advance, Sincerely, Laxmisha Rai - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: How to compare the value of two slots in the same fact?
Your rule matches individual facts that look like (a 1), not slots inside of a t fact, which is what you're actually asserting. You have to match the t fact explicitly, and furthermore, you have to match it all as part of one pattern. The equivalent, correct rule could look like (defrule r1 (t (a ?a) (d ?d) {b ?a} { c ?d || b ?d }) = (printout t test crlf)) On Mar 12, 2010, at 11:21 AM, Andrew Meng wrote: Hello, I try to write a rule to compare values in two slot but it does not fire. See the jess code below. Can anyone point me the issue or a better way to do it? - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: No such Variable error
On Mar 11, 2010, at 4:14 PM, uMt wrote: But same code is in your book sir. In Jess in action page 295. Yep, that's a known error in the book. - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: HELP on a rule
On Mar 10, 2010, at 11:13 AM, John Chrysakis wrote: (bind ?newrooms (?usr getDisplayRooms)) (calling ShowContent ?newrooms) The bind line looks fine; if ShowContent is a deffunction or loaded Userfunction, the second line should just be (ShowContent ?newrooms) . - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Problems with copying shadow facts via bsave and bload
. - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Defglobal function.
Hi Andrew, I'm not sure how subtle your question actually is, because there may be a major issue with accomplishing what you're after here. The initial value of a defglobal is stored exactly as it appears in the definition of the defglobal; if the initial value is a function call, then that function call itself is stored. This is so that when you call (reset), the function call can be invoked to initialize the defglobal to an appropriate new value at that time. In any case, the point is that the function call has to be stored as Jess code, so the code that creates the FuzzyVariable itself has to be expressed as a Jess function call no matter what. If you want to express exactly what you've shown here without any Jess code, then I'm afraid you're out of luck! If, on the other hand, it's OK for the initial value of the defglobal to be one, specific object created in Java, then you could just create the FuzzyVariable in Java (including the addTerm calls) and then call something like FuzzyRete engine = ... FuzzyVariable var = ... Defglobal dg = new Defglobal(*v*, new Value(var)); engine.addDefglobal(dg); On Mar 2, 2010, at 11:09 PM, Andrew Meng wrote: Hello, I try to follow a fuzzyJess example. It does something(in Jess only) like: (defglobal ?*v* = (new FuzzyVariable value 0 100 percentage)) then (?*v* addTerm low, (new TriangleFuzzySet (...)) I am wondering how I could do the same thing totally from Java using Jess API. - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: Website Down?
On Feb 25, 2010, at 8:17 AM, John Chrysakis wrote: Hello, I am trying to access the main website of JESS, but it seems to be down... It's down right now due to hardware problems; someone is working on it now. - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: pattern matching of java objects fields
On Feb 24, 2010, at 12:12 AM, Manolis Mavrikis wrote: So let's say I would like to write a rule that check whether the value of MockVerifier is true (but for other reasons I don't want to add MockVerifier as a fact). So I have a fact like this == f-4 (MAIN::analysisResultUpdater (class Java- Object:java.lang.Class) (testMe TRUE) (verifier Java- Object:uk.ac.lkl.migen.system.AI.analysis.MockVerifier) (OBJECT Java- Object:uk.ac.lkl.migen.system.AI.reasoning.AnalysisResultUpdater)) My latest attempt is something like (defrule MOCK_VERIFIER_TRUE (analysisResultUpdater (verifier ?aru1)) (MockVerifier (value ?value) (OBJECT ?aru1)) ;;and here I was thinking that maybe I should use test but = To continue the database analogy: not adding the MockVerifiers to working memory is like not having a MockVerifiers table, but instead having some structured text in a column named MockVerifiers in the AnalysisResultUpdater table. So to ask this sort of question in that database, you'd select AnalysisResultUpdaters, then use a LIKE clause or some kind of text functions to match the MockVerifier column. I like the database analogy because it makes it clear that you should expect this to be less elegant and less performant than having a separate table. But you could write the rule in Jess something like this using a predicate constraint: (defrule MOCK_VERIFIER_TRUE (analysisResultUpdater (verifier ?aru1:(eq (?aru1 getValue) TRUE = I deliberately wrote this in a general way that would work for non- boolean properties as well. For booleans you can actually remove the redundant comparison function: (defrule MOCK_VERIFIER_TRUE (analysisResultUpdater (verifier ?aru1:(?aru1 getValue))) = - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: pattern matching of java objects fields
On Feb 23, 2010, at 11:02 PM, Manolis Mavrikis wrote: I am probably missing something as I can't even see how the current example would be matched: assuming that only VirtualSite has been instantiated as a fact. Bad assumption; the rules are written for the situation where all of the VirtualSite and InetModem objects are added to working memory using (add) or (definstance). - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: pattern matching of java objects fields
On Feb 23, 2010, at 11:38 PM, Manolis Mavrikis wrote: Bad assumption; the rules are written for the situation where all of the VirtualSite and InetModem objects are added to working memory using (add) or (definstance). Thanks. Isn't that a bit redundant and rigid? ??? So, there isn't any way I can write a rule that matches a value (say for example for simplicity that publicIpAddress was boolean) of an object that what is inside an object when the latter is a fact? Sure there is, you didn't ask about that. The rules we're talking about, though, have as their very purpose finding the InetModem address that goes with a given VirtualSite; it's like doing a join across two tables in a database. - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: OutOfMemory after multiple assertions-resets
Hmmm. The numbers don't mean anything specifically -- they're just a way of creating unique symbols -- but the fact that they come one after another this way finally makes me realize that you really did mean you are redefining a query over and over again, hundreds of times. Perhaps you *have* found a memory leak, because you're doing something highly atypical. Why do you need to redefine the identical query over and over again? On the other hand, perhaps the redefinition a red herring: if you're automatically generating these, perhaps you're creating many, many rules or queries that are *not* duplicates, and therefore running out of memory? Looking at your heap dump info, it seems to suggest that you have 47,000 live facts in working memory, and maybe somewhere between 200-600 rules and/or queries. Does that align with your expectations? On Feb 20, 2010, at 9:24 PM, Sam Sarjant wrote: Hmm. I just came across something that could be the culprit. When creating the new queries which overwrite the old ones, upon examination of the 'ppdefquery queryname', I noticed that the '?' variable is assigned a new JESS name (an internal process). The possible problem I noticed was that this internal variable was incrementing with every redefinition of the query. For instance: (defquery MAIN::polRule0 (on ?X ?_blank_396) (above ?X ?_blank_397) (clear ?X) (block ?X)) (defquery MAIN::polRule0 (on ?X ?_blank_398) (above ?X ?_blank_399) (clear ?X) (block ?X)) (defquery MAIN::polRule0 (on ?X ?_blank_400) (above ?X ?_blank_401) (clear ?X) (block ?X)) etc. Perhaps it's nothing, but if JESS is hanging on to these variables, it could become bloated. Ernest Friedman-Hill-3 wrote: The best thing to do would be to try to figure out where the memory is going, and whether it's a bug, or a normal consequence of how you're operating. There's no reason why, given what you've described, memory usage should increase over time, so there's either something you're not telling me, or there's a bug someplace. Can you try to check it out using any kind of a heap profiler? On Feb 17, 2010, at 10:43 PM, Sam Sarjant wrote: Hi. I am using JESS to represent a relational environment for an agent to interact in (Blocks World, to be specific, if that helps). At each state, I am first resetting the Rete object and then asserting the state of the environment. From these assertions, further assertions are made by using rules which define extra predicates. For example, if I assert (on a b), I also create the (above a b) and possibly (clear a), depending on the exact state of the environment when (run) is called. Anyway, the agent receives this information, chooses an action to take, and the environment is updated again by resetting and re-asserting. While I could contain all operations within JESS in this particular environment, some Java code is required to be run during the process for other environments, so this is why I don't simply operate using assert and retract. Obviously this doesn't fit the idea that generally rule bases remain static, but the performance I get is reasonable. My problem lies in the fact that after several hundred (or perhaps thousand) of these assertion, resetting loops, Java or JESS runs out of memory and throws an OutOfMemoryException. The rules for defining extra predicates are asserted only once, but queries are asserted roughly each iteration for state matching, though they should be asserting over one-another (defqueries of the same name). Is there something I can do to 'flush' JESS, or stop it storing these reset assertions? Or would it be better to periodically create a new Rete object, load in the rules and continue? - Sam Sarjant -- View this message in context: http://old.nabble.com/OutOfMemory-after-multiple-assertions-resets-tp27634092p27634092.html Sent from the Jess mailing list archive at Nabble.com. To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com ' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . -- View this message in context: http://old.nabble.com/JESS%3A-OutOfMemory-after-multiple-assertions-resets
Re: JESS: OutOfMemory after multiple assertions-resets
And I've got enough information from this to track down the real cause of the problem; there is indeed an unintended memory leak in Jess when you redefine a rule in a live system. It will be easy to fix. We do have a new release coming out soon so this fix will be in it. On Feb 22, 2010, at 7:56 PM, Sam Sarjant wrote: Haha! While I haven't run extensive tests, the problem appears to be solved. By only defining a query once, things seem to be proceeding normally. The heap dump still has JESS's token's on top, but they no longer hold a large majority share of resources. I was under the impression that if a defquery was defined under the same name as another, the older one would be overwritten. Perhaps this is a bug, or perhaps I was simply misled towards this impression. Thanks for your help in this. I hope the rest of my JESS use stays problem-free. Sam Sarjant wrote: Well, I'm really just being a lazy programmer. I don't really need to redefine the same query; I could just use a map to point to previously defined queries. The queries come about because an interactive agent uses a policy to make decisions. This policy is made up of rules, the conditions of which I use to query the state to see if the rule is applicable. 'Why not just use rules?' you may ask. Well rules are checked when run is called (which BTW is at each state of the environment to assert extra information kept by environment rules), whereas queries are only checked when they are manually called. If an agent's policy was asserted as a rule, it would have to be retracted again when the policy changes. In any case, I'll stop being lazy with the query definitions and see what happens on that front. The environment in which that heap dump was generated from should have about 25 facts (thereabouts) and approximately 10 rules. And about 10 templates. So something is amiss here. The (facts) command only shows the facts that should be there (the approx 25 or so), so something internal is going on. I'll investigate the query redefinition problem and send my results. Ernest Friedman-Hill-3 wrote: Hmmm. The numbers don't mean anything specifically -- they're just a way of creating unique symbols -- but the fact that they come one after another this way finally makes me realize that you really did mean you are redefining a query over and over again, hundreds of times. Perhaps you *have* found a memory leak, because you're doing something highly atypical. Why do you need to redefine the identical query over and over again? On the other hand, perhaps the redefinition a red herring: if you're automatically generating these, perhaps you're creating many, many rules or queries that are *not* duplicates, and therefore running out of memory? Looking at your heap dump info, it seems to suggest that you have 47,000 live facts in working memory, and maybe somewhere between 200-600 rules and/or queries. Does that align with your expectations? On Feb 20, 2010, at 9:24 PM, Sam Sarjant wrote: Hmm. I just came across something that could be the culprit. When creating the new queries which overwrite the old ones, upon examination of the 'ppdefquery queryname', I noticed that the '?' variable is assigned a new JESS name (an internal process). The possible problem I noticed was that this internal variable was incrementing with every redefinition of the query. For instance: (defquery MAIN::polRule0 (on ?X ?_blank_396) (above ?X ?_blank_397) (clear ?X) (block ?X)) (defquery MAIN::polRule0 (on ?X ?_blank_398) (above ?X ?_blank_399) (clear ?X) (block ?X)) (defquery MAIN::polRule0 (on ?X ?_blank_400) (above ?X ?_blank_401) (clear ?X) (block ?X)) etc. Perhaps it's nothing, but if JESS is hanging on to these variables, it could become bloated. Ernest Friedman-Hill-3 wrote: The best thing to do would be to try to figure out where the memory is going, and whether it's a bug, or a normal consequence of how you're operating. There's no reason why, given what you've described, memory usage should increase over time, so there's either something you're not telling me, or there's a bug someplace. Can you try to check it out using any kind of a heap profiler? On Feb 17, 2010, at 10:43 PM, Sam Sarjant wrote: Hi. I am using JESS to represent a relational environment for an agent to interact in (Blocks World, to be specific, if that helps). At each state, I am first resetting the Rete object and then asserting the state of the environment. From these assertions, further assertions are made by using rules which define extra predicates. For example, if I assert (on a b), I also create the (above a b) and possibly (clear a), depending on the exact state of the environment when (run) is called. Anyway, the agent receives this information, chooses an action to take, and the environment is updated again by resetting and re-asserting. While I could contain all operations
Re: JESS: Shadow facts and user functions
Jess likes to work with JavaBeans properties, and your 'Message' class isn't very Bean-like, so it will be somewhat awkward to work with. I think what you want your rule to do is print valid whenever a RoutingMessage with a non-nil EBID property is asserted, right? So your rule could look like (defrule valid-message (RoutingMessage (OBJECT ?o:(neq (?o getProperty EBID) nil))) = (printout t valid crlf)) The lines on the left-hand-side of the rule -- i.e., before the = -- are patterns that match facts in working memory. They are not function calls. In the {} syntax you were using (but that I have not used here) the left-hand-side of each expression is the name of a property (a slot) in a fact; since your object has no JavaBeans properties of interest, this syntax is basically useless (see, I told you your class would be awkward to work with.) The syntax I've used here is a color followed by a function call that returns boolean; it's called a predicate constraint and you can read about that in the manual. On Feb 17, 2010, at 11:59 AM, Kumar, Amitesh wrote: Hi guys , I new to Jess rules and im struggling on the syntax What im trying to do is execute a function on an object added to the rete engine Object been added engine.getEngine().add(message); engine.getEngine().run(); CLP file 1 (import com.standardbank.cibi.infra.zippy.dataobject.*) 2 (import com.standardbank.cibi.infra.zippy.jess.functions.*) 3 4 (deftemplate RoutingMessage (declare (from-class RoutingMessage))) 5 (load-function GetProperties) 6 7 (defrule valid-message 8 ?ebid- ( get-property OBJECT EBID ) 9 (RoutingMessage {?ebid nil}) 10 = 11 (printout t valid crlf) 12 ) I get an exception Caused by: Jess reported an error in routine Jesp.parsePattern. Message: Bad slot name at token '?ebid'. Program text: ( defrule valid-message ?ebid - ( get-property OBJECT EBID ) ( RoutingMessage { ?ebid at line 9 in file zippy.clp. If I remove line 9) then it compiles but the rule doesn’t fire Can anyone help me out All my Function does Is public class GetProperties implements Userfunction { public String getName() { return get-property; } public Value call(ValueVector valueVector, Context context) throws JessException { String key = valueVector.get(2).stringValue(context); RoutingMessage routingMessage = (RoutingMessage) valueVector.get(1).externalAddressValue(context); try { return new Value(routingMessage.getProperty(key)); } catch (JMSException e) { e.printStackTrace(); } return null; } } ** More information on Standard Bank is available at www.standardbank.com Everything in this email and any attachments relating to the official business of Standard Bank Group Limited and any or all subsidiaries, (the Company), is proprietary to the Company. It is confidential, legally privileged and protected by relevant laws. The Company does not own and endorse any other content. Views and opinions are those of the sender unless clearly stated as being that of the Company. The person or persons addressed in this email are the sole authorised recipient. Please notify the sender immediately if it has unintentionally, or inadvertently reached you and do not read, disclose or use the content in any way and delete this e-mail from your system. The Company cannot ensure that the integrity of this email has been maintained nor that it is free of errors, virus, interception or interference. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. ** This message has been scanned for viruses by BlackSpider MailControl - Ernest Friedman-Hill Informatics Decision Sciences Phone: (925) 294-2154 Sandia National Labs PO Box 969, MS 9012ejfr...@sandia.gov Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: OutOfMemory after multiple assertions-resets
The best thing to do would be to try to figure out where the memory is going, and whether it's a bug, or a normal consequence of how you're operating. There's no reason why, given what you've described, memory usage should increase over time, so there's either something you're not telling me, or there's a bug someplace. Can you try to check it out using any kind of a heap profiler? On Feb 17, 2010, at 10:43 PM, Sam Sarjant wrote: Hi. I am using JESS to represent a relational environment for an agent to interact in (Blocks World, to be specific, if that helps). At each state, I am first resetting the Rete object and then asserting the state of the environment. From these assertions, further assertions are made by using rules which define extra predicates. For example, if I assert (on a b), I also create the (above a b) and possibly (clear a), depending on the exact state of the environment when (run) is called. Anyway, the agent receives this information, chooses an action to take, and the environment is updated again by resetting and re-asserting. While I could contain all operations within JESS in this particular environment, some Java code is required to be run during the process for other environments, so this is why I don't simply operate using assert and retract. Obviously this doesn't fit the idea that generally rule bases remain static, but the performance I get is reasonable. My problem lies in the fact that after several hundred (or perhaps thousand) of these assertion, resetting loops, Java or JESS runs out of memory and throws an OutOfMemoryException. The rules for defining extra predicates are asserted only once, but queries are asserted roughly each iteration for state matching, though they should be asserting over one-another (defqueries of the same name). Is there something I can do to 'flush' JESS, or stop it storing these reset assertions? Or would it be better to periodically create a new Rete object, load in the rules and continue? - Sam Sarjant -- View this message in context: http://old.nabble.com/OutOfMemory-after-multiple-assertions-resets-tp27634092p27634092.html Sent from the Jess mailing list archive at Nabble.com. To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov . - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
Re: JESS: rule in jess : LHS based Event timing,
Look at question 9 in the FAQ: http://www.jessrules.com/jess/FAQ.shtml#Q9 Just make your idle fact include the current time (you can use Jess's time function to get it). Then you can write rules that match the current time as included in this fact. On Feb 4, 2010, at 12:39 PM, Yasir Khalid wrote: Hai There, I am curious about a rule that the pattern (LHS) is depended on timing event, what i meant the rule fired on specific time. for example, a dummy and small program that should able to print out Good Morning for every 8'Clock morning , I have tried to browse and see on the manual, i just could not find any idea on how to do it, I am even a 'dirty' program, which create recursive function which is called itself, and it has if statement to check the is it 8'Clock, plus dummy rule, which call the that particular function, and what i got long bunch of run time error(Obvious... ) So is there any suggestion ? -- - Yasir - - Ernest Friedman-Hill Informatics Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com To unsubscribe, send the words 'unsubscribe jess-users y...@address.com' in the BODY of a message to majord...@sandia.gov, NOT to the list (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.