[rules-users] Unable to create restriction '[QualifiedIndentifierRestr: != $nissan.pos ]' for field 'pos' , in the rule 'Racing order'

Edson Tirelli tirelli at post.com
Thu Aug 21 11:24:17 EDT 2008


   Maxim,

   I'm not sure about what specific case you are talking too, but Drools 4
is supposed to be faster than Drools 3, specially if you follow the best
practices and disable shadow facts.

   []s
   Edson

2008/8/21 Maxim Veksler <maxim.veksler at gmail.com>

> Hello Edson,
>
> Thank you for your reply. We are considering moving on to Drool4, the main
> question actually is performance. Is Drools4 can provide better performance
> regarding speed of conclusion.
>
> I'm considering suggesting a move to v4 but haven't so because I've read
> some reports on this list about Drools 4 slowness. Could you suggest please
> your opinion on the subject?
>
>
> Thank you very much,
> Maxim.
>
>
> On Thu, Aug 21, 2008 at 4:57 PM, Edson Tirelli <tirelli at post.com> wrote:
>
>>
>>    Yes, it is a new feature on Drools 4. Please note that Drools 4 has a
>> huge amount of improvements in comparison to Drools 3, and we strongly
>> advise the upgrade.
>>    If you really want to stay on Drools 3, you should contact Red Hat for
>> support. Not sure it is possible, but you may try.
>>
>>    []s
>>    Edson
>>
>> 2008/8/21 Maxim Veksler <maxim.veksler at gmail.com>
>>
>>
>>> On Wed, Aug 20, 2008 at 8:57 PM, Edson Tirelli <tirelli at post.com> wrote:
>>>
>>>>
>>>>    You are using variables (like $nissan) before binding them. Remember
>>>> you can only use a variable "after" binding it.
>>>>
>>>>    []s
>>>>    Edson
>>>>
>>>
>>> Please allow me to a related question, regarding drools 3.0.x
>>>
>>> In this LHS example, mentioned in this thread :
>>>
>>> """
>>>        $fred : Golfer( name == "Fred")
>>>        $bob : Golfer( name == "Bob",
>>>                position != $fred.position,
>>>                color == "plaid",
>>>                color != $fred.color)
>>> """
>>>
>>> $fred is a bind variable, but how is it possible to use a data member
>>> from this variable inside another node's ruling ?
>>>
>>> Judging from Drools 3, this should have failed with compilation errors,
>>> assuming that it's a new feature of Drools 4, is there a possibility to
>>> implement this behavior in drools3? as it would be great help for me in my
>>> rules.
>>>
>>> // Just for reference, the way I would implement the above logic in
>>> Drools 3 is :
>>>
>>> """
>>>        $fred : Golfer( name == "Fred", $fredPosition : position,
>>> $fredColor : color)
>>>        $bob : Golfer( name == "Bob",
>>>                position != $fredPosition,
>>>                color == "plaid",
>>>                color != $fredColor)
>>> """
>>>
>>>
>>> Thank you,
>>> Maxim.
>>>
>>>>
>>>>
>>>> 2008/8/20 Marcin Krol <mrkafk at gmail.com>
>>>>
>>>> Hello everyone,
>>>>>
>>>>> I managed to produce my first example of Drools rules. However, I am
>>>>> having problems with some field restrictions:
>>>>>
>>>>> Racing order:Unable to create restriction '[QualifiedIndentifierRestr:
>>>>> != $nissan.pos ]' for field 'pos' in the rule 'Racing order'
>>>>>
>>>>> The problem is only SOME field restrictions produce this error. Other
>>>>> field restrictions don't!
>>>>>
>>>>> If anybody has a hint or knows why this is not working, please let me
>>>>> know, I would greatly appreciate it.
>>>>>
>>>>>
>>>>>
>>>>> The rules are:
>>>>>
>>>>>
>>>>> #created on: 2008-08-20
>>>>> package com.sample
>>>>>
>>>>> #list any import classes here.
>>>>>
>>>>> #declare any global variables here
>>>>>
>>>>> dialect "mvel"
>>>>>
>>>>> import com.sample.Car;
>>>>>
>>>>> rule "Racing order"
>>>>>    when
>>>>>
>>>>>        // Porsche was not red
>>>>>        $porsche : Car( manufacturer == "Porsche",
>>>>>                pos != $nissan.pos,
>>>>>                pos != $subaru.pos,
>>>>>                color != "red"
>>>>>                //color != "blue",
>>>>>                //color != $nissan.color,
>>>>>                //color != $subaru.color
>>>>>                )
>>>>>
>>>>>
>>>>>                // First car was Nissan
>>>>>        $nissan : Car( manufacturer == "Nissan",
>>>>>         pos == 1,
>>>>>         color != $subaru.color,
>>>>>         color != $porsche.color )
>>>>>
>>>>>        // Subaru was blue
>>>>>        $subaru : Car( manufacturer == "Subaru",
>>>>>                //pos == 2,
>>>>>                pos != $nissan.pos,
>>>>>                pos != $porsche.pos,
>>>>>                color == "blue" )
>>>>>
>>>>>                // 2nd car was silver
>>>>>        Car( pos == 2,
>>>>>                      color == "silver",
>>>>>                      this in ( $nissan, $subaru, $porsche ) )
>>>>>
>>>>>        then
>>>>>        System.out.println( "Nissan " + $nissan.getPos() + " " +
>>>>> $nissan.getColor() );
>>>>>        System.out.println( "Subaru " + $subaru.getPos() + " " +
>>>>> $subaru.getColor() );
>>>>>        System.out.println( "Porsche " + $porsche.getPos() + " " +
>>>>> $porsche.getColor() );
>>>>>
>>>>> end
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> The Car.java file:
>>>>>
>>>>>
>>>>> package com.sample;
>>>>>
>>>>>    public class Car {
>>>>>        private String manufacturer;
>>>>>        private String color;
>>>>>        private int pos;
>>>>>
>>>>>        public Car() {
>>>>>
>>>>>        }
>>>>>
>>>>>        public Car(String manufacturer, String color, int pos) {
>>>>>                super();
>>>>>                this.color = color;
>>>>>                this.pos = pos;
>>>>>                this.manufacturer = manufacturer;
>>>>>        }
>>>>>
>>>>>        public String getManufacturer() {
>>>>>                return this.manufacturer;
>>>>>        }
>>>>>
>>>>>        public float getPos() {
>>>>>                return this.pos;
>>>>>        }
>>>>>
>>>>>        public String getColor() {
>>>>>                return this.color;
>>>>>        }
>>>>>    }
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> The CarExample.java file, which is the main app:
>>>>>
>>>>>
>>>>>
>>>>> package com.sample;
>>>>>
>>>>> import java.io.InputStreamReader;
>>>>>
>>>>> import org.drools.RuleBase;
>>>>> import org.drools.RuleBaseFactory;
>>>>> import org.drools.StatefulSession;
>>>>> import org.drools.compiler.PackageBuilder;
>>>>> import com.sample.Car;
>>>>>
>>>>> public class CarExample {
>>>>>
>>>>>    public static void main(String[] args) throws Exception {
>>>>>
>>>>>        final PackageBuilder builder = new PackageBuilder();
>>>>>        builder.addPackageFromDrl( new InputStreamReader(
>>>>> CarExample.class.getResourceAsStream( "CarExample.drl" ) ) );
>>>>>
>>>>>        final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
>>>>>        ruleBase.addPackage( builder.getPackage() );
>>>>>
>>>>>        final StatefulSession session = ruleBase.newStatefulSession();
>>>>>
>>>>>        String[] names = new String[] { "Nissan", "Subaru", "Porsche"};
>>>>>        String[] colors = new String[] { "red", "blue", "silver"};
>>>>>        int[] positions = new int[] { 1, 2, 3 };
>>>>>
>>>>>        for ( int n = 0; n < names.length; n++ ) {
>>>>>            for ( int c = 0; c < colors.length; c++ ) {
>>>>>                for ( int p = 0; p < positions.length; p++ ) {
>>>>>                    session.insert( new Car( names[n], colors[c],
>>>>> positions[p]) );
>>>>>                }
>>>>>            }
>>>>>        }
>>>>>
>>>>>        session.fireAllRules();
>>>>>        session.dispose();
>>>>>    }
>>>>>
>>>>>
>>>>>
>>>>> }
>>>>>
>>>>> _______________________________________________
>>>>> rules-users mailing list
>>>>> rules-users at lists.jboss.org
>>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Edson Tirelli
>>>> JBoss Drools Core Development
>>>> JBoss, a division of Red Hat @ www.jboss.com
>>>>
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>
>>>>
>>>
>>>
>>> --
>>> Cheers,
>>> Maxim Veksler
>>>
>>> "Free as in Freedom" - Do u GNU ?
>>>
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>>
>>
>> --
>> Edson Tirelli
>> JBoss Drools Core Development
>> JBoss, a division of Red Hat @ www.jboss.com
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
>
> --
> Cheers,
> Maxim Veksler
>
> "Free as in Freedom" - Do u GNU ?
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
Edson Tirelli
JBoss Drools Core Development
JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080821/7cf30300/attachment.html 


More information about the rules-users mailing list