Hi all,

I'm currently evaluating the use of drools for my research purposes and I have
two questions for you. I omit the java code because I think the problem is not
on that side, but if needed I can post it.

1. I have a directed graph with two nodes (N1 and N2) and (possibily) a relation
(R) between them. N1 has a value, let say, 1.0; what I'm trying to do is a
propagation mechanism that, if N2.value < N1.value, and the relation actually
exists between the nodes, then assigns N1.value to N2.value; otherwise, all
remains unchanged.
I wrote the following rule:

rule "Propagate values"

when

        n1 : Node( v1: value > 0 );
        
        n2 : Node( value < v1 );
        
        r : Relation();
        
        eval( r.startnode == n1 );
        eval( r.endnode == n2 );
        
then
        
        n2.value = n1.value;
        modify( n2 );

end

And it works. However, if I understood correctly, eval() is a second-best
choice. So I wrote this one:

rule "Propagate values"

when

        n1 : Node( v1: value > 0 );
        
        n2 : Node( value < v1 );
        
        r : Relation( startnode == n1, endgoal == n2 );
        
then
        
        n2.value = n1.value;
        modify( n2 );

end

But it won't work (the condition is never satisfied). Could you please explain
me why? (The objects in the workingMemory are the same, only the rule changes)


2. Let suppose the relation has a "metric", let say 0.5. The meaning of the
metric is this: if N2.value is less than (N1.value * R.metric), then N2.value =
(N1.value * R.metric); otherwise, it remains unchanged.
The first problem is: the "*" operator is not supported in rules. So, how could
I produce the same effect without using it? (And btw, will mathematical
operators be available in the future)?

Thank you

Alberto


Reply via email to