[rules-users] Ruleflow and persistence
vdelbart
delbart.v at mipih.fr
Mon Sep 10 10:17:01 EDT 2007
Hello,
I have a problem with this ruleflow :
http://www.nabble.com/file/p12593732/ruleflow.jpg
This two rules package doesn't work in the same way :
First package :
#created on: 29 août 2007
package reductionExample1
import model.*
rule "global rule"
ruleflow-group "WorldReduction"
#include attributes such as "salience" here...
when
$p:Product(year == 2006)
then
#actions
System.out.println("Global rule");
System.out.println("$p.getPrice() : " + $p.getPrice());
$p.setPrice($p.getPrice()*1.1);
end
rule "local rule"
ruleflow-group "StateReduction"
#include attributes such as "salience" here...
when
$p:Product(year < 2007, $price: price)
then
#actions
System.out.println("Local rule");
System.out.println("$price : " + $price);
System.out.println("$p.getPrice() : " + $p.getPrice());
$p.setPrice($price * 1.2);
end
I have :
Before : Product(name=Adidas, year=2006, price=100.0)
Global rule
$p.getPrice() : 100.0
Local rule
$price : 110.00000000000001
$p.getPrice() : 110.00000000000001
After : Product(name=Adidas, year=2006, price=132.0)
Second package :
#created on: 29 août 2007
package reductionExample1
import model.*
rule "global rule"
ruleflow-group "WorldReduction"
#include attributes such as "salience" here...
when
$p:Product(year == 2006, $priceGlobal: price)
then
#actions
System.out.println("Global rule");
System.out.println("$price : " + $priceGlobal);
System.out.println("$p.getPrice() : " + $p.getPrice());
$p.setPrice($p.getPrice()*1.1);
end
rule "local rule"
ruleflow-group "StateReduction"
#include attributes such as "salience" here...
when
$p:Product(year < 2007, $price: price)
then
#actions
System.out.println("Local rule");
System.out.println("$price : " + $price);
System.out.println("$p.getPrice() : " + $p.getPrice());
$p.setPrice($price * 1.2);
end
I have :
Before : Product(name=Adidas, year=2006, price=100.0)
Global rule
$price : 100.0
$p.getPrice() : 100.0
Local rule
$price : 100.0
$p.getPrice() : 110.00000000000001
After : Product(name=Adidas, year=2006, price=120.0)
What is the normal execution (for me the first way) and why is different ?
thanks,
vdelbart
--
View this message in context: http://www.nabble.com/Ruleflow-and-persistence-tf4415033.html#a12593732
Sent from the drools - user mailing list archive at Nabble.com.
More information about the rules-users
mailing list