I will take a look on those classes, sounds really interesting.
- CTO @
- Mauricio "Salaboy" Salatino -
On 19/02/2011, at 05:24, 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