Re: [rules-users] Shadow facts

2009-02-11 Thread Mark Proctor

J Michael Dean wrote:
I think I was not clear in my note.  I used dynamic facts with Drools 
4.07 but am migrating to Drools 5, where there is no longer a second 
argument to the insert method.  My POJOs do have property change 
listeners.
We have deprecated the insert method in favour of an attribute of a type 
declaration for propertychangesupport, this will be in the CR.


Mark


Here is an example rule that activates but never apparently fires:

rule "Detect insulin on"
dialect "java"
when
decision : GlucoseDecision(currentInsulinDripRate > 0)
decisionState : GlucoseDecisionState( insulinOn == false )
then
decisionState.setInsulinOn(true);
end

The relevant method that is called on the RHS:

public void setInsulinOn(boolean insulinOn) {
boolean oldValue = this.isInsulinOn();
this.insulinOn = insulinOn;
firePropertyChange("insulinOn", oldValue, insulinOn);
}

The eventual call is to fireRules which then calls executeRules in a 
callback.  Previously, I had a Boolean argument to the insert
statements and all the code worked with the old RuleBase, RuleAgent 
objects.  But since changing to KnowledgeSession, the rules

do not appear to fire.  Here are the relevant methods:

public void executeRules(WorkingEnvironmentCallback callback) {
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
callback.initEnvironment(ksession);
ksession.fireAllRules();
ksession.dispose();
}

public void fireRules(final GlucoseDecision glucoseDecision, final 
GlucoseDecisionState decisionState) {

rulesEngine.executeRules(new WorkingEnvironmentCallback() {
public void initEnvironment(StatefulKnowledgeSession workingMemory) {
workingMemory.insert(glucoseDecision);
workingMemory.insert(decisionState);
}
});
}


Message: 2
Date: Wed, 11 Feb 2009 10:26:06 -0500
From: Edson Tirelli mailto:tire...@post.com>>
Subject: Re: [rules-users] Shadow facts
To: Rules Users List >

Message-ID:
>

Content-Type: text/plain; charset="iso-8859-1"

  Dean,

  There are two unrelated things in here... the boolean flag for dynamic
facts means your fact supports the property change listeners and you 
don't

need to call modify() when you change an attribute. ShadowFacts are a
complete different thing that should be mostly transparent to users.
  If you can provide an example, it will be easier to help you.

   []s
   Edson

2009/2/11 J Michael Dean >



I am migrating from 4.07 to 5 and my previous DRL file does not function
correctly;  I previousliy inserted facts with the dynamic Boolean 
set true.

I understand that this is no longer done because shadow facts are "not
needed" in Drools 5, but is it necessary to do anything different in 
the RHS

when modifying facts?  My fact POJOs have a method for adding text to
themselves.  I believe my rules are not working properly because 
nothing is

being modified - only the initial activation set fires and then nothing
happens.

Restated, the documentation talks about how to "avoid" shadow facts in
Drools 4.07 - are the restrictions in this part of the docs necessary in
Drools 5?

Thanks.
___
rules-users mailing list
rules-users@lists.jboss.org 
https://lists.jboss.org/mailman/listinfo/rules-users




___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
  


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Shadow facts

2009-02-11 Thread J Michael Dean
I think I was not clear in my note.  I used dynamic facts with Drools  
4.07 but am migrating to Drools 5, where there is no longer a second  
argument to the insert method.  My POJOs do have property change  
listeners.


Here is an example rule that activates but never apparently fires:

rule "Detect insulin on"
dialect "java"
when
decision : GlucoseDecision(currentInsulinDripRate > 0)
decisionState : GlucoseDecisionState( insulinOn == false )
then
decisionState.setInsulinOn(true);
end

The relevant method that is called on the RHS:

public void setInsulinOn(boolean insulinOn) {
boolean oldValue = this.isInsulinOn();
this.insulinOn = insulinOn;
firePropertyChange("insulinOn", oldValue, insulinOn);
}

The eventual call is to fireRules which then calls executeRules in a  
callback.  Previously, I had a Boolean argument to the insert
statements and all the code worked with the old RuleBase, RuleAgent  
objects.  But since changing to KnowledgeSession, the rules

do not appear to fire.  Here are the relevant methods:

public void executeRules(WorkingEnvironmentCallback callback) {
		StatefulKnowledgeSession ksession =  
kbase.newStatefulKnowledgeSession();

callback.initEnvironment(ksession);
ksession.fireAllRules();
ksession.dispose();
}

	public void fireRules(final GlucoseDecision glucoseDecision, final  
GlucoseDecisionState decisionState) {

rulesEngine.executeRules(new WorkingEnvironmentCallback() {
public void initEnvironment(StatefulKnowledgeSession 
workingMemory) {
workingMemory.insert(glucoseDecision);
workingMemory.insert(decisionState);
}
});
}


Message: 2
Date: Wed, 11 Feb 2009 10:26:06 -0500
From: Edson Tirelli 
Subject: Re: [rules-users] Shadow facts
To: Rules Users List 
Message-ID:

Content-Type: text/plain; charset="iso-8859-1"

  Dean,

  There are two unrelated things in here... the boolean flag for  
dynamic
facts means your fact supports the property change listeners and you  
don't

need to call modify() when you change an attribute. ShadowFacts are a
complete different thing that should be mostly transparent to users.
  If you can provide an example, it will be easier to help you.

   []s
   Edson

2009/2/11 J Michael Dean 

I am migrating from 4.07 to 5 and my previous DRL file does not  
function
correctly;  I previousliy inserted facts with the dynamic Boolean  
set true.
I understand that this is no longer done because shadow facts are  
"not
needed" in Drools 5, but is it necessary to do anything different  
in the RHS

when modifying facts?  My fact POJOs have a method for adding text to
themselves.  I believe my rules are not working properly because  
nothing is
being modified - only the initial activation set fires and then  
nothing

happens.

Restated, the documentation talks about how to "avoid" shadow facts  
in
Drools 4.07 - are the restrictions in this part of the docs  
necessary in

Drools 5?

Thanks.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] StatefulKnowledgeSession and J2EE

2009-02-11 Thread Dan Seaver

Is there any recommended "Best Practice" for instantiating and accessing a
StatelfulKnowledgeSession in a J2EE environment? 

One use case for this type of session is it will act as a Complex Event
Processor - taking in low-level events from all over the system and throwing
complex events based on Fusion rules. The session is intended to be global
in nature as ALL events will flow through this CEP processor.

Another use case would be for long running processes or work-flows that
interact with data streams.

The 3 patterns I'm looking at are:
- the Singleton pattern
- use of JMS and MDBs
- use of external rule server(s)

Any thoughts about scalability issues?
-- 
View this message in context: 
http://www.nabble.com/StatefulKnowledgeSession-and-J2EE-tp21968423p21968423.html
Sent from the drools - user mailing list archive at Nabble.com.

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools rule writing question

2009-02-11 Thread Steve Núñez
Fusion


On 11/02/09 6:35 PM, "Denny Lee"  wrote:

> Hello,
> I am new to Drools.  We have been using JESS for a while and ran into a
> problem that we cannot solve and is hoping Drools have a solution.  Is there
> anything in the Drools language / rules that allows for temporal evaluation
> within the rules?  What I mean is, say your rule examines 2 variables, var1
> and var2, and if both are true it fires.  Is there any way/technique to say
> "If var1 becomes true and var2 was ALREADY true, fire" and "If var1 was
> ALREADY true and var2 becomes true, DO NOT fire?"   I've worked w/ JESS and
> there is nothing built into the language that does this.  Is there something
> in Drools that can handle this or some general techniques that can deal with
> something like this?
> 
> Thanks.
> 
> Denny
> 
>  
> 
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Drools rule writing question

2009-02-11 Thread Denny Lee
Hello,
I am new to Drools.  We have been using JESS for a while and ran into a problem 
that we cannot solve and is hoping Drools have a solution.  Is there anything 
in the Drools language / rules that allows for
temporal evaluation within the rules?  What I mean is, say your rule
examines 2 variables, var1 and var2, and if both are true it fires.  Is
there any way/technique to say "If var1 becomes true and var2 was
ALREADY true, fire" and "If var1 was ALREADY true and var2 becomes
true, DO NOT fire?"   I've worked w/ JESS and there is nothing built
into the language that does this.  Is there something in Drools that can handle 
this or some general techniques that can deal with something like this?

Thanks.

Denny



  ___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] drools-solver -- logger error (slf4j binding)?

2009-02-11 Thread Andrew Waterman

Hi,

I'm using the drools-solver.M5 build through Maven and have gotten the  
following error while running my project:


SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for  
further details.


I've checked my dependency graph, and drools-solver references the  
sl4j-api, but no implementation.  I checked the mvnrepository, and  
there are several other slf4j related projects.  What is the preferred  
binding for JDK1.6?


best wishes,

Andrew

-
Andrew Waterman
San Cristóbal de las Casas, Chiapas, Mexico
+52 1 967 107 5902
+1 510 342 5693









___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools Performance

2009-02-11 Thread Steve Núñez
Ashish,

There are a lot of variables involved in performance benchmarking. Your
scenario is common in many industries, such as insurance, that utilise large
decision tables.

We have previously published benchmarks comparing various rules engines at
http://illation.com.au/benchmarks, however they don¹t specifically address
the use case of large rulesets, but instead stress various aspects of the
rules engines.

We are working to put together a new set of benchmarks that will better test
typical use cases, and we¹d welcome your comments and participation. We are
very early in this process, and should have a publically available Œblog to
discuss the topic.

Regards,
- Steve Nunez


On 11/02/09 11:37 AM, "Ashish Soni"  wrote:

> Hi All , 
> 
> I am not sure if this question is asked previously but it would be great if
> any one can put some lights on this ..
> 
> If i have 10,000 rules with same priority or equal priority then how drools
> engine evaluate them or what is the path it chooses.
> 
> Also if there any performance metrics available ,please point to the links.
> 
> 
> Thanks and Regards,
> Ashish soni

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools-solver performance optimizations?

2009-02-11 Thread Andrew Waterman

Hi Wim,

I'm just starting to use the solver as well on a project.  Have you  
ensured that the algorithm implemented by the other solver is the same  
as the local search your using for drools-solver?  You may want to  
think about tuning that piece, by switching to Geoffrey's tabu  
implementation.


I believe there are a few other examples in drools-solver-examples  
that show some different approaches to both using the MoveFactory  
(small-grained moves versus rough-grain moves) as well as with a  
StartingSolutionInitializer.


Anyway, thought I'd pass on a few ideas from my limited experience  
with the project and interacting on the list.


best,

A

-
Andrew Waterman
San Cristóbal de las Casas, Chiapas, Mexico
+52 1 967 107 5902
+1 510 342 5693








On Feb 11, 2009, at 12:59 PM, Wim Vancroonenburg wrote:


Hi,

I'm a student currently evaluating Drools Solver for my  
dissertation. I am currently trying to solve an optimization problem  
with two different solvers (one of which is Drools Solver) and I am  
comparing the results with earlier obtained results from literature.  
However I am having some troubles with the performance of Drools  
Solver, and I was hoping if someone could look at my rules to see if  
they could be tuned:


rule "patientsToBeAssignedToRoomsOfAppropriateSex"
when
$n : Night();
$room : Room(sexRestriction == Sex.Dependent &&  
capacity > 1);
$genders : ArrayList(size>1) from  
collect( PatientStay(bed.room == $room, night == $n) );
exists PatientStay(bed.room == $room, night == $n,  
$a : admission, eval(((PatientStay) 
$genders.get(0)).getAdmission().getPatient().getSex() !=  
$a.getPatient().getSex()));

then
insertLogical(new  
IntConstraintOccurrence 
("patientsToBeAssignedToRoomsOfAppropriateSex 
",ConstraintType.NEGATIVE_HARD,50,$room,$n));

end

rule "hasRequiredRoomProperties"
when
$pr : RequiredRoomPropertiesConstraint($a :  
admission, $r : room, $w : weight );

$ps : PatientStay(admission == $a, bed.room == $r);
then
insertLogical(new  
IntConstraintOccurrence 
("hasPreferredRoomProperties",ConstraintType.NEGATIVE_SOFT,50*$w, 
$ps));

end

rule "unplannedTransfers"
when
$ps : PatientStay($a : admission, $b : bed, $n :  
night);
$ps2 : PatientStay(admission == $a, bed != $b, $n2 :  
night,eval($n.getIndex()+1 == $n2.getIndex()));

then
insertLogical(new  
IntConstraintOccurrence 
("unplannedTransfers",ConstraintType.NEGATIVE_SOFT,110,$ps,$ps2));

end

rule "hasPreferredRoomProperties"
when
$pr : PreferredRoomPropertiesConstraint($a :  
admission, $r : room, $w : weight );

$ps : PatientStay(admission == $a, bed.room == $r);
then
insertLogical(new  
IntConstraintOccurrence 
("hasPreferredRoomProperties",ConstraintType.NEGATIVE_SOFT,20*$w, 
$ps));

end

rule "meetsRoomPreference"
when
$mr : MeetsRoomPreferenceConstraint($a : admission,  
$r : room);

$ps : PatientStay(admission == $a, bed.room == $r);
then
insertLogical(new  
IntConstraintOccurrence 
("meetsRoomPreference",ConstraintType.NEGATIVE_SOFT,8,$ps));

end

rule "inGoodDepartment"
when
$gd : GoodDepartmentConstraint($a : admission, $d :  
department);
$ps : PatientStay(admission == $a, $b : bed,  
eval($b.getRoom().getDepartment().equals($d)));

then
insertLogical(new  
IntConstraintOccurrence 
("inGoodDepartment",ConstraintType.NEGATIVE_SOFT,10,$ps));

end

rule "inGoodRoom"
when
$gr : GoodRoomConstraint($a : admission, $r : room,  
$w : weight);

$ps : PatientStay(admission == $a, bed.room == $r);
then
insertLogical(new  
IntConstraintOccurrence("inGoodRoom",ConstraintType.NEGATIVE_SOFT,10* 
$w,$ps));

end

rule "calcScore"
salience -10
when
$count : Number() from  
accumulate( IntConstraintOccurrence($w : weight) ,
 sum 
($w) );

then
scoreCalculator.setScore(-$count.doubleValue());
end

The classes with **Constraint in it are possible combinations that  
cause a constraint to be violated, and are calculated and inserted  
at initialization time (and are never changed). I know that the rule  
"patientsToBeAssignedToRoomsOfAppropriateSex" is fairly complex, but  
even when I remove it, the performance is not fantastic. Is there  
anything else I can do to get better performance? I'm already using  
JDK 1.6 and -server mode. Furthermore, all classes used here have  
their default equals and hashCode methods, so they don't have an  
impact on performance.


Sincerely,

Wim Va

[rules-users] Drools-solver performance optimizations?

2009-02-11 Thread Wim Vancroonenburg
Hi,

I'm a student currently evaluating Drools Solver for my dissertation. I am
currently trying to solve an optimization problem with two different solvers
(one of which is Drools Solver) and I am comparing the results with earlier
obtained results from literature. However I am having some troubles with the
performance of Drools Solver, and I was hoping if someone could look at my
rules to see if they could be tuned:

rule "patientsToBeAssignedToRoomsOfAppropriateSex"
when
$n : Night();
$room : Room(sexRestriction == Sex.Dependent && capacity >
1);
$genders : ArrayList(size>1) from collect(
PatientStay(bed.room == $room, night == $n) );
exists PatientStay(bed.room == $room, night == $n, $a :
admission,
eval(((PatientStay)$genders.get(0)).getAdmission().getPatient().getSex() !=
$a.getPatient().getSex()));
then
insertLogical(new
IntConstraintOccurrence("patientsToBeAssignedToRoomsOfAppropriateSex",ConstraintType.NEGATIVE_HARD,50,$room,$n));
end

rule "hasRequiredRoomProperties"
when
$pr : RequiredRoomPropertiesConstraint($a : admission, $r :
room, $w : weight );
$ps : PatientStay(admission == $a, bed.room == $r);
then
insertLogical(new
IntConstraintOccurrence("hasPreferredRoomProperties",ConstraintType.NEGATIVE_SOFT,50*$w,$ps));
end

rule "unplannedTransfers"
when
$ps : PatientStay($a : admission, $b : bed, $n : night);
$ps2 : PatientStay(admission == $a, bed != $b, $n2 :
night,eval($n.getIndex()+1 == $n2.getIndex()));
then
insertLogical(new
IntConstraintOccurrence("unplannedTransfers",ConstraintType.NEGATIVE_SOFT,110,$ps,$ps2));
end

rule "hasPreferredRoomProperties"
when
$pr : PreferredRoomPropertiesConstraint($a : admission, $r :
room, $w : weight );
$ps : PatientStay(admission == $a, bed.room == $r);
then
insertLogical(new
IntConstraintOccurrence("hasPreferredRoomProperties",ConstraintType.NEGATIVE_SOFT,20*$w,$ps));
end

rule "meetsRoomPreference"
when
$mr : MeetsRoomPreferenceConstraint($a : admission, $r :
room);
$ps : PatientStay(admission == $a, bed.room == $r);
then
insertLogical(new
IntConstraintOccurrence("meetsRoomPreference",ConstraintType.NEGATIVE_SOFT,8,$ps));
end

rule "inGoodDepartment"
when
$gd : GoodDepartmentConstraint($a : admission, $d :
department);
$ps : PatientStay(admission == $a, $b : bed,
eval($b.getRoom().getDepartment().equals($d)));
then
insertLogical(new
IntConstraintOccurrence("inGoodDepartment",ConstraintType.NEGATIVE_SOFT,10,$ps));
end

rule "inGoodRoom"
when
$gr : GoodRoomConstraint($a : admission, $r : room, $w :
weight);
$ps : PatientStay(admission == $a, bed.room == $r);
then
insertLogical(new
IntConstraintOccurrence("inGoodRoom",ConstraintType.NEGATIVE_SOFT,10*$w,$ps));

end

rule "calcScore"
salience -10
when
$count : Number() from accumulate(
IntConstraintOccurrence($w : weight) ,

 sum($w) );
then
scoreCalculator.setScore(-$count.doubleValue());
end

The classes with **Constraint in it are possible combinations that cause a
constraint to be violated, and are calculated and inserted at initialization
time (and are never changed). I know that the rule
"patientsToBeAssignedToRoomsOfAppropriateSex" is fairly complex, but even
when I remove it, the performance is not fantastic. Is there anything else I
can do to get better performance? I'm already using JDK 1.6 and -server
mode. Furthermore, all classes used here have their default equals and
hashCode methods, so they don't have an impact on performance.

Sincerely,

Wim Vancroonenburg
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Drools Performance

2009-02-11 Thread Ashish Soni
Hi All ,

I am not sure if this question is asked previously but it would be great if
any one can put some lights on this ..

If i have 10,000 rules with same priority or equal priority then how drools
engine evaluate them or what is the path it chooses.

Also if there any performance metrics available ,please point to the links.


Thanks and Regards,
Ashish soni
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Shadow facts

2009-02-11 Thread Edson Tirelli
   Dean,

   There are two unrelated things in here... the boolean flag for dynamic
facts means your fact supports the property change listeners and you don't
need to call modify() when you change an attribute. ShadowFacts are a
complete different thing that should be mostly transparent to users.
   If you can provide an example, it will be easier to help you.

[]s
Edson

2009/2/11 J Michael Dean 

> I am migrating from 4.07 to 5 and my previous DRL file does not function
> correctly;  I previousliy inserted facts with the dynamic Boolean set true.
>  I understand that this is no longer done because shadow facts are "not
> needed" in Drools 5, but is it necessary to do anything different in the RHS
> when modifying facts?  My fact POJOs have a method for adding text to
> themselves.  I believe my rules are not working properly because nothing is
> being modified - only the initial activation set fires and then nothing
> happens.
>
> Restated, the documentation talks about how to "avoid" shadow facts in
> Drools 4.07 - are the restrictions in this part of the docs necessary in
> Drools 5?
>
> Thanks.
> ___
> rules-users mailing list
> rules-users@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@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Shadow facts

2009-02-11 Thread J Michael Dean
I am migrating from 4.07 to 5 and my previous DRL file does not  
function correctly;  I previousliy inserted facts with the dynamic  
Boolean set true.  I understand that this is no longer done because  
shadow facts are "not needed" in Drools 5, but is it necessary to do  
anything different in the RHS when modifying facts?  My fact POJOs  
have a method for adding text to themselves.  I believe my rules are  
not working properly because nothing is being modified - only the  
initial activation set fires and then nothing happens.


Restated, the documentation talks about how to "avoid" shadow facts in  
Drools 4.07 - are the restrictions in this part of the docs necessary  
in Drools 5?


Thanks.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users