Semantic Web Drools Module, Request for Feedbak
by Xavier Breton
Hi,
I'm looking for feedback, I'll develop a Semantic Web Drools Module that
will be the subject of my Master Degree Tesis.
The idea is to use Eclipse Modelling Framework (EMF) for prototyping and
follow a Model Driven Architecture (MDA) where the source language is
Semantic of Business Vocabularies and Business Rules (SBVR) and the target
language is Drools DRL.
The mapping could be (PIM level):
- Semantic Web Rule Language (SWRL)
- Ontology Web Language (OWL)
- RuleML
- Rule Interchange Format (RIF)
- REWERSE Rule Markup Language (R2ML)
It could be added to the module at the source UML or Entity Relationship
like models to transform the models into SBVR.
Regards
Xavier Breton
10 years, 10 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...
11 years, 3 months
Data model oracle is moving to drools project
by Toni Rikkola
Hi,
Data model oracle codes are moving to drools project. Since Jenkins does
not build everything that fast, it is possible that the project
depending on DMO will break. Building droolsjbpm-build-bootstrap, guvnor
and kie-wb-commons locally will fix any issues related to this.
Toni Rikkola
11 years, 3 months
Drools and GWT Application integration
by Moses Kalema
Hello everyone,
I recently started using Drools Guvnor and i find it necessary. I create
rules on Guvnor and fire the rules in a Java application and everything is
fine.
However when i try to access the rules in a GWT application,i get an error
which looks like none of the Drools code is executed.
My request is if any one has used rules n a GWT application please help me
out
--
Moses Kalema
Bachelor Science in Computer Engineering
Software/Mobile/Embedded Systems Developer
+256773391723
+256704209937
Skype: mkgremo
Twitter: @mkgremo
"Life's Success is based on Opportunity not Chance"
11 years, 3 months
Drools doesn't works with latest beta releases of Java 8
by fcuenca
I'm using Drools 5.4.0 with Java 8 beta 89 and all works perfect. Very simple
use of Drools:
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("CFL_Advisor.dsl",
getClass() ), ResourceType.DSL);
kbuilder.add( ResourceFactory.newClassPathResource( "CFL_Advisor.dslr",
getClass() ), ResourceType.DSLR );
Now I've just upgraded to Java 8 beta 104 and Drools stopped working. I have
tried with Java 8 beta 101 with the same error. I have tried also with
Drools 5.5.0 and Drools 6.0.0 RC3 and the error is the same.
Java 8 beta 89 works also well for all the previous Drools versions.
I need to use lastest Java 8 beta releases because we are developing an
experimental system that needs last releases of Java FX. And I suppose that
it is important that Drools (any versión) will support Java 8.
I get this error:
Exception in thread "main" java.lang.RuntimeException: wrong class format
at
org.drools.commons.jci.compilers.EclipseJavaCompiler$2.findType(EclipseJavaCompiler.java:263)
at
org.drools.commons.jci.compilers.EclipseJavaCompiler$2.findType(EclipseJavaCompiler.java:203)
at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:102)
at
org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:49)
at
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:122)
at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromTypeSignature(LookupEnvironment.java:1188)
at
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.cachePartsFrom(BinaryTypeBinding.java:317)
at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:640)
at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:619)
at org.eclipse.jdt.internal.compiler.Compiler.accept(Compiler.java:295)
at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:107)
at
org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:49)
at
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:122)
at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getTypeFromTypeSignature(LookupEnvironment.java:1188)
at
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.createFields(BinaryTypeBinding.java:355)
at
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.cachePartsFrom(BinaryTypeBinding.java:326)
at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:640)
at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createBinaryTypeFrom(LookupEnvironment.java:619)
at org.eclipse.jdt.internal.compiler.Compiler.accept(Compiler.java:295)
at
org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:107)
at
org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:49)
at
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:122)
at
org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.resolve(ParameterizedTypeBinding.java:851)
at
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.resolveType(BinaryTypeBinding.java:100)
at
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.superclass(BinaryTypeBinding.java:1062)
at
org.eclipse.jdt.internal.compiler.lookup.Scope.findMethod(Scope.java:1256)
at
org.eclipse.jdt.internal.compiler.lookup.Scope.findMethod(Scope.java:1181)
at org.eclipse.jdt.internal.compiler.lookup.Scope.getMethod(Scope.java:2237)
at
org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:401)
at
org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:357)
at
org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:913)
at
org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:447)
at
org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:189)
at
org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:406)
at
org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1131)
at
org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1219)
at
org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:528)
at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:759)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:464)
at
org.drools.commons.jci.compilers.EclipseJavaCompiler.compile(EclipseJavaCompiler.java:389)
at
org.drools.commons.jci.compilers.AbstractJavaCompiler.compile(AbstractJavaCompiler.java:49)
at
org.drools.rule.builder.dialect.java.JavaDialect.compileAll(JavaDialect.java:371)
at
org.drools.compiler.DialectCompiletimeRegistry.compileAll(DialectCompiletimeRegistry.java:46)
at org.drools.compiler.PackageRegistry.compileAll(PackageRegistry.java:102)
at org.drools.compiler.PackageBuilder.compileAll(PackageBuilder.java:1006)
at
org.drools.compiler.PackageBuilder.compileAllRules(PackageBuilder.java:842)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:831)
at
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:467)
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:673)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:45)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:34)
at es.indra.ifocucs.drools.CflAdvisor.getKnowledgeBase(CflAdvisor.java:28)
at es.indra.ifocucs.drools.CflAdvisor.(CflAdvisor.java:52)
at es.indra.ifocucs.drools.CflAdvisor.main(CflAdvisor.java:79)
Caused by: org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException
at
org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.(ClassFileReader.java:372)
at
org.drools.commons.jci.compilers.EclipseJavaCompiler$2.createNameEnvironmentAnswer(EclipseJavaCompiler.java:287)
at
org.drools.commons.jci.compilers.EclipseJavaCompiler$2.findType(EclipseJavaCompiler.java:258)
... 53 more
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-doesn-t-works-with-latest-beta-r...
Sent from the Drools: Developer (committer) mailing list mailing list archive at Nabble.com.
11 years, 3 months