OK, I believe I traced it down to an extra "reset" prior to run. My
original tests had a number of different clp files being batched and I'm
guessing there was a spurious reset in there somewhere. The negative case
seems to work now that I've reduced the test to just these scripts; but if
I actually have the B/D assertions in there, the extra reset incorrectly
causes the not-present rule to fire. So what exactly is the reset doing
that causes the LHS to evaluate to true in those cases??
=============
works
=============
(watch all)
(reset)
(assert (value "Aa"))
(assert (value "Bb"))
(assert (value "Cc"))
(assert (value "Dd"))
(defrule only-when-starts-with-B-and-D-NOT-present
(not (value /B.*/))
(not (value /D.*/))
=>
(printout t crlf "B* and D* NOT present" crlf)
)
;;(reset)
(run)
==> Focus MAIN
==> f-0 (MAIN::initial-fact)
==> f-1 (MAIN::value "Aa")
==> f-2 (MAIN::value "Bb")
==> f-3 (MAIN::value "Cc")
==> f-4 (MAIN::value "Dd")
==> Activation: MAIN::only-when-starts-with-B-and-D-NOT-present : f-0,,
<== Activation: MAIN::only-when-starts-with-B-and-D-NOT-present : f-0,,
MAIN::only-when-starts-with-B-and-D-NOT-present: +1+1+1+1+1+2+1+2+t
<== Focus MAIN
elapsed time = 235 millis
===================
doesn't work
===================
(watch all)
(reset)
(assert (value "Aa"))
(assert (value "Bb"))
(assert (value "Cc"))
(assert (value "Dd"))
(defrule only-when-starts-with-B-and-D-NOT-present
(not (value /B.*/))
(not (value /D.*/))
=>
(printout t crlf "B* and D* NOT present" crlf)
)
(reset)
(run)
==> Focus MAIN
==> f-0 (MAIN::initial-fact)
==> f-1 (MAIN::value "Aa")
==> f-2 (MAIN::value "Bb")
==> f-3 (MAIN::value "Cc")
==> f-4 (MAIN::value "Dd")
==> Activation: MAIN::only-when-starts-with-B-and-D-NOT-present : f-0,,
<== Activation: MAIN::only-when-starts-with-B-and-D-NOT-present : f-0,,
MAIN::only-when-starts-with-B-and-D-NOT-present: +1+1+1+1+1+2+1+2+t
==> Focus MAIN
==> f-0 (MAIN::initial-fact)
==> Activation: MAIN::only-when-starts-with-B-and-D-NOT-present : f-0,,
FIRE 1 MAIN::only-when-starts-with-B-and-D-NOT-present f-0,,
B* and D* NOT present
<== Focus MAIN
elapsed time = 234 millis
-- Mike
____________________
Michael Stopper
Systems Development Scientist
SPS Enterprise Architect
CACI Transformation Solutions Group
Tel 703.460.1845
Mobile 703.407.7058
[EMAIL PROTECTED] | www.caci.com
"Ernest Friedman-Hill" <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]
05/07/2007 11:16 PM
Please respond to
[email protected]
To
[email protected]
cc
Subject
Re: JESS: Fire a rule when multiple conditions NOT true
Well, what we have here, I suspect, is a failure to communicate. Here is
an actual transcript of a Jess command prompt session. Do you see
something different? If so, show us *exactly* what you typed, starting
with launching Jess.
[EMAIL PROTECTED] ~]$ java jess.Main
Jess, the Rule Engine for the Java Platform
Copyright (C) 2006 Sandia Corporation
Jess Version 7.0p1 12/21/2006
Jess> (reset)
TRUE
Jess> (assert (value "Aa"))
<Fact-1>
Jess>
Jess> (assert (value "Cc"))
Jess>
Jess> <Fact-2>
Jess> (defrule only-when-starts-with-B-and-D-NOT-present
(not (value /B.*/))
(not (value /D.*/))
=>
(printout t "B* and D* NOT present" crlf)
)
TRUE
Jess> (run)
B* and D* NOT present
1
Jess> (reset)
TRUE
Jess> (assert (value "Aa"))
<Fact-1>
Jess> (assert (value "Bb"))
<Fact-2>
Jess> (assert (value "Cc"))
<Fact-3>
Jess> (run)
0
Jess> (retract 2)
TRUE
Jess> (run)
B* and D* NOT present
1
Jess>
On 5/7/07, Mike Stopper <[EMAIL PROTECTED]> wrote:
Hmm. That doesn't seem to do it:
f-10 (MAIN::value "aa")
f-11 (MAIN::value "Bb")
f-12 (MAIN::value "cc")
f-13 (MAIN::value "Dd")
f-14 (MAIN::value "ee")
still yields
B* and D* NOT present
as does
f-10 (MAIN::value "aa")
f-11 (MAIN::value "cc")
f-12 (MAIN::value "ee")
which actually prints it out twice!!
B* and D* NOT present
B* and D* NOT present
This is version 7.0p1 if that makes any difference.
-- Mike
____________________
Michael Stopper
Systems Development Scientist
SPS Enterprise Architect
CACI Transformation Solutions Group
Tel 703.460.1845
Mobile 703.407.7058
[EMAIL PROTECTED] | www.caci.com
"Ernest Friedman-Hill" <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]
05/07/2007 05:03 PM
Please respond to
[email protected]
To
[email protected]
cc
Subject
Re: JESS: Fire a rule when multiple conditions NOT true
This should do just what you want:
(defrule only-when-starts-with-B-and-D-NOT-present
(not (value /B.*/))
(not (value /D.*/))
=>
(printout t "B* and D* NOT present" crlf)
)
This rule has two conditions: that there are no B* facts, and that there
are
no D* facts. Both must be met for the rule to fire.
On Monday 07 May 2007 4:04:59 pm Mike Stopper wrote:
> I'm having trouble getting my head set straight on this one..
>
> I'd like to be able to have a rule fire if two or more facts are NOT
true
> using regular expressions, but can't seem to figure out the right rule
> def.
>
> Given the following setup:
>
> (assert (value "aa"))
> (assert (value "Bb"))
> (assert (value "cc"))
> (assert (value "Dd"))
> (assert (value "ee"))
>
> (defrule only-when-starts-with-B-and-D-present
> (value /B.*/)
> (value /D.*/)
> =>
> (printout t "B* and D* present" crlf)
> )
>
> yields
>
> B* and D* present
>
>
> but I can't seem to figure out how to get this one to work such that the
> RHS is fired only when no fact starts with either /B.*/ or /D.*/ regular
> expressions...
>
> (assert (value "aa"))
> ;;(assert (value "Bb"))
> (assert (value "cc"))
> ;;(assert (value "Dd"))
> (assert (value "ee"))
>
> (defrule only-when-starts-with-B-and-D-NOT-present
>
> (value /(?!B).*/)
> (value /(?!D).*/)
> =>
> (printout t "B* and D* NOT present" crlf)
> )
>
> fires whether or not B and D are present or not.
>
> I've tried various incarnations of the tests, using a Jess "not"
> condition, various flavors of regex expressions, all to no avail. Can
> anyone tell me what I'm doing wrong?? Is it a misuse of facts/rules, or
a
> misunderstanding of just what the LHS can do?
>
> Thanks.
>
>
> -- Mike
> ____________________
>
> Michael Stopper
> Systems Development Scientist
> SPS Enterprise Architect
> CACI Transformation Solutions Group
>
> Tel 703.460.1845
> Mobile 703.407.7058
> [EMAIL PROTECTED] | www.caci.com
--
---------------------------------------------------------
Ernest Friedman-Hill
Advanced Software Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://www.jessrules.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]
--------------------------------------------------------------------