You're right, Jess is not handling this correctly. In this specific
case, you can work around the problem for now like this:
(defrule findClosestPersonToHome
(home (latitude ?homeLat) (longitude ?homeLon))
(person (latitude ?lat) (longitude ?lon))
(not (person (latitude ?otherLat)
(longitude ?otherLon&:(<
(distance ?homeLat ?homeLon ?otherLat ?otherLon)
(distance ?homeLat ?homeLon ?lat ?lon)))))
...
but I'll work on the actual problem. Thanks for the report.
I think Drew Van Duren wrote:
> Hello,
>
> I'm having a bit of an issue regarding pattern matching inside 'and'
> operators nested within 'not' operators. Here's an example: The rule
> should assert a fact containing the latitude of the person who is
> closest to home (and no other)......
>
> (defrule findClosestPersonToHome
> (home (latitude ?homeLat) (longitude ?homeLon))
> (person (latitude ?lat) (longitude ?lon))
> (not
> (and
> (person (latitude ?otherLat) (longitude ?otherLon))
>
> (test (< (distance ?homeLat ?homeLon ?otherLat ?otherLon)
>
> (distance ?homeLat ?homeLon ?lat ?lon)
> )
> )
> )
> )
> =>
> (assert (closestLat ?lat ))
> )
>
> I know Jess will not allow variable definition (to be later patter
> matched) within a 'not', but I was hoping there was some way to at least
> pattern match across different patterns all contained in the 'not.' Any
> advice on how to handle the problem above would be greatly appreciated.
>
> Drew
>
> ps The preceding resulted in the following error message.......
>
> ********************
> Jess reported an error in routine ReteCompiler.eval
> while executing (batch test.kb).
> Message: Unbound variable found in funcall: otherLat parsing defrule
> MAIN::findClosestPersonToHome .
> Program text: ( batch test.kb ) at line 1.
> at jess.ReteCompiler.compilerError(ReteCompiler.java:698)
> at jess.ReteCompiler.eval(ReteCompiler.java:75)
> at jess.ReteCompiler.eval(ReteCompiler.java:83)
> at jess.ReteCompiler.addRule(ReteCompiler.java:510)
> at jess.Rete.addDefrule(Rete.java:686)
> at jess.Jesp.addARule(Jesp.java:1017)
> at jess.Jesp.doParseDefrule(Jesp.java:971)
> at jess.Jesp.parseDefrule(Jesp.java:894)
> at jess.Jesp.parseSexp(Jesp.java:159)
> at jess.Jesp.parse(Jesp.java:62)
> at jess.Batch.batch(Batch.java:43)
> at jess.Batch.call(Batch.java:57)
> at jess.FunctionHolder.call(FunctionHolder.java:37)
> at jess.Funcall.execute(Funcall.java:270)
> at jess.Jesp.parseAndExecuteFuncall(Jesp.java:1583)
> at jess.Jesp.parseSexp(Jesp.java:183)
> at jess.Jesp.parse(Jesp.java:62)
> at jess.Main.execute(Main.java:123)
> at jess.Main.main(Main.java:23)
> ************************
>
>
>
>
>
>
> ---------------------------------------------------------------------
> 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
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
Org. 8920, MS 9012 [EMAIL PROTECTED]
PO Box 969 http://herzberg.ca.sandia.gov
Livermore, CA 94550
---------------------------------------------------------------------
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]
---------------------------------------------------------------------