Re: JESS: Defining default rules
[EMAIL PROTECTED] wrote: > >You don't need to avoid salience at all costs; you should avoid > >excessive use of it, and you should avoid trying to force all rules to > >fire in some specified order using it. Hi Henrique, To echo Ernest's point: The Jess Wiki contains a brief article on this subject. I welcome your feedback on its usefulness as well as any suggestions on how to improve it. http://herzberg.ca.sandia.gov/jesswiki/view?SalienceUsageTips Cheers, Jason Morris Jess Wiki Moderator On 10/7/05, Henrique Lopes Cardoso <[EMAIL PROTECTED]> wrote: > Thank you for the quick reply. > But then again, I can avoid salience if I combine your approach with > module definitions. > For instance: > > (defrule default-rule >?a <- (a) >(not (processed ?a)) > => >(default-action) >(assert (processed ?a)) > ) > > (defmodule m) > (defrule m-rule >?a <- (a) >(not (processed ?a)) > => >(special-action) >(assert (processed ?a)) > ) > > (assert (a)) > (focus m) > > (run) > > > Is this a bad idea? > It seems to fit my purpose, since I may have lots of rules that are best > organized with modules, which conceptualy correspond to contexts that > are created in run-time. Therefore, when a fact arrives (which is > defined using a deftemplate that contains a slot named "context") I > focus on the corresponding module (which was previously created). > Something like: > > (defrule change-focus >(foo (context ?ctx)) > => >(focus ?ctx) > ) > > (defrule default-rule >?foo <- (foo) >(not (processed ?foo)) > => >(default-action) >(assert (processed ?foo)) > ) > > > Should I avoid this by using auto-focus? By the way, can I apply the > auto-focus property to all rules inside a module at once, or must I > define this property in every rule inside a module? > > Henrique > > --- > [EMAIL PROTECTED] wrote: > > >You don't need to avoid salience at all costs; you should avoid > >excessive use of it, and you should avoid trying to force all rules to > >fire in some specified order using it. > > > >The higher-priority rules need to make some change in working memory > >that the lower-priority rules can detect. For example > > > >(defrule default-rule > > ?a <- (a) > > (not (processed ?a)) > > => > > (default-action) > > (assert (processed ?a))) > > > >(defrule special-rule > > (declare (salience 100)) > > ?a <- (a) > > (not (processed ?a)) > > => > > (special-action) > > (assert (processed ?a))) > > > >For each fact ?a, special-rule will fire, and default-rule won't. > > > >I think Henrique Lopes Cardoso wrote: > >[Charset iso-8859-1 unsupported, filtering to ASCII...] > > > > > >>Hi, > >> > >>I am trying to develop a Jess program that considers the use of default > >>rules. > >>Here goes a simple example. > >> > >>I have a rule in the MAIN module, but I want that rule to fire only if > >>no other rule fires. > >>Since the Jess 6 manual discourages the use of salience definitions, I > >>am thinking on using modules. > >> > >>That is, I have a module where I have some rules that are meant to fire > >>when a fact appears in MAIN. If no rule fires, then the default rule in > >>MAIN should fire. > >> > >>Example: > >> > >>(defrule default-rule (a) => (printout t "This is the default rule." crlf)) > >> > >>(defmodule m) > >>(defrule m-rule (a) => (printout t "This is the rule in m." crlf)) > >> > >>(assert (a)) > >>(focus m) > >> > >>(run) > >> > >>Now, both rules fire: first the one inside module m and then the > >>default-rule in MAIN. If I do not want the default-rule to fire, must I > >>retract fact (a)? > >> > >>(defrule m-rule > >>?x<- (a) > >>=> > >>(retract ?x) (printout t "This is the rule in m." crlf) > >>) > >> > >>What if I want to keep a history of all the facts? > >> > >>Thanks. > >> > >>Henrique > >> > >> > >>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] > >> > >> > >> > >> > > > > > > > >- > >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: Defining default rules
Thank you for the quick reply. But then again, I can avoid salience if I combine your approach with module definitions. For instance: (defrule default-rule ?a <- (a) (not (processed ?a)) => (default-action) (assert (processed ?a)) ) (defmodule m) (defrule m-rule ?a <- (a) (not (processed ?a)) => (special-action) (assert (processed ?a)) ) (assert (a)) (focus m) (run) Is this a bad idea? It seems to fit my purpose, since I may have lots of rules that are best organized with modules, which conceptualy correspond to contexts that are created in run-time. Therefore, when a fact arrives (which is defined using a deftemplate that contains a slot named "context") I focus on the corresponding module (which was previously created). Something like: (defrule change-focus (foo (context ?ctx)) => (focus ?ctx) ) (defrule default-rule ?foo <- (foo) (not (processed ?foo)) => (default-action) (assert (processed ?foo)) ) Should I avoid this by using auto-focus? By the way, can I apply the auto-focus property to all rules inside a module at once, or must I define this property in every rule inside a module? Henrique --- [EMAIL PROTECTED] wrote: You don't need to avoid salience at all costs; you should avoid excessive use of it, and you should avoid trying to force all rules to fire in some specified order using it. The higher-priority rules need to make some change in working memory that the lower-priority rules can detect. For example (defrule default-rule ?a <- (a) (not (processed ?a)) => (default-action) (assert (processed ?a))) (defrule special-rule (declare (salience 100)) ?a <- (a) (not (processed ?a)) => (special-action) (assert (processed ?a))) For each fact ?a, special-rule will fire, and default-rule won't. I think Henrique Lopes Cardoso wrote: [Charset iso-8859-1 unsupported, filtering to ASCII...] Hi, I am trying to develop a Jess program that considers the use of default rules. Here goes a simple example. I have a rule in the MAIN module, but I want that rule to fire only if no other rule fires. Since the Jess 6 manual discourages the use of salience definitions, I am thinking on using modules. That is, I have a module where I have some rules that are meant to fire when a fact appears in MAIN. If no rule fires, then the default rule in MAIN should fire. Example: (defrule default-rule (a) => (printout t "This is the default rule." crlf)) (defmodule m) (defrule m-rule (a) => (printout t "This is the rule in m." crlf)) (assert (a)) (focus m) (run) Now, both rules fire: first the one inside module m and then the default-rule in MAIN. If I do not want the default-rule to fire, must I retract fact (a)? (defrule m-rule ?x<- (a) => (retract ?x) (printout t "This is the rule in m." crlf) ) What if I want to keep a history of all the facts? Thanks. Henrique 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] - 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]
Re: JESS: Problem with definstance
Thanks again. I've identified the problem. I had bean properties for all slots, but some of the slot names started with capital letters which seemed to throw definstance (I should have thought of this earlier). I've resolved this by renaming the slots so that they're more in line with the bean specs. Thanks for all your help Regards David ejfried Sent by: owner-jess-users@ To sandia.govjess-users@sandia.gov cc 05/10/2005 20:03 Subject Re: JESS: Problem with definstance Please respond to [EMAIL PROTECTED] .gov 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] 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: Problems with Jess and Eclipse
Matt, Whoops, sorry - I didn't see your attachment. alan [EMAIL PROTECTED] wrote: In the screenshot, you show that you've defined two "classpath variables", one named source pointing to the "source" directory, and one named "jess" pointing to jess.jar. This is no guarantee that you've *used* those classpath variables for anything. This is like defining a Windows environment variable named MY_JARS and expecting them to automatically show up on the CLASSPATH: it won't happen, of course, unless your CLASSPATH includes %MY_JARS% . Anyway, what's really relevant is not these global preferences, but the individual project properties. Right-click on your project and choose "Properties." Click "Java Build Path". On the Source tab, you want to have any source folders in your project. This would be a place you could use your "source" variable, although this would actually be somewhat unconventional. Eclipse should automatically put entries for the actual source folders in your project, so your project may not be set up properly as a Java project in the first place. I think Matthew Hutchinson wrote: [Charset iso-8859-1 unsupported, filtering to ASCII...] G'day everyone, First of all I'd like to say I'm starting to get into the programming aspect of my PhD and its really interesting to learn JESS; great product and great support. Having set up eclipse with the jess plugin, I was dissapointed to find something was not working. I've set my windows classpath to match where my code is, and even set the project class path (in eclipse) to the same directory. For some reason it just keeps telling me that it can't find the "Address" class... which is quite obviously there. Perhaps I've just missed something obvious? Thanks, Matt - 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]
Re: JESS: Defining default rules
You don't need to avoid salience at all costs; you should avoid excessive use of it, and you should avoid trying to force all rules to fire in some specified order using it. The higher-priority rules need to make some change in working memory that the lower-priority rules can detect. For example (defrule default-rule ?a <- (a) (not (processed ?a)) => (default-action) (assert (processed ?a))) (defrule special-rule (declare (salience 100)) ?a <- (a) (not (processed ?a)) => (special-action) (assert (processed ?a))) For each fact ?a, special-rule will fire, and default-rule won't. I think Henrique Lopes Cardoso wrote: [Charset iso-8859-1 unsupported, filtering to ASCII...] > Hi, > > I am trying to develop a Jess program that considers the use of default > rules. > Here goes a simple example. > > I have a rule in the MAIN module, but I want that rule to fire only if > no other rule fires. > Since the Jess 6 manual discourages the use of salience definitions, I > am thinking on using modules. > > That is, I have a module where I have some rules that are meant to fire > when a fact appears in MAIN. If no rule fires, then the default rule in > MAIN should fire. > > Example: > > (defrule default-rule (a) => (printout t "This is the default rule." crlf)) > > (defmodule m) > (defrule m-rule (a) => (printout t "This is the rule in m." crlf)) > > (assert (a)) > (focus m) > > (run) > > Now, both rules fire: first the one inside module m and then the > default-rule in MAIN. If I do not want the default-rule to fire, must I > retract fact (a)? > > (defrule m-rule > ?x<- (a) > => > (retract ?x) (printout t "This is the rule in m." crlf) > ) > > What if I want to keep a history of all the facts? > > Thanks. > > Henrique > > > 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] > > - 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: Problems with Jess and Eclipse
In the screenshot, you show that you've defined two "classpath variables", one named source pointing to the "source" directory, and one named "jess" pointing to jess.jar. This is no guarantee that you've *used* those classpath variables for anything. This is like defining a Windows environment variable named MY_JARS and expecting them to automatically show up on the CLASSPATH: it won't happen, of course, unless your CLASSPATH includes %MY_JARS% . Anyway, what's really relevant is not these global preferences, but the individual project properties. Right-click on your project and choose "Properties." Click "Java Build Path". On the Source tab, you want to have any source folders in your project. This would be a place you could use your "source" variable, although this would actually be somewhat unconventional. Eclipse should automatically put entries for the actual source folders in your project, so your project may not be set up properly as a Java project in the first place. I think Matthew Hutchinson wrote: [Charset iso-8859-1 unsupported, filtering to ASCII...] > G'day everyone, > > First of all I'd like to say I'm starting to get into the programming aspect > of my PhD and its really interesting to learn JESS; great product and great > support. > Having set up eclipse with the jess plugin, I was dissapointed to find > something was not working. I've set my windows classpath to match where my > code is, and even set the project class path (in eclipse) to the same > directory. For some reason it just keeps telling me that it can't find the > "Address" class... which is quite obviously there. > > Perhaps I've just missed something obvious? > > Thanks, > Matt > - 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: Problems with Jess and Eclipse
Matt, Setting the windows classpath environment variable shouldn't be necessary or may not even work at all since eclipse is likely to use classloaders that are limited to those directories/jars specified in the project configuration. I'm not an eclipse expert but you might want to ping the eclipse mailing list/faq for answers if the following doesn't help. You didn't mention which bit of software couldn't find your Address class. I'm guessing that Jess is parsing or executing some code and didn't find the class (e.g. is this an eclipse or Jess error message?) Could you please send us a copy of the error message? Also, be sure you have told Jess about your class. Did you do an (import) and/or (defclass) in the file exhibiting the problem? alan Matthew Hutchinson wrote: G'day everyone, First of all I'd like to say I'm starting to get into the programming aspect of my PhD and its really interesting to learn JESS; great product and great support. Having set up eclipse with the jess plugin, I was dissapointed to find something was not working. I've set my windows classpath to match where my code is, and even set the project class path (in eclipse) to the same directory. For some reason it just keeps telling me that it can't find the "Address" class... which is quite obviously there. Perhaps I've just missed something obvious? Thanks, Matt -- Matthew Hutchinson Ph.D. Candidate Department of Spatial Sciences Curtin University of Technology GPO Box U1987 Perth, Western Australia 6845 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: Defining default rules
Hi, I am trying to develop a Jess program that considers the use of default rules. Here goes a simple example. I have a rule in the MAIN module, but I want that rule to fire only if no other rule fires. Since the Jess 6 manual discourages the use of salience definitions, I am thinking on using modules. That is, I have a module where I have some rules that are meant to fire when a fact appears in MAIN. If no rule fires, then the default rule in MAIN should fire. Example: (defrule default-rule (a) => (printout t "This is the default rule." crlf)) (defmodule m) (defrule m-rule (a) => (printout t "This is the rule in m." crlf)) (assert (a)) (focus m) (run) Now, both rules fire: first the one inside module m and then the default-rule in MAIN. If I do not want the default-rule to fire, must I retract fact (a)? (defrule m-rule ?x<- (a) => (retract ?x) (printout t "This is the rule in m." crlf) ) What if I want to keep a history of all the facts? Thanks. Henrique 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]