Skipping a Rule - Help needed

View: New views
8 Messages — Rating Filter:   Alert me  

Skipping a Rule - Help needed

by katie678 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I am complety new to Jess and am in desperate need of help please.

I am trying to create a simple tool for fire a list of questions and for some reason, one question is being skipped all of the time.

Also when some of my rules are fired, they suggestions are not being outputed.

I have attached my file, if someone could help please.

Katiecareer12.txt

Re: JESS: Skipping a Rule - Help needed

by Jason Morris :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, May 10, 2008 at 3:45 PM, katie678 <conway.geraldine@...> wrote:

Hi,

I am complety new to Jess and am in desperate need of help please.

Hi Katie,

Here is a list of issues that caught my eye:

1.  If you have a function B that depends on function A, then function A *must* be defined in your Jess script *before* function B, else B will not "know about" A. 
    Look at your code carefully to spot this one.
2.  All LHS patterns are implicitly joined with an (and).  There is no need to use (and <pattern 1> <pattern 2> ... <pattern n> ) in your rules.  Fix all the rules that do this.
3.  Don't use the (or) connective to simply match facts having alternative slot values.  If you want to match on (foo) facts with a slot called "value" such that value = 5, 10, or 15 you would write:

     (defrule find-foos
         (foo (value ?v&5|10|25))
     =>
     ;; do something interesting here
    )
Fix all the rules where you have done this.
   
4.  If you want a fact matched over a range of slot values, then you use predicate constraints like so:

    Match all (foo) fact with value between 1 and 3:
    (defrule find-foos-from-1-to-3
        (foo (value ?v&:(>= ?v 1)&:(< ?v 4)))
    =>
    ;; Do something interesting here
    )
Make these corrections, too.
   
5.  When you have two or more rules for which there will never be more than one fact that activates more than one rule at a time, there is no need to enforce
activation order using salience -- I think this is where your code diverges from the Tax Adviser example in "Jess in Action".  The tax adviser will actually recommend multiple
forms whereas you just recommend one course of action.  When you do use salience, as in all programming, avoid using unbound "magic numbers" like 100000 and 70000. 
These are arbitrary and just bad karma -- the danger is where do you stop once you start?  100001, 100002, 70001, etc? 
Take a look at the article on the Jess wiki http://www.jessrules.com/jesswiki/view?SalienceUsageTips and in the documentation http://www.jessrules.com/jess/docs/71/rules.html#salience regarding salience. 

Less important items...

1.  You've got some typos in your questions that make answering them awkward.  For example:
    "Do you want to work full time after homes?" makes no sense.
    "How many homes a week do you want to work?" -- clearly you meant "hours a week".
    Go through all your questions and edit them.

2.  Good programmers error-trap their code for bad inputs.  Any place that you are expecting numerical input (asking about ages, dollars, etc.) run the input
through the (numberp) function.  (numberp) stands for number-parse, and gives back a boolean TRUE if its argument parses to any number.

3.  Omit defining (defglobal ?*crlf* = ...) since it's part of Jess now anyway.  Just use the symbol "crlf" anywhere you want a carriage-return-linefeed.

It is important that you make these changes and that I just not give you my corrected solution -- I hope nobody actually does this!
Once I fixed these issues, your program seemed to run just fine.

I hope this helps!

Cheers,
Jason

-----------------------------------------------------------
Jason Morris
Morris Technical Solutions LLC
consulting@...
(517) 304-5883

Re: JESS: Skipping a Rule - Help needed

by katie678 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This type of help is greatly appreciated and the response was so quick.

I will follow all your instructions and see how I get on.

Thanks so much

Katie

Jason Morris wrote:
On Sat, May 10, 2008 at 3:45 PM, katie678 <conway.geraldine@gmail.com>
wrote:

>
> Hi,
>
> I am complety new to Jess and am in desperate need of help please.


Hi Katie,

Here is a list of issues that caught my eye:

1.  If you have a function B that depends on function A, then function A
*must* be defined in your Jess script *before* function B, else B will not
"know about" A.
    Look at your code carefully to spot this one.
2.  All LHS patterns are implicitly joined with an (and).  There is no need
to use (and <pattern 1> <pattern 2> ... <pattern n> ) in your rules.  Fix
all the rules that do this.
3.  Don't use the (or) connective to simply match facts having alternative
slot values.  If you want to match on (foo) facts with a slot called "value"
such that value = 5, 10, or 15 you would write:

     (defrule find-foos
         (foo (value ?v&5|10|25))
     =>
     ;; do something interesting here
    )
Fix all the rules where you have done this.

4.  If you want a fact matched over a range of slot values, then you use
predicate constraints like so:

    Match all (foo) fact with value between 1 and 3:
    (defrule find-foos-from-1-to-3
        (foo (value ?v&:(>= ?v 1)&:(< ?v 4)))
    =>
    ;; Do something interesting here
    )
Make these corrections, too.

5.  When you have two or more rules for which there will never be more than
one fact that activates more than one rule at a time, there is no need to
enforce
activation order using salience -- I think this is where your code diverges
from the Tax Adviser example in "Jess in Action".  The tax adviser will
actually recommend multiple
forms whereas you just recommend one course of action.  When you do use
salience, as in all programming, avoid using unbound "magic numbers" like
100000 and 70000.
These are arbitrary and just bad karma -- the danger is where do you stop
once you start?  100001, 100002, 70001, etc?
Take a look at the article on the Jess wiki
http://www.jessrules.com/jesswiki/view?SalienceUsageTips and in the
documentation http://www.jessrules.com/jess/docs/71/rules.html#salienceregarding
salience.

Less important items...

1.  You've got some typos in your questions that make answering them
awkward.  For example:
    "Do you want to work full time after homes?" makes no sense.
    "How many homes a week do you want to work?" -- clearly you meant "hours
a week".
    Go through all your questions and edit them.

2.  Good programmers error-trap their code for bad inputs.  Any place that
you are expecting numerical input (asking about ages, dollars, etc.) run the
input
through the (numberp) function.  (numberp) stands for number-parse, and
gives back a boolean TRUE if its argument parses to any number.

3.  Omit defining (defglobal ?*crlf* = ...) since it's part of Jess now
anyway.  Just use the symbol "crlf" anywhere you want a
carriage-return-linefeed.

It is important that you make these changes and that I just not give you my
corrected solution -- I hope nobody actually does this!
Once I fixed these issues, your program seemed to run just fine.

I hope this helps!

Cheers,
Jason

-----------------------------------------------------------
Jason Morris
Morris Technical Solutions LLC
consulting@morris-technical-solutions.com
(517) 304-5883

Re: JESS: Skipping a Rule - Help needed

by Jason Morris :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You are very welcome.
Best of luck and keep trying!  ;-)
- Jason

On Sun, May 11, 2008 at 5:43 AM, katie678 <conway.geraldine@...> wrote:

This type of help is greatly appreciated and the response was so quick.

I will follow all your instructions and see how I get on.

Thanks so much

Katie


Jason Morris wrote:
>
> On Sat, May 10, 2008 at 3:45 PM, katie678 <conway.geraldine@...>
> wrote:
>
>>
>> Hi,
>>
>> I am complety new to Jess and am in desperate need of help please.
>
>
> Hi Katie,
>
> Here is a list of issues that caught my eye:
>
> 1.  If you have a function B that depends on function A, then function A
> *must* be defined in your Jess script *before* function B, else B will not
> "know about" A.
>     Look at your code carefully to spot this one.
> 2.  All LHS patterns are implicitly joined with an (and).  There is no
> need
> to use (and <pattern 1> <pattern 2> ... <pattern n> ) in your rules.  Fix
> all the rules that do this.
> 3.  Don't use the (or) connective to simply match facts having alternative
> slot values.  If you want to match on (foo) facts with a slot called
> "value"
> such that value = 5, 10, or 15 you would write:
>
>      (defrule find-foos
>          (foo (value ?v&5|10|25))
>      =>
>      ;; do something interesting here
>     )
> Fix all the rules where you have done this.
>
> 4.  If you want a fact matched over a range of slot values, then you use
> predicate constraints like so:
>
>     Match all (foo) fact with value between 1 and 3:
>     (defrule find-foos-from-1-to-3
>         (foo (value ?v&:(>= ?v 1)&:(< ?v 4)))
>     =>
>     ;; Do something interesting here
>     )
> Make these corrections, too.
>
> 5.  When you have two or more rules for which there will never be more
> than
> one fact that activates more than one rule at a time, there is no need to
> enforce
> activation order using salience -- I think this is where your code
> diverges
> from the Tax Adviser example in "Jess in Action".  The tax adviser will
> actually recommend multiple
> forms whereas you just recommend one course of action.  When you do use
> salience, as in all programming, avoid using unbound "magic numbers" like
> 100000 and 70000.
> These are arbitrary and just bad karma -- the danger is where do you stop
> once you start?  100001, 100002, 70001, etc?
> Take a look at the article on the Jess wiki
> http://www.jessrules.com/jesswiki/view?SalienceUsageTips and in the
> documentation
> http://www.jessrules.com/jess/docs/71/rules.html#salienceregarding
> salience.
>
> Less important items...
>
> 1.  You've got some typos in your questions that make answering them
> awkward.  For example:
>     "Do you want to work full time after homes?" makes no sense.
>     "How many homes a week do you want to work?" -- clearly you meant
> "hours
> a week".
>     Go through all your questions and edit them.
>
> 2.  Good programmers error-trap their code for bad inputs.  Any place that
> you are expecting numerical input (asking about ages, dollars, etc.) run
> the
> input
> through the (numberp) function.  (numberp) stands for number-parse, and
> gives back a boolean TRUE if its argument parses to any number.
>
> 3.  Omit defining (defglobal ?*crlf* = ...) since it's part of Jess now
> anyway.  Just use the symbol "crlf" anywhere you want a
> carriage-return-linefeed.
>
> It is important that you make these changes and that I just not give you
> my
> corrected solution -- I hope nobody actually does this!
> Once I fixed these issues, your program seemed to run just fine.
>
> I hope this helps!
>
> Cheers,
> Jason
>
> -----------------------------------------------------------
> Jason Morris
> Morris Technical Solutions LLC
> consulting@...
> (517) 304-5883
>
>

--
View this message in context: http://www.nabble.com/Skipping-a-Rule---Help-needed-tp17166875p17170299.html
Sent from the Jess mailing list archive at Nabble.com.



--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------




--
-----------------------------------------------------------
Jason Morris
Morris Technical Solutions LLC
consulting@...
(517) 304-5883

Re: JESS: Skipping a Rule - Help needed

by Jason Morris :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Katie (Geraldine!?)

Certain people on the Jess list have contacted me and said that I was being too harsh on you. 
If you feel that I have been, please accept my apology. 
My concern is that you get the help that you need, and because you are a student, that you do the corrections yourself without me just giving them to you.

Cheers,
Jason


On Sun, May 11, 2008 at 5:43 AM, katie678 <conway.geraldine@...> wrote:

This type of help is greatly appreciated and the response was so quick.

I will follow all your instructions and see how I get on.

Thanks so much

Katie


Jason Morris wrote:
>
> On Sat, May 10, 2008 at 3:45 PM, katie678 <conway.geraldine@...>
> wrote:
>
>>
>> Hi,
>>
>> I am complety new to Jess and am in desperate need of help please.
>
>
> Hi Katie,
>
> Here is a list of issues that caught my eye:
>
> 1.  If you have a function B that depends on function A, then function A
> *must* be defined in your Jess script *before* function B, else B will not
> "know about" A.
>     Look at your code carefully to spot this one.
> 2.  All LHS patterns are implicitly joined with an (and).  There is no
> need
> to use (and <pattern 1> <pattern 2> ... <pattern n> ) in your rules.  Fix
> all the rules that do this.
> 3.  Don't use the (or) connective to simply match facts having alternative
> slot values.  If you want to match on (foo) facts with a slot called
> "value"
> such that value = 5, 10, or 15 you would write:
>
>      (defrule find-foos
>          (foo (value ?v&5|10|25))
>      =>
>      ;; do something interesting here
>     )
> Fix all the rules where you have done this.
>
> 4.  If you want a fact matched over a range of slot values, then you use
> predicate constraints like so:
>
>     Match all (foo) fact with value between 1 and 3:
>     (defrule find-foos-from-1-to-3
>         (foo (value ?v&:(>= ?v 1)&:(< ?v 4)))
>     =>
>     ;; Do something interesting here
>     )
> Make these corrections, too.
>
> 5.  When you have two or more rules for which there will never be more
> than
> one fact that activates more than one rule at a time, there is no need to
> enforce
> activation order using salience -- I think this is where your code
> diverges
> from the Tax Adviser example in "Jess in Action".  The tax adviser will
> actually recommend multiple
> forms whereas you just recommend one course of action.  When you do use
> salience, as in all programming, avoid using unbound "magic numbers" like
> 100000 and 70000.
> These are arbitrary and just bad karma -- the danger is where do you stop
> once you start?  100001, 100002, 70001, etc?
> Take a look at the article on the Jess wiki
> http://www.jessrules.com/jesswiki/view?SalienceUsageTips and in the
> documentation
> http://www.jessrules.com/jess/docs/71/rules.html#salienceregarding
> salience.
>
> Less important items...
>
> 1.  You've got some typos in your questions that make answering them
> awkward.  For example:
>     "Do you want to work full time after homes?" makes no sense.
>     "How many homes a week do you want to work?" -- clearly you meant
> "hours
> a week".
>     Go through all your questions and edit them.
>
> 2.  Good programmers error-trap their code for bad inputs.  Any place that
> you are expecting numerical input (asking about ages, dollars, etc.) run
> the
> input
> through the (numberp) function.  (numberp) stands for number-parse, and
> gives back a boolean TRUE if its argument parses to any number.
>
> 3.  Omit defining (defglobal ?*crlf* = ...) since it's part of Jess now
> anyway.  Just use the symbol "crlf" anywhere you want a
> carriage-return-linefeed.
>
> It is important that you make these changes and that I just not give you
> my
> corrected solution -- I hope nobody actually does this!
> Once I fixed these issues, your program seemed to run just fine.
>
> I hope this helps!
>
> Cheers,
> Jason
>
> -----------------------------------------------------------
> Jason Morris
> Morris Technical Solutions LLC
> consulting@...
> (517) 304-5883
>
>

--
View this message in context: http://www.nabble.com/Skipping-a-Rule---Help-needed-tp17166875p17170299.html
Sent from the Jess mailing list archive at Nabble.com.



--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------




--
-----------------------------------------------------------
Jason Morris
Morris Technical Solutions LLC
consulting@...
(517) 304-5883

Re: JESS: Skipping a Rule - Help needed

by Doug Metzler-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Very minor point but:

On Sat, 10 May 2008, Jason Morris wrote:

> run the input
> through the (numberp) function.  (numberp) stands for number-parse, and
> gives back a boolean TRUE if its argument parses to any number.

Doesn't Jess follow the original LISP meaning of the "p" suffix
usage in built in as well as user defined functions as "predicate"
rather than "parse", and isn't that a better usage in any case
since it reflects the purpose of any predicate (as you indicate in
the example above) rather than the way it is implemented which
can vary quite a bit (table lookup for predicates with a finite
domain, pointer traversal, graph traversal, numeric or symbolic
computation of any sort).

Doug (more familiar with LISP, OPS and Clips, than with Jess)


--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------


Re: JESS: Skipping a Rule - Help needed

by Jason Morris :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>> Doesn't Jess follow the original LISP meaning of the "p" suffix .. and isn't that a better usage in any case

Hi Doug,
Well, it's clear that Ernest has followed that syntax.  Whether or not one enforces its historical meaning I suppose depends on how pedantic (LISPy) one wants to be. 
At some point, sure, I could say "by the way, the 'p' really means predicate as in predicate calculus.

My original point was not to harangue the poor girl, but to give her a practical answer.
Sometimes it's best to give a simplified definition first without the history lesson.  ;-)

Cheers,
Jason

-----------------------------------------------------------
Jason Morris
Morris Technical Solutions LLC
consulting@...
(517) 304-5883

Re: JESS: Skipping a Rule - Help needed

by katie678 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I think you have been really helpful and not harsh at all.
If it was as easy as getting you to do it for me, well then why would we all go to college!!

Thanks

Jason Morris wrote:
You are very welcome.
Best of luck and keep trying!  ;-)
- Jason

On Sun, May 11, 2008 at 5:43 AM, katie678 <conway.geraldine@gmail.com>
wrote:

>
> This type of help is greatly appreciated and the response was so quick.
>
> I will follow all your instructions and see how I get on.
>
> Thanks so much
>
> Katie
>
>
> Jason Morris wrote:
> >
> > On Sat, May 10, 2008 at 3:45 PM, katie678 <conway.geraldine@gmail.com>
> > wrote:
> >
> >>
> >> Hi,
> >>
> >> I am complety new to Jess and am in desperate need of help please.
> >
> >
> > Hi Katie,
> >
> > Here is a list of issues that caught my eye:
> >
> > 1.  If you have a function B that depends on function A, then function A
> > *must* be defined in your Jess script *before* function B, else B will
> not
> > "know about" A.
> >     Look at your code carefully to spot this one.
> > 2.  All LHS patterns are implicitly joined with an (and).  There is no
> > need
> > to use (and <pattern 1> <pattern 2> ... <pattern n> ) in your rules.  Fix
> > all the rules that do this.
> > 3.  Don't use the (or) connective to simply match facts having
> alternative
> > slot values.  If you want to match on (foo) facts with a slot called
> > "value"
> > such that value = 5, 10, or 15 you would write:
> >
> >      (defrule find-foos
> >          (foo (value ?v&5|10|25))
> >      =>
> >      ;; do something interesting here
> >     )
> > Fix all the rules where you have done this.
> >
> > 4.  If you want a fact matched over a range of slot values, then you use
> > predicate constraints like so:
> >
> >     Match all (foo) fact with value between 1 and 3:
> >     (defrule find-foos-from-1-to-3
> >         (foo (value ?v&:(>= ?v 1)&:(< ?v 4)))
> >     =>
> >     ;; Do something interesting here
> >     )
> > Make these corrections, too.
> >
> > 5.  When you have two or more rules for which there will never be more
> > than
> > one fact that activates more than one rule at a time, there is no need to
> > enforce
> > activation order using salience -- I think this is where your code
> > diverges
> > from the Tax Adviser example in "Jess in Action".  The tax adviser will
> > actually recommend multiple
> > forms whereas you just recommend one course of action.  When you do use
> > salience, as in all programming, avoid using unbound "magic numbers" like
> > 100000 and 70000.
> > These are arbitrary and just bad karma -- the danger is where do you stop
> > once you start?  100001, 100002, 70001, etc?
> > Take a look at the article on the Jess wiki
> > http://www.jessrules.com/jesswiki/view?SalienceUsageTips and in the
> > documentation
> > http://www.jessrules.com/jess/docs/71/rules.html#salienceregarding
> > salience.
> >
> > Less important items...
> >
> > 1.  You've got some typos in your questions that make answering them
> > awkward.  For example:
> >     "Do you want to work full time after homes?" makes no sense.
> >     "How many homes a week do you want to work?" -- clearly you meant
> > "hours
> > a week".
> >     Go through all your questions and edit them.
> >
> > 2.  Good programmers error-trap their code for bad inputs.  Any place
> that
> > you are expecting numerical input (asking about ages, dollars, etc.) run
> > the
> > input
> > through the (numberp) function.  (numberp) stands for number-parse, and
> > gives back a boolean TRUE if its argument parses to any number.
> >
> > 3.  Omit defining (defglobal ?*crlf* = ...) since it's part of Jess now
> > anyway.  Just use the symbol "crlf" anywhere you want a
> > carriage-return-linefeed.
> >
> > It is important that you make these changes and that I just not give you
> > my
> > corrected solution -- I hope nobody actually does this!
> > Once I fixed these issues, your program seemed to run just fine.
> >
> > I hope this helps!
> >
> > Cheers,
> > Jason
> >
> > -----------------------------------------------------------
> > Jason Morris
> > Morris Technical Solutions LLC
> > consulting@morris-technical-solutions.com
> > (517) 304-5883
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Skipping-a-Rule---Help-needed-tp17166875p17170299.html
> Sent from the Jess mailing list archive at Nabble.com.
>
>
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users you@address.com'
> in the BODY of a message to majordomo@sandia.gov, NOT to the list
> (use your own address!) List problems? Notify owner-jess-users@sandia.gov.
> --------------------------------------------------------------------
>
>


--
-----------------------------------------------------------
Jason Morris
Morris Technical Solutions LLC
consulting@morris-technical-solutions.com
(517) 304-5883
LightInTheBox - Buy quality products at wholesale price