JESS: Problem with definstance
Hi, I'm sure this is a trivial error and I'm going to kick myself when someone tells me what I've done wrong, but here goes anyway: I'm trying to create shadow facts that subclass a deftemplate that's already been added to the Rete. When I try and add the java bean using definstance I get a ClassCastException as follows: java.lang.ClassCastException at jess.DefinstanceList.createNewShadowFact(DefinstanceList.java:206) at jess.DefinstanceList.definstance(DefinstanceList.java:275) at jess.Rete.definstance(Rete.java:1317) at jess.Rete.definstance(Rete.java:1309) at jess.extensions.test.framework.JessTestCase.assertOrder(JessTestCase.java:83) at jess.extensions.test.framework.MyTest.testSetTagValue(MyTest.java:175) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ... I've traced it through and it looks as though (through a beginner's eyes at least :-) a Value object with an m_object value of "nil" has appeared in the template so when the DefinstanceList tries to cast it to a (SerializablePD) it goes bang. The problem is I don't know where the nil Value is coming from. It always seems to be the second property that it tries though. The first (a property of type long) seems to succeed without exception. Does anyone know why I might be getting this? Before I try and define the instance, I'm running the following setup code: executeCommand("(deftemplate orders (slot orderId) (slot Tag8))"); //stub method that just creates the superclass template I'm trying to extend in the Rete rete.defclass("test-orders", "jess.extensions.test.templates.Order", "orders"); //define the test-orders class as a subclass of "orders" as defined above rete.definstance("test-orders", order, true); //create the shadow fact based on an object of type jess.extensions.test.templates.Order The first two commands succeed. The third fails with the ClassCastException shown above. The Order class itself has about 35 fields, two of which override the slots created in the deftemplate command shown above. Interestingly, the one property-to-slot conversion that succeeds before the ClassCastException is thrown is for the first of these two slots (orderId). It is not an explicit subclass of any other object - if that makes a difference, which I wouldn't expect. Can anyone shed any light on why this is happening and the definstance fails? Any help would be very gratefully received. Thanks in advance David <> This message contains confidential information and is intended only for the named individual. If you are not the named addressee, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this message in error and delete this e-message from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, delayed in transmission, incomplete, or may contain viruses. 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. To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED]
Re: JESS: Jess DE & JSR-94
I think erich.oliphant wrote: > Hi, > We are using the JSR-94 interface but would like to use JessDE for > debugging,etc. Will jessDE support the XML formatted files required by the > JSR-94 interface ? There are two JSR94 drivers. There's the reference implementation that comes with the JSR94 package from Sun. It only supports a weird XML rule format in which Jess language code is "wrapped" with XML tags. This driver works with Jess 6 and I do not encourage anyone to use it. It was just a proof-of-concept. There also the new JSR94 driver that is packaged with recent versions of Jess 7. It supports JessML *and* Jess language code. In fact, the example given in the manual show it being used with Jess language code, not JessML. If you're using the JessDE, then you'll need to use this new Jess 7 driver. So tell me where you got the idea that JessML was required if you were using javax.rules? I'd like to change it if I can to make it clear that it's not. - Ernest Friedman-Hill Advanced Software Research Phone: (925) 294-2154 Sandia National LabsFAX: (925) 294-2234 PO Box 969, MS 9012 [EMAIL PROTECTED] Livermore, CA 94550 http://herzberg.ca.sandia.gov To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED]
Re: JESS: Problem with definstance
I think David Firmin wrote: > I'm trying to create shadow facts that subclass a deftemplate that's > already been added to the Rete. When I try and add the java bean using > definstance I get a ClassCastException as follows: > > java.lang.ClassCastException > at jess.DefinstanceList.createNewShadowFact(DefinstanceList.java:206) > at jess.DefinstanceList.definstance(DefinstanceList.java:275) Jess is assuming that the given class "looks like" a subclass of the deftemplate -- i.e., if the template has slots foo and bar, then the class had better have getFoo() and getBar() methods. It can have additional properties as well, of course, as befits a subclass. In any case, this is a lousy error message -- Jess should explicitly detect and report this problem. - Ernest Friedman-Hill Advanced Software Research Phone: (925) 294-2154 Sandia National LabsFAX: (925) 294-2234 PO Box 969, MS 9012 [EMAIL PROTECTED] Livermore, CA 94550 http://herzberg.ca.sandia.gov To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED]
Re: JESS: Problem with definstance
Hi, Thanks for this, although I'm still missing something I think. The Order class I'm trying to define as an instance does have accessors and modifiers for all its properties, including the two defined on the superclass deftemplate that's already been created in the Rete. Given this, I'm still a little confused as to how the nil Value arises that causes the ClassCastException I'm getting and I'm still not sure how to correct it. Is there anything else that would cause this exception to be thrown? Many thanks in advance Regards David ejfried Sent by: owner-jess-users@ To sandia.govjess-users@sandia.gov cc 05/10/2005 14:34 Subject Re: JESS: Problem with definstance Please respond to [EMAIL PROTECTED] .gov I think David Firmin wrote: > I'm trying to create shadow facts that subclass a deftemplate that's > already been added to the Rete. When I try and add the java bean using > definstance I get a ClassCastException as follows: > > java.lang.ClassCastException > at jess.DefinstanceList.createNewShadowFact(DefinstanceList.java:206) > at jess.DefinstanceList.definstance(DefinstanceList.java:275) Jess is assuming that the given class "looks like" a subclass of the deftemplate -- i.e., if the template has slots foo and bar, then the class had better have getFoo() and getBar() methods. It can have additional properties as well, of course, as befits a subclass. In any case, this is a lousy error message -- Jess should explicitly detect and report this problem. - Ernest Friedman-Hill Advanced Software Research Phone: (925) 294-2154 Sandia National LabsFAX: (925) 294-2234 PO Box 969, MS 9012 [EMAIL PROTECTED] Livermore, CA 94550 http://herzberg.ca.sandia.gov To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED] To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED]
JESS: Central data storage for multiople Jess instances
Hello everybody, I working on the model from the field of social simulation. I am using RePast and Jess to make my agents think in a declarative way. At the moment I have a separate Jess instance for every agent (300 agents = 300 Rete instances). I was just wondering if it is possible to have some central place for putting information which is accessible form every Rete instance. For example every agent needs to now some facts about the world and I would like to store in not in the agent's working memory but somehow separately. I was thinking of making a Java template and refer to it as a shadow fact from every instance. Does anybody have a better idea for my issue of central knowledge storage and is it better to have a separate Jess instance for every agent or have only one instance for the whole model (in terms of programming and rule writing having separate Jess instance for every agent is far more simple I suppose). Many thanks in advance! Bogdan Werth Doctoral Researcher Centre for Policy Modelling The Graduate School of Business Aytoun Building Aytoun Street Manchester M1 3GH UK Tel: +44 161 247 6481 Fax: +44 161 247 6802 Email: [EMAIL PROTECTED] Web: http://cfpm.org/~bogdan ** Before acting on this email or opening any attachments you should read the Manchester Metropolitan University's email disclaimer available on its website http://www.mmu.ac.uk/emaildisclaimer *** To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED]
Re: JESS: Jess DE & JSR-94
Great thanks for the info was reading about it in Jess in action which was of course written for v6 -Original Message- From: [EMAIL PROTECTED] Date: Wed, 5 Oct 2005 05:53:04 To:jess-users@sandia.gov Subject: Re: JESS: Jess DE & JSR-94 I think erich.oliphant wrote: > Hi, > We are using the JSR-94 interface but would like to use JessDE for > debugging,etc. Will jessDE support the XML formatted files required by the > JSR-94 interface ? There are two JSR94 drivers. There's the reference implementation that comes with the JSR94 package from Sun. It only supports a weird XML rule format in which Jess language code is "wrapped" with XML tags. This driver works with Jess 6 and I do not encourage anyone to use it. It was just a proof-of-concept. There also the new JSR94 driver that is packaged with recent versions of Jess 7. It supports JessML *and* Jess language code. In fact, the example given in the manual show it being used with Jess language code, not JessML. If you're using the JessDE, then you'll need to use this new Jess 7 driver. So tell me where you got the idea that JessML was required if you were using javax.rules? I'd like to change it if I can to make it clear that it's not. - Ernest Friedman-Hill Advanced Software Research Phone: (925) 294-2154 Sandia National LabsFAX: (925) 294-2234 PO Box 969, MS 9012 [EMAIL PROTECTED] Livermore, CA 94550 http://herzberg.ca.sandia.gov To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED] To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED]
JESS: Firing on subsets (again)
Hey guys I tried your advise but was unsuccessful. Alan, I really thought your method would do exactly what I was trying to accomplish, but I thought that you were saying to assert that line ...as opposed to the '?' being in the rule itself. Here's what I'm trying to do: (MAIN::webservice (service getaddress) (project sage) (org georgetown) (analystname blake) (analystrole lead) (priority low) (reldatetime within_an_hour) (location dc) (action run) ) (defrule run-service ?inputservice <- Hey guys I tried your advise but was unsuccessful. Alan, I really thought your method would do exactly what I was trying to accomplish, but I thought that you were saying to assert that line ...as opposed to the '?' being in the rule itself. Here's what I'm trying to do: (MAIN::webservice (service getaddress) (project sage) (org georgetown) (analystname blake) (analystrole lead) (priority low) (reldatetime within_an_hour) (location dc) (action run) ) (defrule run-service ?inputservice <- (inputservice ?service ?project ?org ?analystname ?analystrole ?priority ?reldatetime ?location) ?newserv <- (webservice (service ?service) (project ?project) (org ?org) (analystname ?analystname) (analystrole ?analystrole) (priority ?priority) (reldatetime ?reldatetime) (location ?location) (action run) ) => (store RETURN "run") (printout t "JESS: Found an existing service = " ?service crlf) (printout t "JESS: The user-specified action is to run the service! " crlf) (retract ?inputservice)) Then assert: (assert (inputservice getaddress sage georgetown blake lead low within_an_hour dc)) Which obviously fires and give the desired result. But we would like for the user to be allowed to leave a field empty and still have this rule fire, so that this would also fire for us: (assert (inputservice getaddress ? georgetown ? lead low within_an_hour dc)) This is what I thought you were saying to do Alan, but after re-reading your post I see that the '?' is in the rule. But if we implemented it that way, we would have a rule like: ?inputservice <- (inputservice ?service ? ? ? ? ? ? ?) Which would be useless. So my question is, is there a way to have this rule fire for a specific set of values, and if some of the fields are left blank? Just f.y.i I thought it could be done by changing the second line of the rule to: ?newserv <- (webservice (service ?service) (project ?project|nil) (org ?org|nil) (analystname ?analystname|nil) (analystrole ?analystrole|nil) (priority ?priority|nil) (reldatetime ?reldatetime|nil) (location ?location|nil) (action run) ) nil being the value passed from Java when the field was left blank ...needless to say this didn't work out. thanks for the help guys -Jerome BG(inputservice ?service ?project ?org ?analystname ?analystrole ?priority ?reldatetime ?location) ?newserv <- (webservice (service ?service) (project ?project) (org ?org) (analystname ?analystname) (analystrole ?analystrole) (priority ?priority) (reldatetime ?reldatetime) (location ?location) (action run) ) => (store RETURN "run") (printout t "JESS: Found an existing service = " ?service crlf) (printout t "JESS: The user-specified action is to run the service! " crlf) (retract ?inputservice)) Then assert: (assert (inputservice getaddress sage georgetown blake lead low within_an_hour dc)) Which obviously fires and give the desired result. But we would like for the user to be allowed to leave a field empty and still have this rule fire, so that this would also fire for us: (assert (inputservice getaddress ? georgetown ? lead low within_an_hour dc)) This is what I thought you were saying to do Alan, but after re-reading your post I see that the '?' is in the rule. But if we implemented it that way, we would have a rule like: ?inputservice <- (inputservice ?service ? ? ? ? ? ? ?) Which would be useless. So my question is, is there a way to have this rule fire for a specific set of values, and if some of the fields are left blank? Just f.y.i I thought it could be done by changing the second line of the rule to: ?newserv <- (webservice (service ?service) (project ?project|nil) (org ?org|nil) (analystname ?analystname|nil) (analystrole ?analystrole|nil) (priority ?priority|nil) (reldatetime ?reldatetime|nil) (location ?location|nil) (action run) ) nil being the value passed from Java when the field was left blank ...needless to say this didn't work out. thanks for the help guys -Jerome BG __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED]
Re: JESS: Problem with definstance
I think David Firmin wrote: > > Hi, > Thanks for this, although I'm still missing something I think. > > The Order class I'm trying to define as an instance does have accessors and > modifiers for all its properties, including the two defined on the > superclass deftemplate that's already been created in the Rete. To clarify, yes or no: does the template define any slots that *don't* correspond to properties in the Order class? - Ernest Friedman-Hill Advanced Software Research Phone: (925) 294-2154 Sandia National LabsFAX: (925) 294-2234 PO Box 969, MS 9012 [EMAIL PROTECTED] Livermore, CA 94550 http://herzberg.ca.sandia.gov To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED]
Re: JESS: Firing on subsets (again)
Jerome, You can match against ordered facts like so: (defrule myRule (first second ? fourth fifth ? seventh) => (printout t "Rule fired") ) What this does is to match any of the following facts: (assert (first second dontcare fourth fifth dontcare seventh)) (assert (first second anything fourth fifth here seventh)) (assert (first second x fourth fifth y seventh)) (assert (first second nil fourth fifth nil seventh)) The question marks in the rule above will make the rule pattern match facts with the specified values (e.g. first, second, etc.) at the positions indicated and with *any* value at ordinal position 3 and 6". In this case the question marks are unnamed variables that get bound to whatever is at those positions in the matching fact(s). You could bind named variables like so: (defrule myRule (first second ?position3 fourth fifth ?position6 seventh) => (printout t "Rule fired - values at position 3 and 6 are " ?position3 ", " ?position6) ) I would suggest that you try a simplified version of your rule cut down to just one or two fields and experiment with how the pattern matching works. (defrule run-service ?inputservice <- (inputservice ?service ?project ?org ?analystname ?analystrole ?priority ?reldatetime ?location) ?newserv <- (webservice (service ?service) (project ?project) (org ?org) (analystname ?analystname) (analystrole ?analystrole) (priority ?priority) (reldatetime ?reldatetime) (location ?location) (action run) ) => (store RETURN "run") (printout t "JESS: Found an existing service = " ?service crlf) (printout t "JESS: The user-specified action is to run the service! " crlf) (retract ?inputservice)) If this rule isn't firing for you and you think it should, try removing some of the slot matches in the second pattern. Maybe one or more of the slot values aren't *exactly* the same in both facts and so are preventing them from matching. Start with only one or two slots and keep adding them back until the rule stops firing. For example, (defrule run-service ?inputservice <- (inputservice ?service ?project ?org ?analystname ?analystrole ?priority ?reldatetime ?location) ?newserv <- (webservice (service ?service) (action run) ) => (store RETURN "run") (printout t "JESS: Found an existing service = " ?service crlf) (printout t "JESS: The user-specified action is to run the service! " crlf) (retract ?inputservice) ) Good luck! alan To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED]
Re: JESS: Firing on subsets (again)
Thanks again Alan and I understand what your saying, but the fields where the blank values will be unknown. Therefore to allow any of them to be random I would have to make a useless rule using ? as the varible for everything but the actual service. So even though we would like to match to empty fields ...or some random prechoosen value, we still need the other feilds so that the rule won't fire on every entry. just to help in giving you all am idea in what im trying to do here is another try I made at it: ?newserv <- (webservice (service ?service) (project ?project|?) (org ?org|?) (analystname ?analystname|?) (analystrole ?analystrole|?) (priority ?priority|?) (reldatetime ?reldatetime|?) (location ?location|?) (action run) ) ...maybe I dont underst and the '|' operator on the left-hand side, but I thought that meant 'or', but this wont fire for me either. thanks again -Jerome BG --- Alan Moore <[EMAIL PROTECTED]> wrote: > Jerome, > > You can match against ordered facts like so: > > (defrule myRule > (first second ? fourth fifth ? seventh) > => > (printout t "Rule fired") > ) > > What this does is to match any of the following > facts: > > (assert (first second dontcare fourth fifth dontcare > seventh)) > (assert (first second anything fourth fifth here > seventh)) > (assert (first second x fourth fifth y seventh)) > (assert (first second nil fourth fifth nil seventh)) > > The question marks in the rule above will make the > rule pattern match > facts with the specified values (e.g. first, second, > etc.) at the > positions indicated and with *any* value at ordinal > position 3 and 6". > In this case the question marks are unnamed > variables that get bound to > whatever is at those positions in the matching > fact(s). > > You could bind named variables like so: > > (defrule myRule > (first second ?position3 fourth fifth ?position6 > seventh) > => > (printout t "Rule fired - values at position 3 > and 6 are " > ?position3 ", " ?position6) > ) > > I would suggest that you try a simplified version of > your rule cut down > to just one or two fields and experiment with how > the pattern matching > works. > > > (defrule run-service > >?inputservice <- (inputservice ?service > ?project > > ?org ?analystname ?analystrole ?priority > ?reldatetime > > ?location) > >?newserv <- (webservice (service ?service) > (project > > ?project) (org ?org) (analystname ?analystname) > > (analystrole ?analystrole) (priority ?priority) > > (reldatetime ?reldatetime) (location ?location) > > (action run) ) > > => > > (store RETURN "run") > > (printout t "JESS: Found an existing service = " > > ?service crlf) > > (printout t "JESS: The user-specified action is > to > > run the service! " crlf) > > (retract ?inputservice)) > > If this rule isn't firing for you and you think it > should, try removing > some of the slot matches in the second pattern. > Maybe one or more of the > slot values aren't *exactly* the same in both > facts and so are > preventing them from matching. Start with only one > or two slots and keep > adding them back until the rule stops firing. For > example, > > (defrule run-service > ?inputservice <- (inputservice ?service ?project > ?org ?analystname > ?analystrole ?priority ?reldatetime ?location) > ?newserv <- (webservice (service ?service) > (action run) ) > => >(store RETURN "run") >(printout t "JESS: Found an existing service = " > ?service crlf) >(printout t "JESS: The user-specified action is > to run the service! " > crlf) >(retract ?inputservice) > ) > > Good luck! > > alan > > > To unsubscribe, send the words 'unsubscribe > jess-users [EMAIL PROTECTED]' > in the BODY of a message to [EMAIL PROTECTED], > NOT to the list > (use your own address!) List problems? Notify > [EMAIL PROTECTED] > > > __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED]
Re: JESS: Firing on subsets (again)
I think Jerome Butchergreen wrote: [Charset iso-8859-1 unsupported, filtering to ASCII...] > Thanks again Alan and I understand what your saying, > but the fields where the blank values will be unknown. You need to think clearlt about what you're trying to accomplish. I think on reflection you'll realize that you've got some logical loopholes. Here is the rule you're trying to write: (defrule run-service ?inputservice <- (inputservice ?service ?project ?org ?analystname ?analystrole ?priority ?reldatetime ?location) ?newserv <- (webservice (service ?service) (project ?project) (org ?org) (analystname ?analystname) (analystrole ?analystrole) (priority ?priority) (reldatetime ?reldatetime) (location ?location) (action run) ) => (store RETURN "run") (printout t "JESS: Found an existing service = " ?service crlf) Now, what this rule says is that if there are an inputservice fact and a webservice fact, and all of the data in the ordered inputservice fact matches the contents of the webservice fact exactly, then the rule should fire. What you're saying is that maybe the inputservice fact will contain some nil values, and you want the rule to still fire. First, consider the corner case: what if all the values in inputservice are nil? Should the rule match? I suspect not. Now, what if "service" is nil, but all the others match. Should the rule fire? I suspect not, although I don't know for sure. So there are some fields that *must* match, and some that don't need to. If they don't need to, why check them at all? Why not just check the ones that must match? Why not write, for example, (defrule run-service ?inputservice <- (inputservice ?service ?project ?org ? ? ? ? ?) ?newserv <- (webservice (service ?service) (project ?project) (org ?org) (action run)) => (store RETURN "run") (printout t "JESS: Found an existing service = " ?service crlf) - Ernest Friedman-Hill Advanced Software Research Phone: (925) 294-2154 Sandia National LabsFAX: (925) 294-2234 PO Box 969, MS 9012 [EMAIL PROTECTED] Livermore, CA 94550 http://herzberg.ca.sandia.gov To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED]
Re: JESS: Central data storage for multiople Jess instances
I think Bogdan Werth wrote: [Charset iso-8859-1 unsupported, filtering to ASCII...] > Hello everybody, > I working on the model from the field of social simulation. I am using RePast and Jess to make my agents think in a declarative way. At the moment I have a separate Jess instance for every agent (300 agents = 300 Rete instances). Don't do that. Just use one Jess instance. Facts that are specific to one agent should include an agent-specific identifier, and rules that operate on these facts should take care to match them as needed to keep the various agent's logical processes separate. - Ernest Friedman-Hill Advanced Software Research Phone: (925) 294-2154 Sandia National LabsFAX: (925) 294-2234 PO Box 969, MS 9012 [EMAIL PROTECTED] Livermore, CA 94550 http://herzberg.ca.sandia.gov To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED]