Debasish,


If you want to create an explicit template, it should look like this:



(deftemplate MAIN::opposite-of

    (slot entity-A)

   (slot entity-B))



Then the facts would be declared as:



(opposite-of (entity-A shore-1) (entity-B shore-2))



However, you'd also have to assert



(opposite-of (entity-A shore-2) (entity-B shore-1))



This will lead to problems with rules firing twice, once on each opposite-of
assertion. To handle that, you can adopt a convention that all commutative
relations, such as opposite-of, are expressed with arguments in canonical
order (e.g., sorted alphabetically):



(deftemplate MAIN::canonical-opposite-of

  (multislot entities))



This will result in facts of the form



      (canonical-opposite-of (entities shore-1 shore-2))



you will have to make sure that facts of the form



      (canonical-opposite-of (entities shore-2 shore-1)) ;;NOT CANONICAL



are never asserted. Also, when you assert a fact you'll to make sure that
the arguments are sorted in the right order (e.g., by applying a
deffunction).



Hope this helps.



-John







From: debasish.da...@cognizant.com [mailto:debasish.da...@cognizant.com]
Sent: Monday, November 22, 2010 3:38 AM
To: jess-users@sandia.gov
Subject: JESS: representation of deftemplate from deffacts



Hi Jess-users,



Just trying to understand, how the following deffacts can represent in
deftemplate?



(deffacts MAIN::opposites

  (opposite-of shore-1 shore-2)

  (opposite-of shore-2 shore-1))



Jess is creating a *implied* template for this as below.

(deftemplate MAIN::opposite-of

   "(Implied)"

   (multislot __data))



Here the term *__data* is not very much clear, since if I keep this as
template explicitly as follows -

(deftemplate MAIN::opposite-of

   (multislot __data))



The ruleset is running fine as expected, and JESS is not creating again the
*implied* template in this case. But, if I change it to some other name, say
*data* instead of *__data*, JESS engine throwing a exception (Jess reported
an error in routine Jesp.parseFact.)while parsing the above fact.



Also, if I create the template as follows using *slot*.

(deftemplate MAIN::opposite-of

(slot shore-1)

   (slot shore-2))



But in this case, the deffacts needs to be defined as follows, which seems
not same as mentioned above, and the rule is not working as expected.



(deffacts MAIN::opposites

  (opposite-of (shore-1 shore-2))

  (opposite-of (shore-2 shore-1)))



OR



(deffacts MAIN::initial-opposite-of

  (opposite-of (shore-1 shore-2)

                  (shore-2 shore-1)))



So, if anyone can clarify this.



Regards



DEBASISH DALUI (122816)
-----------------------------------

BFS - Technology Solutions Group,

Cognizant Technology Solutions,


Cell: +91 9674069478

Office: +91-33-44306060; VNet: 336063




This e-mail and any files transmitted with it are for the sole use of the
intended recipient(s) and may contain confidential and privileged
information.
If you are not the intended recipient, please contact the sender by reply
e-mail and destroy all copies of the original message.
Any unauthorised review, use, disclosure, dissemination, forwarding,
printing or copying of this email or any action taken in reliance on this
e-mail is strictly
prohibited and may be unlawful.



Reply via email to