[rules-users] Queries with bound variables

Senlin Liang senlin.liang at gmail.com
Tue Aug 19 11:12:03 EDT 2008


In the following program, i want to compute the paths:
<code>
rule "base"
    when
        edge : Edge(x : first, y : second)
	not   Path(first == x, second == y)
    then
	insert(new Path(edge.getFirst(), edge.getSecond()));
end

rule "recursive"
    when
        edge : Edge(x : first, z : second)
	path  : Path(first == z, y : second)
	not      Path(first == x, second == y)
    then
        insert(new Path(edge.getFirst(), path.getSecond()));
end
</code>

My question: How to express the query "path(cityA, X)?" efficiently in drools?

Since the first element is bound to 'cityA', I am wondering whether
drools can make use of it. I think there should be more efficient way
than firing all rules.

Thanks,
Senlin Liang



More information about the rules-users mailing list