Hello,

I have a question about the multislots. I have a rule that basically tries to match two cars that having black color.

/(defrule get-black-cars
   (car (id ?id1) (color "black"))
   (car (id ?id2 &:(~= ?id1 ?id2)) (color "black"))
(and (not (black-cars (car-id ?id1 ?id2)) (not (black-cars (car-id ?id2 ?id1)))
=>
(assert (black-cars (car-id ?id1 ?id2)))/

The important thing is that the cars should be diferent, so this is why i use the /&:(~= ?id1 ?id2))/ expression. I even use the "/not/" expression to avoid duplication, like:
   car A and car B are black, meaning that i will have a fact:
        / black-cars (car-id A B)/
   but the same is true
         /black-cars (car-id B A)/

My question is: There is a matching way of avoid this comparison? The only thing i want to know is which are the black cars, not the order.

Moreover, when matching a multislot, a simillar problem arises:
/(defrule matching-multislot
   (car (id ?id1) (color "black"))
   (car (id ?id2 &:(~= ?id1 ?id2)) (color "black"))
   (not (black-cars (car-id ?id1 ?id2)))
=>..../
Depending on how jess schedule the matching facts, this rule might be eroneous, because i can have a fact /black-cars (car-id A B)/, which is not the same as /black-cars (car-id B A)/. This means that for pair of elements in the multislot a check must follow, replacing the last /not/ with / (and (not (black-cars (car-id ?id1 ?id2))) (not (black-cars (car-id ?id2 ?id1)))). /While this is not a problem with two elements, can become a very diffult problem with 3 or more elements. Can anyone tell me techniques to avoid this situation?

Regards,

Joao

---------------
unclassified email






------------------------------------------------------------------------------------------------------------
Disclaimer:

If you are not the intended recipient of this email, please notify the sender and delete it. Any unauthorized copying, disclosure or distribution of this email or its attachment(s) is forbidden. Thales Nederland BV will not accept liability for any damage caused by this email or its attachment(s). Thales Nederland BV is seated in Hengelo and is registered at the Chamber of Commerce under number 06061578.
------------------------------------------------------------------------------------------------------------

begin:vcard
fn;quoted-printable:Jo=C3=A3o Mour=C3=A3o
n;quoted-printable;quoted-printable:Mour=C3=A3o;Jo=C3=A3o
org:Thales;Above Water Systems
adr:;;;Hengelo;;;Netherlands
email;internet:[email protected]
title:THALES NETHERLANDS B.V.
tel;work:2640
note:-unclassified mail-
version:2.1
end:vcard

Reply via email to