Hello,

thank you for your help. Actually, I used the test statement quite often.
Mostly because it was easier to understand the rules when you write some
conditions seperately.
But it didn't help me solve my problem.

In my system, the most rules look like this:

RULE1:
(defrule UPDATE::wheat-close
     "wheat is close"
     ?worker <- (MAIN::worker (position ?workerPos) (rangeOfVision ?range))
     ?wheat <- (MAIN::wheat (position ?wheatPos&: (<= (distance ?workerPos
?wheatPos) ?range)))
     =>
     (bind ?distance (distance ?workerPos ?wheatPos))
     (assert (WORKER::wheat-close ?worker ?wheat ?wheatPos ?distance))
)

and
RULE2:
(defrule HARVESTING::harvest-closest-wheat
     "harvest the closest wheat"
     ?worker <- (MAIN::worker (position ?workerPos) (OBJECT ?workerObj))
     ?wheat <- (MAIN::wheat (position ?wheatPos&:(neq ?workerPos ?wheatPos))
(OBJECT ?wheatObj))
     (WORKER::wheat-close ?worker ?wheat ?wheatPos ?distance)
     (not (exists (WORKER::wheat-close ?worker ?wheat2&~?wheat ?wheatPos2
?distance2&:(< ?distance2 ?distance))))
 =>
     (bind ?destination (new ae.jess.Destination ?workerObj ?wheatObj))
     (bind ?dest (definstance PLAN::destination ?destination false))
     (assert (PLAN::new-destination ?dest))
)

In this system, worker, wheat and distance are shadow facts, the slot
position also represents a Java object.
There is only one worker fact in the system, representing the owner of the
rete engine and a lot of wheat shadow facts representing the potential food
sources.
On every update, new wheat-close facts are generated by RULE1 and used by
RULE2 to create a new destination object for the agent.

Is there anything wrong with this kind of rules or do you have any other
suggestions on speeding up my system (and lowering the memory comsumption).

Eliminating the test CE statements helped, but it was not enough to let the
system run for hours.

Thanks,
Tobias
University of Karlsruhe

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, April 04, 2005 1:56 PM
Subject: Re: JESS: Memory Problems with Jess


> I think Tobias Hilka wrote:
> [Charset iso-8859-1 unsupported, filtering to ASCII...]
> > Hello,
>
> > All in all, there are about 60 to 100 facts in each rete engine. If
> > I insert like 40 of these agents in my world, everything is working
> > fine. But just in the beginning. If I let it run 300 and more turns,
> > it gets terribly slow, sometimes even runs out of memory.
>
> When a Jess program is using too much memory, the problem is generally
> that you're forming a large number of partial matches in your rules:
> see http://herzberg.ca.sandia.gov/jess/FAQ.shtml#Q12 for an
> explanation. You need to look at the rules you've written and try to
> eliminate any code that generates polynomial numbers of matches.
>
> There's a newbie mistake that often causes problems like this: overuse
> of the "test" conditional element. "test" is needed only in rare
> circumstances. Don't write
>
> (defrule bad-example
>   (number ?n1)
>   (number ?n2)
>   (test (eq (+ ?n1 1) ?n2))
>   ...
>
> Instead write
>
> (defrule good-example
>   (number ?n1)
>   (number ?n2&:(+ ?n1 1))
>   ...
>
> The former forms N^2 partial matches, the latter only N (where N is
> the number of "number" facts).
>
> ---------------------------------------------------------
> 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://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]
> --------------------------------------------------------------------
>
>

--------------------------------------------------------------------
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