On 19/02/2011 15:01, Simon Chen wrote:
Let me make sure I get it correctly...
The example you gave seems to be the one-hop case. For the two-hop
case, we need something like this
when
edge(a, b), reach(b, c), not exists reach(a, c)
then
insertLogical( reach(a,c) )
So, where do you put your logical around? It should include both
edge(a,b) and reach(b,c), right?
Yes a logical CE should be able to wrap 1....n
patterns from the first
pattern. Clips makes you have a logical CE per pattern, but I don't see
why that is necessary, compared to having a single CE that contains
multiple patterns.
http://www.csie.ntu.edu.tw/~sylee/courses/clips/bpg/node5.4.8.html
Mark
Another thought, can we have something like
testExistsAndInsertLogical() to replace insertLogical()? But this may
be buggy, as the conditions are all met, so the rule actually fired...
I really need this working, so I'll probably take a crack at modifying
drools, although haven't done it before...
What's this for? A university
project, or a company project?
Mark
Thanks.
-Simon
On Saturday, February 19, 2011, Mark Proctor<mproctor(a)codehaus.org> wrote:
> I think to impl this what is needed is a "logical" node. At the moment
> the entire LHS forms the justification. But if we supported a logical
> node, we could do this:
> rule "reachDirect"
> salience 10
> when
> logical( e : Edge(s1 : source, t1 : target) )
> not( Reach(source == s1, target == t1) )
> then
> insertLogical( new Reach(e.getSource(),e.getTarget()) );
> System.out.println( "Reach " + e.getSource() + "," +
> e.getTarget() );
> end
>
>
> That means that it would be inserted when there was no Reach, but it
> would only be retracted when there was no matching Edge. The
> justification is only for the part of the rule that is in the logical
> grouping.
>
> To do this is actually quite a trivial change in drools, but it's not
> something we do now. I think one reason why I held off was that i was
> looking at Jess and Clips that have this and they state you can have
> multiple logical elements. But i could't figure out how having 2 or 3
> would differ, compare to having just one.
>
> Anway to support a singe logical element, you'd need to update the
> parser to support 'logical' conditional element, in the same format as
> 'not' and 'exists'. Then if you look at RuleTerminalNode you'll
see the
> part of the code that is related to removing the justifications, on a
> retract or modify - removeLogicalDependencies. Likewise if you look in
> the DefaultKnowlegeHelper you'll see how the insertion works. That could
> would instead be copied to the logical node. If a logical node exists
> the RTN should have an if statement so the same code does not execute again.
>
> Any takers?
>
> Mark
>
>
> On 19/02/2011 05:20, Simon Chen wrote:
>> Hi all,
>>
>> I know this is kinda an old topic, but I just couldn't get it working.
>>
>> Here is a previous attempt using insertLogical() to handle transitive
>> closure:
>>
http://drools-java-rules-engine.46999.n3.nabble.com/transitive-closure-td...
>> The problem with this one is that the newly "logically inserted"
object
>> would violate its own "not exists" condition term, thus removing
itself,
>> then goes the infinite circle of insert/remove...
>>
>> Here is a post that deals with transitive closure using "insert", but
it
>> doesn't handle object removal correctly:
>>
http://drools-java-rules-engine.46999.n3.nabble.com/one-question-about-Tr...
>>
>>
>> To me, using insertLogical is attractive because it doesn't require me to
>> write specific rules to handle object removal. Is there a trick that I can
>> use to actually implement transitive closure with insertLogical?
>>
>> Thanks a lot!
>> -Simon
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users