[rules-users] Drools java program on Apple Ipad?

2011-03-18 Thread Jared Davis
I was just asked to investigate porting a drools based program to an Ipad.

Any ideas?

Regards,

Jared

--
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/Drools-java-program-on-Apple-Ipad-tp2699958p2699958.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] Memory Consumption with 5000 Rules

2010-12-09 Thread Jared Davis

I would try two different layouts and see what happens to memory usage. I
think the rules that use in will be faster than the standard matches
implementation.  

rule 1.in
when
$c_0 : CFRO( fi.co in (1,2,3,4,5),  su.co == P, c.co == C)
then
Bcf fact = new Bcf ();
fact.setC( 123);
insert( fact);
end


rule 1.matches
when
$c_0 : CFRO( fi.co matches (1|2|3|4|5),  su.co == P, c.co == C)
then
Bcf fact = new Bcf ();
fact.setC( 123);
insert( fact);
end



Regards,

Jared Davis
-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/Memory-Consumption-with-5000-Rules-tp2060449p2061395.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] Memory usage tied to rule report?

2010-10-07 Thread Jared Davis

Edson,

I'm using yEd for the graph viewer and tgf as the format for the graph. Here
is the mvel template to produce the tgf file. I left the topten name the
same for now. Did I miss any nodes or edges?

@declare{topten}
@code{
  buffer = new StringBuilder();
  for (ni : session.nodeInfos) {
buffer.append( ni.id);
buffer.append(  );
buffer.append( ni.node);
buffer.append( \r\n);
  }
  buffer.append( #\r\n);
  for (node : session.nodeInfos) {
for (child : node.sinkList) {
 buffer.append( node.id);
 buffer.append(  );
 buffer.append( child.id);
 buffer.append( \r\n);
}
  }
}
@{buffer.toString()}
@end{} 


I would like to change the toString representations for all of the classes
used in the graph.

I there a better structure than a bunch of instanceof tests? (Would they
even work?)

if (ni.node instanceof AlphaNode) {
  buffer.append(A: );
  if (ni.node.constraint instanceof  ...) {

Thanks again for your help.


-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/Memory-usage-tied-to-rule-report-tp1434387p1649379.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] Memory usage tied to rule report?

2010-10-05 Thread Jared Davis

Edson,

Thanks for the report. The top ten on the left was just what I needed to
track down the badly written rules. 

The 385 rules generate 823 documents using 2 facts.

My peak heap usage is now only 250mb. Before it would fail with a 1.2GB
heap.

Do you think this report is a good starting point to generate a graphML file
showing the same info as the text report?


Jared


-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/Memory-usage-tied-to-rule-report-tp1434387p1634480.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] matches doesn't catch rule.

2010-06-24 Thread Jared Davis

try

m:myObject(variable matches (WORD 1|WORD 2)) 
-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/matches-doesn-t-catch-rule-tp919334p919402.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] rule fires while condition is false

2010-05-06 Thread Jared Davis
Could the rules be changing the values outside of a modify block?



Please try this (untested) rule as a test. 

It binds the value on the left hand side.


 rule netRepaymentWithLiabilities1TEST
  agenda-group autoUnderwriting
  when
  ea: EnrichedApplicationVersionTO(amount :  
netRepaymentAmountAbilityIncludingLiabilities
 = 0.65)
  decision: Decision()
  then
  System.out.println(!!!  + amount + 
   !!!  + 
  ea.getNetRepaymentAmountAbilityIncludingLiabilities() );
  decision.setDecision(APPROVED, NetRepaymentWthLiblt);
 end



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


Re: [rules-users] rule fires while condition is false

2010-05-06 Thread Jared Davis


Shai wrote:
 
 --snip--
 I then do some more things and insert the value of NetRepayment value to 
 the EnrichedApplication, I re insert it to the workspace and then I run 
 the rules.
 It seems that drools did not re evaluate the EnrichedApplication again 
 and thus the value of NetRepayement as fas as it was concerned was 0.
 --snip--
 

For the rules engine to re-evaluate objects, you need to tell it when they
change. Even though the NetRepayment fact was updated in the engine, there
is no link defined in the rules engine between it and the
EnrichedApplication.  I'm assuming the calculation method
getNetRepaymentAmountAbilityIncludingLiabilities() uses this value.

Perhaps it would be worth investigating moving the method implementation to
a rule. If not, ensure that all object/variables used in the method do not
change once the EnrichedApplication is inserted. 


-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/rule-fires-while-condition-is-false-tp780685p781431.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] evaluation of null not consistent

2010-04-16 Thread Jared Davis

I don't follow this line in the rule:

instance_1_Track : Track($var_1_aou : aouAsFloat != null 
$var_3_platform_ptr : platform != null ) 

Should it be the following?

instance_1_Track : Track($var_1_aou : aouAsFloat != null ,
$var_3_platform_ptr : platform != null ) 
-- 
View this message in context: 
http://n3.nabble.com/evaluation-of-null-not-consistent-tp724910p725040.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] User and/or Code problem with insert/retract and salience

2010-03-30 Thread Jared Davis

I've narrowed it down to a smaller example. The order of insertion seems to
trump the rule salience.

The following rule inserts 4 objects.  Inserted as A4,A3,A2,A1 the rules
sequence is unexpected. Inserted A1,A3,A4,A2 they fire as expected.

rule setup.two
when 
then
  // generates out of salience rule execution
   insert (new RuleLink(A4, new Double(65), null));
   insert (new RuleLink(A3, new Double(70), null));
   insert (new RuleLink(A2, new Double(65), null));
   insert (new RuleLink(A1, new Double(70), null));

 /* // works ok
   insert (new RuleLink(A1, new Double(70), null));
   insert (new RuleLink(A3, new Double(70), null));
   insert (new RuleLink(A4, new Double(65), null));
   insert (new RuleLink(A2, new Double(65), null));
 */
end

Here are 3 of the 6 identical LHS rules differing only by salience
(70,65,60,55,50,0):
rule a70
salience 70
when 
 link:  RuleLink( linkName: name matches A., d : aasDouble) 
RuleLink( name == SKINS, partsO : a)
then
  System.out.println(START 070   + d);
  if ( d  69.9)  {
 System.out.println(drools.getRule().getName() +  retract  +
 linkName);
 retract(link);
  } else {
 System.out.println(drools.getRule().getName() +  no retract  +
 linkName);
  }
end

rule a65
salience 65
when 
 link:  RuleLink( linkName: name matches A., d : aasDouble) 
RuleLink( name == SKINS, partsO : a)
then
  System.out.println(START 065  + d);
  if ( d  64.9)  {
 System.out.println(drools.getRule().getName() +  retract  +
 linkName);
 retract(link);
  } else {
 System.out.println(drools.getRule().getName() +  no retract  +
 linkName);
  }
end

rule a60
salience 60
when 
 link:  RuleLink( linkName: name matches A., d : aasDouble) 
RuleLink( name == SKINS, partsO : a)
then
  System.out.println(***  ERROR  );
  System.out.println(START 060  + d);
  if ( d  59.9)  {
 System.out.println(drools.getRule().getName() +  retract  +
 linkName);
 retract(link);
  } else {
 System.out.println(drools.getRule().getName() +  no retract  +
 linkName);
  }
end

// One more setup rule

rule setup.one
when 
then
   List skinParts = new ArrayList();
   insert (new RuleLink(SKINS, skinParts, null));
end



Here is the test run:

START 070 70.0
a70 retract A1
START 070 65.0
a70 no retract A2
START 070 70.0
a70 retract A3
START 070 65.0
a70 no retract A4
START 065 65.0
a65 retract A2
  ERROR  
START 060 65.0
a60 retract A4

A4 never ran rule 065. It skipped to rule 060 from 070.

The error is very sensitive to other rules in the package.  

Is this the expected behavior?

(I would like to keep the reasons for a branch on the RHS vs an eval on the
LHS out of this discussion.)

-- 
View this message in context: 
http://n3.nabble.com/User-and-or-Code-problem-with-insert-retract-and-salience-tp685963p686283.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] Need Syntax help for a string match

2009-11-17 Thread Jared Davis
Here are two ways to write the regular expression.

 m : Customer( age matches (18|21|33|28|40|41))

 m : Customer( age matches (18|2[18]|33|4[01]))

Did you try

m : Customer( age in (18,21,33,28,40,41))
 


I don't know which solution is faster.  I think that would
be an interesting test.








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


Re: [rules-users] Performance is too bad when using matches predicate

2009-06-02 Thread Jared Davis


starsavari wrote:
 
 We are considering drool rule engine for data profiling (run the data
 through the various regex pattern for data analysis) on a large amount of
 data. We have rules to determine the SSN, Phone number, Driver license
 number, tracking number etc. Most of our rules are regex pattern matching.
 I've developed a sample program with 5 rules, all are pattern matching
 rules and running the rules against million facts/objects (each object has
 2 string fields). It takes around 58 seconds versus 2 seconds when I run
 the same thing with plain JAVA code. 
 
 


I ran into a similar issue but ran out of time before I could put together a
clean fix. Attached is a partial fix to TEST at your own risk. It basically
caches the regular expression instead of re-compiling it on every match.  It
has no limits on size so some might call it a memory leaker.
http://www.nabble.com/file/p23842739/MatchesEvaluatorsDefinition.java
MatchesEvaluatorsDefinition.java 




Check out thread
http://www.nabble.com/Help-with-MatchesEvaluatorsDefinition-that-caches-compiled-regular-expression-patterns-td23377792.html
-- 
View this message in context: 
http://www.nabble.com/Performance-is-too-bad-when-using-matches-predicate-tp23841498p23842739.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


[rules-users] Help with MatchesEvaluatorsDefinition that caches compiled regular expression patterns

2009-05-04 Thread Jared Davis
I need some help placing a cache of compiled regular expressions using the
MatchesEvaluatorsDefinition as a starting point.

Just for a test I placed a static map in the class:

static MapString,Pattern uglyHack = new HashMapString,Pattern();


Then in each of the evaluators I have different versions of:

Pattern p = uglyHack.get(value2);
if (p == null ) {
p = Pattern.compile(value2);
uglyHack.put(value2, p);
}
Matcher m = p.matcher(value1);
return m.matches();

instead of 


return value1.matches( value2 );


The time elapsed to inserting objects into the workspace has been cut in half.  

.4 seconds - .2

Has someone already done this optimization? Where should the cache be stored?




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


[rules-users] NullPointerException in SessionConfiguration

2009-03-27 Thread Jared Davis
Any advice on this NPE?  (March 20th snapshot of 5.00)

It occurs when a second thread attempts to create a session using a static
KnowledgeBase.

java.lang.NullPointerException
at org.drools.SessionConfiguration.initProcessInstanceManagerFactory
(SessionConfiguration.java:260)
at org.drools.SessionConfiguration.getProcessInstanceManagerFactory
(SessionConfiguration.java:249)
at 
org.drools.common.AbstractWorkingMemory.init(AbstractWorkingMemory.java:295)
at 
org.drools.common.AbstractWorkingMemory.init(AbstractWorkingMemory.java:239)
at org.drools.reteoo.ReteooWorkingMemory.init(ReteooWorkingMemory.java:85)
at org.drools.reteoo.ReteooStatefulSession.init(ReteooStatefulSession.java:67)
at org.drools.reteoo.ReteooRuleBase.newStatefulSession(ReteooRuleBase.java:325)
at org.drools.reteoo.ReteooRuleBase.newStatefulSession(ReteooRuleBase.java:310)
at org.drools.impl.KnowledgeBaseImpl.newStatefulKnowledgeSession
(KnowledgeBaseImpl.java:151)
at org.drools.impl.KnowledgeBaseImpl.newStatefulKnowledgeSession
(KnowledgeBaseImpl.java:134)

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


[rules-users] How to tell if rule is using eval internally

2009-03-26 Thread Jared Davis
How do you tell if a rule is using eval() without access to Eclipse?


The documentation states certain nested accessors will be re-written into eval
statements.


Regards,



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


[rules-users] Compiles in 4.07 not in 5.0 Snapshot (3/20)

2009-03-23 Thread Jared Davis
Hi,

This rule (not the best style) compiles fine in 4.07. It gives this error
message using 5.0 Snapshot. I changed some of the text to be generic so I could
post the code.

Rule Compilation error : [Rule name='A.B.inlet.mxb.first.link.20090216.01']
com/zz/yyy/awl/Rule_A_B_inlet_mxb_first_link_20090216_01_0.java
(11:5517) : The method insert(RuleLink) is undefined for the type
Rule_A_B_inlet_mxb_first_link_20090216_01_0


Here is the rule: (I had to change all the  to . to get gmane to accept the
email as a non top post)

rule A.B.inlet.mxb.first.link.20090216.01
agenda-group A.B
when 
 
. comp : XComponentRule( path == ~unit~mxb)
then
. Point3d l = new Point3d();
. comp.getBounds().getLower(l);

. if (l.x  1)  {
.insert( new RuleLink(FIRST.INLET , comp, comp) );
. } else {
.insert( new RuleLink(FIRST.INLET.NOT , comp, comp) );
. }
. 
end

If I change the rule to 

rule A.B.inlet.mxb.first.link.20090216.01
agenda-group A.B
when 
 
. comp : XComponentRule( path == ~unit~mxb)
then
. Point3d l = new Point3d();
. comp.getBounds().getLower(l);
. String name = FIRST.INLET;
. if (l.x  1)  {
.   // nothing
. } else {
.   name = FIRST.INLET.NOT;
. }
. insert( new RuleLink(name , comp, comp) );
. 
end

it compiles w/o a problem.





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


[rules-users] Re: DSL question: how to apply same conversion multiple times?

2008-11-11 Thread Jared Davis
Charles Binford Charles.Binford at Sun.COM writes:

 
 I'm using the DSL feature of 4.07 and am having trouble getting it to
 behave like I want.
 
 I have a File object where I'm always going to have a state
 constraint, plus one or more optional constraints based on user input. 
 (I'm parsing user data to generate the .dsrl file on the fly).
 
 Samples:
 file in 1.x state where uid == 0 where gid == 0
 Should turn into
$f: File ( classState == 1.x, uid == 0, gid == 0 )
 
 The key lines from my DSL file that do this are:
 [condition][]file in {state} state {constraints}=$f: File ( classState
 == {state} {constraints} )
 [condition][]where {constraint}=, {constraint}
 
 Unfortunately what I get is
$f: File ( classState == 1.x, uid == 0 where gid == 0 )
 
 If only have one where then all works fine.  If I add another
 [condition][]where {constraint}=, {constraint}
 line in my DSL file it works. The first DSL where line catches the
 first where uuid and the second DSL line catches the where gid.   On
 the current path it looks like I'll have to set a hard limit on how many
 constraints a user can specify and make sure I've dup'd the where line
 that many times in the DSL file.  Of course I'd much rather leave it
 open and have the single where line apply itself as many times as it can.
 
 Thanks in advance for any help.
 
 Charles Binford
 Sun Microsystems
 ___
 rules-users mailing list
 rules-users at lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users
 
 


Have you looked at using the - operation? It doesn't meet your one line goal,
but it works.

The rule would look like this:

file in 1.x state where
 - uid is 0
 - gid is 0
 - lastModified  


the dsl would follow this cheese example from the drools docs (I grabbed it from
4.03)

[when]There is a Cheese with=Cheese()
[when]- age is less than {age}=age{age}
[when]- type is '{type}'=type=='{type}'
[when]- country equal to '{country}'=country=='{country}'

Search the doc for the section Adding constraints to facts for more details.

HTH,

Jared Davis


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


[rules-users] Re: Best way to detect duplicate rule names?

2007-11-27 Thread Jared Davis
Mark Proctor mproctor at codehaus.org writes:

 
 At the moment no, we could expose a handler/even that allows the user to 
 add additional behaviour. For now your best way of doing this is to 
 augment the PackageBuilder with AOP.
snip

Mark,

Thank you for your help with my questions. We have implemented three
manufacturing modules using drools. One converts one part number to another (OEM
part - real part). The second manipulates the bill of material based on
customer requirements. The third drives a dynamic part drawing using a cad back
end. 

The drools rules look so much easier to maintain than the java code it replaces.

We are pre-processing the files to detect duplicate rule names. For our
application it was simpler than the AOP option.

Regards,

Jared




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


[rules-users] Best way to detect duplicate rule names?

2007-11-20 Thread Jared Davis
Hi,

What is the best way to detect duplicate rule names in drl files? In my
application a duplicate rule name is an error.

There are multiple drl files loaded into one package.  If the rule name is
duplicated across the files only the last rule is used. This behavior is clearly
documented.


The code below silently eats duplicated rules.

 Reader sourceDrl = new InputStreamReader(  new FileInputStream(r1.drl));
 Reader sourceDsl = new InputStreamReader(  new FileInputStream(r.dsl));
 Reader sourceDrlTwo = new InputStreamReader(  new FileInputStream(r2.drl));
 Reader sourceDslTwo = new InputStreamReader(  new FileInputStream(r.dsl));
  
 PackageBuilder builder = new PackageBuilder();
 builder.addPackageFromDrl( sourceDrl, sourceDsl );
 builder.addPackageFromDrl( sourceDrlTwo, sourceDslTwo );
 System.out.println(builder.hasErrors()); // returns false 
// A duplicate rule is not an error
 Package pkg = builder.getPackage();


Is there a better alternative than loading each drl into a separate
PackageBuilder to track the individual rule counts in each drl file?

eg

 PackageBuilder builder = new PackageBuilder();
 builder.addPackageFromDrl( sourceDrl, sourceDsl );
 int ruleCountOne = builder.getPackage().getRules().length;

 PackageBuilder builderTwo = new PackageBuilder();
 builderTwo.addPackageFromDrl( sourceDrlTwo, sourceDslTwo );
 int ruleCountTwo = builderTwo.getPackage().getRules().length;

 // now re-compile file (reset readers as well...)

 builder.addPackageFromDrl( sourceDrlTwo, sourceDslTwo );
 if (builder.getPackage().getRules().length != (ruleCountOne + ruleCountTwo)) {
   System.out.println(A duplicate exists - No clue what the name is); 
   // grep -i rule *.drl | sort | uniq -c
 }

This does not detect a duplicate rule name in the same file - that would be even
better.

Regards,

Jared Davis


 


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


[rules-users] Is InternalRuleBase safe to use?

2007-11-14 Thread Jared Davis
Hi,

re:Drools 4.0.3

 I want/need to use ConsequenceExceptionHandler for exception handling.
 I'd like to be able to get the ConsequenceExceptionHandler from a 
StatefulSession. 

The only way I see to get the handler relies on InternalRuleBase. 
The JavaDoc at http://downloads.jboss.com/drools/docs/_
4.0.3.15993.GA/apidocs/org/drools/common/InternalRuleBase.html
does not have any annotation that it is internal use only. However the naming
convention sure makes me this this is a bad idea. 

Any alternatives to the following code to retrieve the 
ConsequenceExceptionHandler?


InternalRuleBase thisSmellsLikeABadIdea= (InternalRuleBase) wm.getRuleBase();
DroolsExceptionHandler deh = (DroolsExceptionHandler)
thisSmellsLikeABadIdea.getConfiguration().getConsequenceExceptionHandler();
ListException exceptions = deh.getExceptions();

(Where DroolsExceptionHandler is 

package droolsconfig;

import java.util.ArrayList;
import java.util.List;
import org.drools.WorkingMemory;
import org.drools.spi.Activation;
import org.drools.spi.ConsequenceExceptionHandler;


public class DroolsExceptionHandler implements ConsequenceExceptionHandler {
ListException exceptions = new ArrayListException();
   
public DroolsExceptionHandler() {
}

public void handleException(Activation activation, WorkingMemory
workingMemory, Exception exception) {
exceptions.add(exception);
}
public ListException getExceptions() {
return exceptions;
}

}

)


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