Both Eric Jain and I think that the problem is that there are multiple
instance of vs.storyworldontology.Forest that don't compare equal
using equals(). I can't think of any other explanation.

You might try 1) adding a print statement to the constructor(s) of
this class, to see how many instances are actually created, and 2)
try, from Java, something like

Forest f1 = new Forest();
Forest f2 = new Forest();
System.out.println(f1.equals(f2));

Hmm. There's another possibility, actually: you've implemented
equals(), but not hashCode(). See the Javadoc for hashCode(), or
Joshua Bloch's "Effective Java", for discussions on why when you
override one of these, you need to do the other one, too, and how to
do it properly. If equals() returns true above, but

System.out.println(f1.hashCode() == f2.hashCode());

prints "false", then that's the problem. If two objects are equals()
they *must* have the same hashCode().



I think Sander Rensen wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hello again,
> 
> I have the following rule in my system:
> -----------------------------
> (defrule rule-test
>  (located  (location ?l2)(thing ?t))
>  (adjacent (locale1 ?l2) (locale2 ?l3))
>  =>
>  (printout t "test geslaagd" crlf)
> )
> -----------------------------
> 
> and the following facts:
> 
> ---------------------------
> f-0 (MAIN::initial-fact)
>  f-2 (MAIN::forest (class <External-Address:java.lang.Class>) (OBJECT
> <External-Address:vs.storyworldontology.Forest>) (name "in the forest")
> (name_type <External-Address:java.lang.Class>))
> f-3 (MAIN::desert (class <External-Address:java.lang.Class>) (OBJECT
> <External-Address:vs.storyworldontology.Desert>) (name "in the desert")
> (name_type <External-Address:java.lang.Class>))
> f-4 (MAIN::adjacent (class <External-Address:java.lang.Class>) (locale1
> <External-Address:vs.storyworldontology.Forest>) (locale1_type
> <External-Address:java.lang.Class>) (locale2
> <External-Address:vs.storyworldontology.Desert>) (locale2_type
> <External-Address:java.lang.Class>) (OBJECT
> <External-Address:vs.storyworldontology.Adjacent>))
> f-5 (MAIN::located (class <External-Address:java.lang.Class>) (location
> <External-Address:vs.storyworldontology.Forest>) (location_type
> <External-Address:java.lang.Class>) (thing
> <External-Address:vs.storyworldontology.Hero>) (thing_type
> <External-Address:java.lang.Class>) (OBJECT
> <External-Address:vs.storyworldontology.Located>))
> -------------------------
> 
> when i run the jess engine, the rule isn`t executed, (there is nothing
> printed) but a fact is added:
> 
> ------------------------
>  f-6 (MAIN::need-adjacent (class nil) (locale1
> <External-Address:vs.storyworldontology.Forest>) (locale1_type nil) (locale2
> nil) (locale2_type nil) (OBJECT nil))
> -----------------------
> 
> In my opinion the rule should be executed, based on fact 5 and fact 4. There
> should be printed "test geslaagd"
> 
> What is wrong?  I see that the needed fact contains some nils where there
> should be references ? I don`t understand why.
> I`ve already tried to make an "equals"  function in the desert and the
> forest class, but that isn`t called.
> 
> I think the objects shown in fact 5 and fact 4 are not totally the same
> (although it is the same object when i assert it fromout java)
> How can i see this....(watch and show functions don`t show any difference)
> 
> Anybody an idea.... it makes me crazy !!
> 
> Thanks a lot in advance .....
> 
> Sander
> 
> 
> 
> 
> 
> ----- Original Message ----- 
> From: "Eric Jain" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, November 03, 2003 7:32 PM
> Subject: JESS: Re: Re: Re: Problem with matching objects
> 
> 
> > > No, i didn`t ??
> >
> > I assume Jess uses the objects "equals" method to check whether Java
> > objects are identical or not. The default implementation of this method
> > returns true only if the objects are physically identical, i.e. point to
> > the same location in memory.
> >
> > --
> > Eric Jain
> >
> > --------------------------------------------------------------------
> > 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]
> --------------------------------------------------------------------
> 



---------------------------------------------------------
Ernest Friedman-Hill  
Science and Engineering PSEs        Phone: (925) 294-2154
Sandia National Labs                FAX:   (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]
--------------------------------------------------------------------

Reply via email to