How To Implement Rule Flow
by neerajs20
Hi All,
I am new to drools and guvnor. I have basic question for rule flow.
I have created 3 rules using guided editor on guvnor plugin. Now I want to
invoke the 2nd or 3rd rule based on the outcome of 1st rule.
e.g. If the patient's age is less than 18 go for 2nd rule for minor checks
otherwise invoke 3rd rule for check from senior physician.
So can this be achieved using rule flow? If yes how? Is there any example
links, documents demonstrating it? Any help very much appreciated.
Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/How-To-Implement-Rule-Flow-tp4025932.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 5 months
Optaplanner rules error
by SNELS Nick
Hi,
I have the following Drools rule in Optaplanner:
rule "oneShiftPerDay"
when
$leftAssignment : ShiftAssignment($leftId : id, $employee : employee, $shiftDate : shiftDate, employee != null)
$rightAssignment : ShiftAssignment(employee == $employee, shiftDate == $shiftDate, id > $leftId)
then
scoreHolder.addHardConstraintMatch(kcontext, -1);
end
But when I run the solver I get the following error:
09:02:46.128 [main] ERROR o.d.c.k.b.impl.AbstractKieModule - Unable to build KieBaseModel:defaultKieBase
Error importing : 'be.comp.permanenties.domain.solver.EmployeeAssignmentTotal'
Error importing : 'be.comp.permanenties.domain.solver.EmployeeWorkSequence'
Rule Compilation error : [Rule name='oneShiftPerDay']
be/comp/permanenties/solver/Rule_oneShiftPerDay544009415.java (2:220) : Only a type can be imported. be.comp.permanenties.domain.solver.EmployeeWorkSequence resolves to a package
be/comp/permanenties/solver/Rule_oneShiftPerDay544009415.java (2:978) : Only a type can be imported. be.comp.permanenties.domain.solver.EmployeeAssignmentTotal resolves to a package
How can I solve this error? Thanks.
Kind regards,
Nick
[http://www.ocmwturnhout.be] <http://www.ocmwturnhout.be>
Dit bericht is onderworpen aan de bepalingen van onze disclaimer<http://www.ocmwturnhout.be/nl/content/2436>
12 years, 5 months
performance of ruleflowGroup
by ashish6276
Hi
I am exploring ruleflow. Can somebody help me in knowing how
RuleFlOWGROUP affects the performance of rules. Say i have 1 lakh rules.
what will be difference in performance if i keep all rules without any group
and if i group rules in diff small small ruleflowgroup and then create a
processflow to execute the flow in such a way where selected ruleflowgroup
will be used based on condition defined in process flow.
--
View this message in context: http://drools.46999.n3.nabble.com/performance-of-ruleflowGroup-tp4026085....
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 5 months
Indicating "used" rules
by Andrzej Grzelak
Hello again,
Im making some kind of expert system. And now i got new problem:
User is asked sequentially for propetieries of object, than I modify object
propetieries, then i call update() and fireAllRules() to check for any
answers.
It is repeated for every object property till we fire rule with answer.
Now problem comes : When user decline answer we need to find another one.
But first answer will fire every time now. That's not what i need....
Making somewhere in app list of "false answers" and then striping out them
on return wont work. My app flow is determined by drools rule fire - if one
of "answer rules" fires i return that answer, normally i would ask another
question.
I would need to indicate drools somehow to delete/deactivate that rule.
Thanks for any help.
12 years, 5 months
Declared Types and Globals in different files with incremental KnowledgeAgent
by De Rooms Brecht
Dear Drools Users,
I am building a network server for drools since the existing
drools-server did not meet my requirements. Since I recently found a
bug and find the people here very helpful I'll try to explain another
issue I encountered in the hope that it improves drools 5.6 and 6.0.
I noticed that declared types and globals don't seem to be found when
you access them from a rule that was written in a different file. For
the declared types I hacked around this issue by preprocessing the files
and placing every declared type at the top of each file that needs it.
For globals this is of course not possible.
An example is shown below. File1 is loaded from the moment the agent
starts up, then file2 is loaded.
There is a difference when the knowledgeAgent detects the two files at
once or one by one. In this case the KnowledgeAgent detects one file and
then a few minutes later the other file and compiles them completely
separately.
The idea is to keep how many rules are matched of a certain type in a
global.
* FILE1: global_rules_matches.drl
----------------------------------------------
package ellipsoidfacts
// declare
global Integer RULES_MATCHED;
// initialize global
rule "initRULESMATCHED"
salience 999
when
then
RULES_MATCHED = 0;
end*
* FILE2: testrule.drl
----------------------------------------------
package ellipsoidfacts
rule "Gesture_lefthook"
when
// ... any precedent rules ...
then
System.out.println("matched gesture: lefthook"+ RULES_MATCHED);
end*
In this particular case, my rule is not matched. I load these rules
using a changeset xml, my knowledgeagent is set to incremental (but
either doesnt work).
The same happens when I declare types in FILE1 and use them in FILE2.
When I write the type declaration in both files it works perfectly.
Being the same package I assumed that these two scenarios should work.
Am I doing something wrong or is the agent not supposed to work like
this and should a package be in one file?
Kind Regards,
De Rooms Brecht
12 years, 5 months
Exception in thread "main" java.lang.ClassCastException: org.drools.io.impl.FileSystemResource cannot be cast to org.drools.io.InternalResource
by poonam.ligade@wipro.com
Hi,
I am getting below error:
Exception in thread "main" java.lang.ClassCastException: org.drools.io.impl.FileSystemResource cannot be cast to org.drools.io.InternalResource
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:487)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:25)
at SimpleRule.createKnowledgeBase(SimpleRule.java:87)
at SimpleRule.main(SimpleRule.java:32)
Can you please help.
Its urgent.
Thanks,
Poonam.
Please do not print this email unless it is absolutely necessary.
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
www.wipro.com
12 years, 5 months
Guvnor 5.5 Final: Can I restrict LOGIN Attempts by user
by Zahid Ahmed
Hi,
I have a requirement to restrict login attempts to Guvnor to prevent BruteForceAttacks. For authentication I am using JAAS authentication with Guvnor.
Is there any option in Guvnor/Seam/JAAS to configure such requirement ?
E.g., A user can try a maximum of 3 unsuccessful attempts for login. If user fails in all 3 login attempts then the user has to wait for 5 minutes.
My Environment :
1. JBOSS EAP 6.1.0
2. Drools-Guvnor 5.5.0-Final;
Thanks and Best Regards,
¬
Zahid Ahmed
Senior Software Engineer | Emirates Group IT
P.O. Box 686 | Dubai, United Arab Emirates
T +971 4 203 3912| M +971 55 124 9171
12 years, 5 months
Pluggable Belief Systems in Drools 6.0
by Mark Proctor
http://blog.athico.com/2013/09/pluggable-belief-systems-in-drools-60.html
---
Drools has supported simple truth maintenance for a long time, and followed a similar approach as that in Jess and Clips.
In 6.0 we abstracted the TMS system to allow for pluggable belief systems. This allows a sub system to control what the main working memory can see; i.e. what is inserted for the user to write rules to join against.
There are two interfaces for this the BeliefSystem and the BeliefSet. The BeliefSystem is global to the engine and provides the handling for logical inserts or deletes. It also has a constructor method to provide the LogicalDependency instance; this allows BeliefSystem to have it's own implementation.
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/jav...
The BeliefSet is the set of "equals" beliefs; i.e. logical insertions. If you remember in a TMS system a belief is a one or more logical insertions; but only one will ever be visible in the system. Logical means they have a supported rule, which is tracked by a counter. Only when there are no supporters and that counter is zero, is the belief deleted. We've extended this so a logical insertion have an additional value associated with it; which becomes useful in our JTMS implementation, that I'll cover in a moment.
We have a "simple" implementation, that emulates what we had in 5.x, and is still the default.
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/jav...
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/jav...
We've added am experimental JTMS implementation, which allows a logical insertion to have a positive or a negative label. This allows for contradiction handling. A logical insertion will only exist in the main working memory, as long as there is no conflict in the labelling - i.e. it must be one or more positive labels, and no minus label.
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/jav...
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/jav...
I've covered the bus pass system before, here. The code is still the same, the only difference now with the JTMS plugin is that each logical insertion defaults to a positive label.
rule "IsChild" when
p : Person( age < 16 )then
logicalInsert( new IsChild( p ) )end
rule "IsAdult" when
p : Person( age >= 16 )then logicalInsert( new IsAdult( p ) )end
rule "Issue Child Bus Pass" when p : Person( ) IsChild( person == p )then
logicalInsert(new ChildBusPass( p ) );end
rule "Issue Adult Bus Pass" when p : Person() IsAdult( person == p )then logicalInsert(new AdultBusPass( p ) );end
In the case of someone who is a child, it results in a tree that looks like below.
These are called your "default" rules. Now what happens if you want to add an exception, that contradicts the default rule. JTMS allows a negative insertion for a fact, doing this causes a conflict an the fact will be held in limbo, and not available in the working memory, until the conflict is resolved. For instance we might want an exception rule, that does not allow a bus pass to be issued to someone who is banned.
rule "Do not issue to banned people" when
p : Person( ) Banned( person == p )then
logicalInsert( new ChildBusPass( p ) , “neg” );end
If the person is banned, it results in a tree with one positive and one negative label. The belief system is incremental and cascading, so at any time the exception rule can become true which would result in a cascading undo operation.
We've also added another experimental implementation for Defeasible logic. Interestingly it turned out that Defeasible logic can be derived from the JTMS implementation, using the same BeliefSystem implementation but a custom BeliefSet implementation. The DefeasibleSet can be found here, clearly it is a lot more complicated than the JTMS one. We use mask operations to try and keep it optimal. We haven't added tracking for recursion yet, that is a TODO, and ideally done at compile time.
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/jav...
Defeasible augments the JTMS with annotations to provide declarative resolving of conflicts.
@Strict // rule cannot be defeated
@Defeasible // rule can be defeated
@Defeater // rule can defeat other rules, but it's result is not propagated into the working memory
@Defeats // takes list of rules it defeats
rule "Do not issue to banned people" @Defeasible when
p : Person( ) Banned( person == p )then
logicalInsert(new ChildBusPass( p ) , “neg” );end
rule "Exception for children with minor offences" @Defeats("Do not issue to banned people") when
p : Person( )
IsChild( person == p )
Banned( person == p, offence == "minor" )then
logicalInsert(new ChildBusPass( p ) );end
In defeasible logic the exception rule here is called a counter argument, and it is possible for another rule to rebut the counter-arguents, creating an argumentation chain, that rebuttal can also be rebutted. A good presentation on this can be found here.
We are currently working on other Belief System implementations. One is based on the Belief Logic Programmingidea, which uses the concepts of belief combination functions as inspired by Dempster-Shafer. This will allow each logical insertion to have a degree of belief, and the BeliefSystem will be able to process those chains of logical insertions, applying the combination functions.
The other idea we are working on is Bayesian network integration. The BeliefSystem can back onto a Bayesian network, which can control which facts are inserted, or not inserted, into the engine. As the data changes over time, the sub system can add or remove what the main engine sees.
If you find this interesting, and what to have a go at implementing your own and need some help, then don't hesitate to drop onto irc and ask:
http://www.jboss.org/drools/irc
While the system is pluggable, the registration process is currently hard coded into an Enum, which you'll need to update with your implementation:
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/jav...
12 years, 5 months
Question about VFS repository
by Carusyte Zhang
Anyone ever tried to use the VFS repository instead of the Guvnor
repository?
I'm stuck with issues not being able to find the sample bpmn2 file, which I
believe has something to do with this block of configurations in jbpm.xml
file:
<repository id="vfs">
<!-- acceptable attributes for parameter
name - name of the property
value - value of the property
system-property - (optional) if set tu true property will
> be set as JVM system property
-->
<!-- simple file system based vfs configuration -->
<parameter name="root" value="default:///tmp/designer-repo" />
>
<parameter name="globaldir" value="/global" />
<parameter name="name" value="Designer Repository"/>
<!-- git based cfs configuration-->
<!--<parameter name="root" value="git://designer-repo" />
<parameter name="globaldir" value="/global" />
<parameter name="username" value="guvnorngtestuser1" />
<parameter name="password" value="test1234" />
<parameter name="origin" value="
> https://github.com/mswiderski/designer-playground.git" />
<parameter name="fetch.cmd" value="?fetch" />
<parameter name="org.kie.nio.git.dir"
> value="/tmp/designer-git-repo" system-property="true"/> -->
</repository>
the 'root' parameter value 'default:///...' seems to be an invalid URI
path, causing the vfs stuff not being able to locate the file.
but I have no idea how to work around this, any kind of information about
this is greatly appreciated!
12 years, 5 months