I was not able to reproduce the problem in a simple example, however, something
appears to be happening that I don't understand. The Java and rule files used
in the trial below are attached. (Note the java files should be Thing1.java and
Thing2.java, cc-mail does not like long file names).
The problem is that the modification to the (definstance... created facts does
not seem to be permanent. The ShowMe rule clearly show that the source and
record field have been set in Java, but the last (facts) output show that those
slots are nil in Jess. This is a similar problem, perhaps they are related.
Jess, the Java Expert System Shell
Copyright (C) 1998 E.J. Friedman Hill and the Sandia Corporation
Jess Version 4.1b3 7/1/98
Jess> (batch "rules.clp")
TRUE
Jess> (reset)
TRUE
Jess> (facts)
f-0 (initial-fact)
f-1 (Thing2 (source nil) (class <External-Address:java.lang.Class>) (OBJECT
<External-Address:Thing2>))
f-2 (Thing1 (source nil) (class <External-Address:java.lang.Class>) (record
nil) (OBJECT <External-Address:Thing1>))
For a total of 3 facts.
TRUE
Jess> (run)
(Query (Source Thing1) (Record (Query (Source Thing2) )) )
(Query (Source Thing2) )TRUE
Jess> (facts)
f-0 (initial-fact)
f-4 (Thing2 (source nil) (class <External-Address:java.lang.Class>) (OBJECT
<External-Address:Thing2>))
f-5 (Thing1 (source nil) (class <External-Address:java.lang.Class>) (record
nil) (OBJECT <External-Address:Thing1>))
For a total of 3 facts.
TRUE
Jess>
Opinions are strictly those of the author and
do not necessarily reflect those of GRCI.
______________________________________________
Lewis Hart GRC International
703-506-5938 1900 Gallows Rd
[EMAIL PROTECTED] Vienna, VA 22182
______________________________ Reply Separator _________________________________
Subject: Re: JESS: Java objects and Jess facts.
Author: Ernest Friedman-Hill <[EMAIL PROTECTED]> at GRC_INET
Date: 7/6/98 10:47 AM
I think [EMAIL PROTECTED] wrote:
>
> ... When an instance of a fact, created using definstance, is modified,
> the old fact is retracted, _but_ the modified fact is never asserted.
> In the excerpt below, when the modify is executed the DM_Query fact
> is lost.
>
Hi Lewis,
As the following excerpt shows, a trivial test case works for me:
----------------------------------------------------------------------
Jess, the Java Expert System Shell
Copyright (C) 1998 E.J. Friedman Hill and the Sandia Corporation
Jess Version 4.1b3 7/1/98
Jess> (defclass simple jess.examples.simple.Simple)
jess.examples.simple.Simple
Jess> (definstance simple (new jess.examples.simple.Simple "Foo"))
TRUE
Jess> (defrule test-rule
?f <- (simple)
=>
(modify ?f (truth TRUE)))
TRUE
Jess> (reset)
TRUE
Jess> (facts)
f-0 (initial-fact)
f-1 (simple (truth FALSE) (class <External-Address:java.lang.Class>)
(name "Foo") (fraction 0.0) (serial 0)
(OBJECT <External-Address:jess.examples.simple.Simple>))
For a total of 2 facts.
TRUE
Jess> (run)
TRUE
Jess> (facts)
f-0 (initial-fact)
f-2 (simple (truth TRUE) (class <External-Address:java.lang.Class>)
(name "Foo") (fraction 0.0) (serial 0)
(OBJECT <External-Address:jess.examples.simple.Simple>))
For a total of 2 facts.
TRUE
Jess>
----------------------------------------------------------------------
> The same thing happens regardless of how the fact is modified, as
> above using (set ?qfr record ?srr), or calling setRecord() in Java.
4.1b3 fixed a bug whereby modifying a definstance fact using a bogus
property name could cause the fact to be retracted without the new
version being asserted... are you using 4.1b3? If you are not,
download it and give it a try. In any case, make sure that there
really is a public method named getRecord() with no arguments that
returns non-void in the class you're matching, and make sure Jess
knows about it (run the 'facts' command and look at all the slots in
the definstance facts.) Let me know what you find out.
>
> The RHS of some rules call user functions which use
>
> aReteEngine.executeCommand(theCommand);
>
> to assert new facts. Could this be causing problems in the rete code
> or data structures?
>
This should be OK; it's equivalent to calling (assert) on the RHS of a
rule, which is perfectly legal. Now if you're doing it on the -LHS- of
a rule, or if you're calling functions that modify a matched object on
the LHS of a rule, well, I think the README warns about that...
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (510) 294-2154
Sandia National Labs FAX: (510) 294-2234
Org. 8920, MS 9214 [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. List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------
begin 666 thing2.jav
M+RHC(V)E9VEN($-L87-S(%1H:6YG,B`J+PHO+W!A8VMA9V4@:F5S<U]T97-T
M.PH@"FEM<&]R="!J879A+F)E86YS+BH[("`O+R!.965D960@9F]R(%!R;W!E
M<G1Y($-H86YG92!3=7!P;W)T"B`*+R\@1$1?3V)J96-T(%8Q+C`@5'5E($IU
M;B`P,B`Q-3HT.#HU-"`Q.3DX"G!U8FQI8R!C;&%S<R!4:&EN9S(@>PH@"B\O
M(%-O=7)C92!6,2XP(%1U92!*=6X@,#(@,34Z-#,Z-3$@,3DY.`HO+R!I<R!D
M871A('1Y<&4@:VEN9"!#2$%204-415(*("`@<')I=F%T92`@4W1R:6YG(%-O
M=7)C93L*("`@<'5B;&EC("!3=')I;F<@9V5T4V]U<F-E*"D@>W)E='5R;B!3
M;W5R8V4[('T*("`@<'5B;&EC("!V;VED('-E=%-O=7)C92@@4W1R:6YG(&YE
M=U-O=7)C92D@>PH@("`@("`@<&-S+F9I<F50<F]P97)T>4-H86YG92@B<V]U
M<F-E(BQ3;W5R8V4L(&YE=U-O=7)C92D["B`@("`@("!3;W5R8V4@/2!N97=3
M;W5R8V4["B`@("`@("!]"B`*+R\@4')O=FED97,@82!B96%N<R!C:&%N9V4@
M;'-I=&5N97(@9F]R('5S92!B>2!*97-S+@H@("!P<FEV871E(%!R;W!E<G1Y
M0VAA;F=E4W5P<&]R="!P8W,@/2!N97<@4')O<&5R='E#:&%N9V53=7!P;W)T
M*'1H:7,I.PH@("!P=6)L:6,@=F]I9"!A9&10<F]P97)T>4-H86YG94QI<W1E
M;F5R*%!R;W!E<G1Y0VAA;F=E3&ES=&5N97(@<&-L*7L*("`@("!P8W,N861D
M4')O<&5R='E#:&%N9V5,:7-T96YE<BAP8VPI.PH@("`@('T*("`@<'5B;&EC
M('9O:60@<F5M;W9E4')O<&5R='E#:&%N9V5,:7-T96YE<BA0<F]P97)T>4-H
M86YG94QI<W1E;F5R('!C;"E["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*2`H<F5C;W)D(&YI;"DI"B`@/3X*("`H;6]D:69Y(#]F=#$@
M*')E8V]R9"`_;W0R*2D*("`I"@HH9&5F<G5L92!3:&]W364*("`H9&5C;&%R
M92`H<V%L:65N8V4@+34I*0H@("A4:&EN9S$@*$]"2D5#5"`_;W0Q*2D*("`H
M5&AI;F<R("A/0DI%0U0@/V]T,BDI"B`@/3X*("`H8FEN9"`_<W0Q("AC86QL
M(#]O=#$@=&]3=')I;F<I*0H@("AB:6YD(#]S=#(@*&-A;&P@/V]T,B!T;U-T
J<FEN9RDI"B`@*'!R:6YT;W5T('0@/W-T,2!C<FQF(#]S=#(I"B`@*2`*
`
end
---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list. List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------