Hi Ernest,

I did ask this question earlier, but i was wondering if there is any way of
achieving this. I am aware of the performance issues involved in letting
jess do what i am asking for. I am thinking of creating different defclasses
based on different interfaces, but am not sure of the possible side effects
of that way.

This is one way i am thinking of solving the problem.

interface A1Intf {
        public int getId();
        public void incrCount();
        public void decrCount();
}

interface A2Intf {
        public int getCount();
        public int getTotalCount();
}

class A implements A1Intf, A2Intf {
        ...........
}

(defclass A1 A1Intf)
(defclass A2 A2Intf)

defrule R1 (
        (A1 (id ?id) (OBJECT ?obj))
        =>
        (call ?obj incrCount)
)
 
defrule R2 (
        (A2 (count ?count) (totalCount ?total_count))
        (test (> (/ (* ?count 100) ?total_count) 50))
        => 
        (printout t "count is more than 50 percent of the total count" crlf)
)

-Satish.


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 24, 2001 11:02 AM
To: Satish boggavarapu
Cc: '[EMAIL PROTECTED]'
Subject: Re: JESS: Rule activation



Satish,

This is really the same question you've asked several times
before. Jess's behaviour in this respect is just different than you'd
like it to be; that's unfortunate but simply a fact of life. There is
no simple "fix" -- you're asking for a fundamentally different way of
organizing information. There is no "count variable fact;" there is
only an A-bean fact. It can't be independently modified because it is
not independently represented in Jess.

Now, as I've said before, I don't disagree that what you'd like Jess
to do might be better from a user perspective. However, there are
always tradeoffs. For example, doing what you suggest would require
more memory in the form of more small objects -- somethat that almost
always hurts the performance of a Java application.

Another example is that in Jess, facts and beans are treated in the
same way, which means that you can write rules regardless of what the
type of an individual fact is. You can have inheritance relationships
among beans and "plain" facts. If the two behaved differently, this
symmetry would be broken and you'd have to work differently with the
two kinds of information. It would also complicate much of Jess's
implentation, again likely degrading performance. If I changed both
facts AND beans to behave the way you suggest, then we'd completely
lose CLIPS compatibility.

Nonetheless, I am interested in exploring ways to get this
functionality without hurting performance. As I ponder the possible
implementation strategies, suggestions for behaviour and features are,
as always, welcome.

I think Satish boggavarapu wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> 
> Hi,
> 
> Is there any way to modify only one slot of the definstance. Right now as
i
> observe it is retracting the object and reasserting it with updated
values.
> 
> I have the following scenario.
> 
> interface AIntf {
>       public int getId();
>       public void incrCount();
>       public void decrCount();
>       public int getCount();
>       public int getTotalCount();
> }
> 
> class A implements AIntf {
>       int id;
>       int count;
>       static final int total_count = 100;
>       ...................
>       ............
> }
> 
> (defclass A AIntf)
> 
> Now i have couple of rules which update the counter and check the
percentage
> of the count.
> 
> defrule R1 (
>       (A (id ?id) (OBJECT ?obj))
>       =>
>       (call ?obj incrCount)
> )
> 
> defrule R2 (
>       (A (count ?count) (totalCount ?total_count))
>       (test (> (/ (* ?count 100) ?total_count) 50))
>       => 
>       (printout t "count is more than 50 percent of the total count" crlf)
> )
> 
> Now whenever rule R1 fires and updates the counter i am firing an event to
> indicate there is a change in the count value so rule R2 can get evaluated
> again. But at the same time jess is retracting the entire A and
reasserting
> it with the new count value and rule R1 is getting activated again and
> firing. This is going in a cycle.  
> 
> Since i do not want to patternmatch on the count variable in rule R1 is
> there any way i can restrict this? Or is it possible to make jess retract
> only that count fact and re assert it instead of the entire object
instance?
> 
> Any suggestions?
> 
> Thanks in advance.
> Satish.
> 
> ---------------------------------------------------------------------
> 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]
---------------------------------------------------------------------

Reply via email to