I think Osvaldo Pinali Doederlein wrote:
> 
> Hi,
> 
> I'm a bit new to Jess, but I already have lots of stuff working (thanks to
> this thing being so easy!) and it's so much stuff that I am already needing
> help on performance and design... :)
> 
> 1. I have a very big graph of Java objects that I'm converting to JESS
> facts.  But my approach is killing all my collections and using back
> references in the pointed things.  For example if I have a class A with a
> list of instances of B, in my facts I will have this:
> 
> (A (code 777) (...other slots...))
> (B (code 778) (owner 777) (...other slots...))
> (B (code 779) (owner 777) (...other slots...))
> 
> I think this is a good idea, but I could try to use the multislots too,
> but would that be slower?

Matching on multislots is definitely slower.

> 
> 2. Is it a good idea to have those unique ID codes to do references between
> things (I'm using deftemplates for all stuff).  My objects are a complex
> graph and there's no way I can generate the facts using references for the
> fact-IDs in a single pass; I would need to do some postprocessing in the
> fact database in order to have that but it's an option.  Basically, I need
> to have tons of pointers btw facts and I have forward references, cycles,
> every damn thing.
> 

This is a classic complaint about the CLIPS fact model. Have you
looked, by the way, at using defclasses and Beans instead of
deftemplates? That's a better technique for object-like things.


> 3. I instinctively transformed my model in several ways while doing the
> templates -- inlining the fields of small aggregate objects in their owners,
> placing unique IDs everywhere, denormalizing structure, commenting out
> unused slots, creating new templates to encode N-N relationships... except
> for the template inheritance, isn't that surprisingly similar to good old
> relational databases? :-)  This is not actually a question, just tell me if
> I'm doing a very unholy and bad thing, as I'm totally fresh to CLIPS.
> 

It's very similar to RDBMSs. In fact, there was (and is) a lot of
overlap between the people who developed this sort of ES technology
and who developed heavy-duty relational database technology. Many
folks (David Miranker is a a good example) continue to blur the distinction.

> 4. Now a really novice question.  How can I prevent things from being
> detected lots of times.  I see that I can retract facts, but I don't want to
> retract any fact because I'm using them to detect several things.  For
> example I have this simple rule:
> 
> (defrule siblings "Finds sibling classes in the inheritance tree"
>   (Generalization (parent ?parent-code) (child ?child-code-1))
>   (Generalization (parent ?parent-code) (child ?child-code-2))
>   (test (neq ?child-code-1 ?child-code-2))
>   (Class (code ?child-code-1) (name ?child-name-1))
>   (Class (code ?child-code-2) (name ?child-name-2))
>   =>
>   (printout t "Found siblings: " ?child-name-1 ", " ?child-name-2 crlf)
> )
> 
> This code works, but it will detect twice all my sibling classes, e.g. if I
> have A and B derived from the same base class, I'll get "Found siblings: A,
> B" and also "Found siblings: B, A".  I fully understand why this happens,
> but not how to prevent it :)

The most common solution is to put a note onto the fact-list

(defrule siblings "Finds sibling classes in the inheritance tree"
   (Generalization (parent ?parent-code) (child ?child-code-1))
   (Generalization (parent ?parent-code) (child ?child-code-2))
   (test (neq ?child-code-1 ?child-code-2))
   (not (done ?child-code-2 ?child-code-1))
   (Class (code ?child-code-1) (name ?child-name-1))
   (Class (code ?child-code-2) (name ?child-name-2))
   =>
   (printout t "Found siblings: " ?child-name-1 ", " ?child-name-1 crlf)
   (assert (done ?child-code-2 ?child-code-1))
 )


> 
> Thanks a lot!!  :)
> 
> ----------------------------------------------------------------
> *** The Free, Open and Pure Java Shell *** Current: Alpha6
> http://www.geocities.com/ResearchTriangle/Node/2005/java_shell.htm
> http://student.vub.ac.be/~opinalid/java_shell.htm
> ----------------------------------------------------------------
> Osvaldo Pinali Doederlein [EMAIL PROTECTED]
> MSc student, Developer, Java & CORBA evangelist, Rainmaker, etc.
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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]
> ---------------------------------------------------------------------
> 
> 


---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 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]
---------------------------------------------------------------------

Reply via email to