Extending the "validation of rules" functionality in Guvnor
by Premkumar Stephen
Hello everyone,
Currently, the validate functionality ensures that rules have proper
syntax.
it is possible to extend this functionality so that business use cases might
also be validated? Is there an API/examples to do that.
For eg, in our domain, an object X can be evaluated for 3 criteria ( a, b,
c )
However, we would need to prevent rules written which combine criteria b and
c
Rules can have the combinations ( a,b,c, ab, ac ). Combinations ( bc and abc
) should not be allowed.
Regards,
Prem
14 years, 8 months
Issue with drools-flow/persistence
by Daniel Ilkovich
I'm stumped. I'm trying to implement persistence with Drools-flow, and I'd
like to grab the value of a property on a workitem / processinstance, but
everytime I try to get the workitem or process instance I end up with the
stack trace below.
I'm walking through the source and from what I can tell, this happens
anytime I try and grab a property that is annotated with @Lob in an entity
class.
My environment is hibernate/mysql/JPA persistence using BTM as a transaction
manager.
These are the relevant lines of code:
ksession =
JPAKnowledgeService.loadStatefulKnowledgeSession(ksession.getId(), m_kbase ,
null, m_environment);
m_pi = ksession.getProcessInstance(m_pi.getId());
What am I doing wrong?
<pre>
<code>
java.lang.NullPointerException
at java.io.ByteArrayInputStream.<init>(ByteArrayInputStream.java:89)
at
org.drools.persistence.processinstance.ProcessInstanceInfo.getProcessInstance(ProcessInstanceInfo.java:135)
at
org.drools.persistence.processinstance.JPAProcessInstanceManager.getProcessInstance(JPAProcessInstanceManager.java:62)
at
org.drools.common.AbstractWorkingMemory.getProcessInstance(AbstractWorkingMemory.java:1793)
at
org.drools.impl.StatefulKnowledgeSessionImpl.getProcessInstance(StatefulKnowledgeSessionImpl.java:261)Hibernate:
select at
org.drools.command.runtime.process.GetProcessInstanceCommand.execute(GetProcessInstanceCommand.java:29)
at
org.drools.command.runtime.process.GetProcessInstanceCommand.execute(GetProcessInstanceCommand.java:12)
at
org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:254)
at
org.drools.command.impl.CommandBasedStatefulKnowledgeSession.getProcessInstance(CommandBasedStatefulKnowledgeSession.java:95)
at
com.thoughtvine.tracks.workflow.TracksFlow.getParameterFromWorkItem(TracksFlow.java:182)
at
com.thoughtvine.tracks.workflow.test.TestTracksFlow.testGetWorkItem(TestTracksFlow.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
</code>
</pre>
14 years, 8 months
Performance of compiler
by Christian Nedregård
Hi.
My environment: Win XP SP3, 2x2.13 GHz cpu, 3GB RAM, Drools 4.0.7, JDK
1.4.2_11, java compiler: JANINO, dialect: java.
We have about 850 drl's with 5 - 10 conditions in each. 0 -2 evals in each.
The drl's only contain one rule each.
We are using Drools programatically by compiling the drls using
PackageBuilder.addPackageFromDrl and adding them to a RuleBase using
RuleBase.addPackage(PackageBuilder.getPackage())
When we are building our rule base we are never able to compile more than 1
-2 rules per second, which means we need over 10 minutes (at 100% cpu) to
build our rulebase.
Profiling shows 68% cpu time in
org.drools.rule.builder.GroupElementBuilder.build and 18% cpu time in
org.codehaus.janino.Compiler.compile.
We have experimented by changing the compiler to ECLIPSE and the dialect to
mvel but the results are the same.
We have experimented using one PackageBuilder instance per drl or grouping
drls by package and sharing a builder per package. Same result in both
scenarios.
We have also expermimented with compiling concurrently in serveral threads.
Again, about the same result.
My question is: Is this the performance we can expect from the compiler or
are we doing something fundamentally wrong?
Below is an example of one of our drls. This one contains no evals, but
still takes more than 1 second to compile. If anyone can spot some issues
with the way we are doing things the feedback would be much apreciated :)
------------------------------------
package domain.core.productoffer.rules.subscriptiontype
import type.productoffer.ProductOfferRuleEvent
import domain.core.subscription.Subscription
import domain.core.subscription.SubscribedService
import type.subscription.ActionTypeEnum
import domain.core.productoffer.ProductOffer
import domain.rules.RuleEvent
global domain.core.productoffer.RuleValidationReport validationResult
rule "RequiredVProducts"
when
ProductOfferRuleEvent(id == '3')
ProductOffer(id.value == 31963)
$subscription:Subscription()
not ( SubscribedService(status != ActionTypeEnum.REMOVE_CANCEL &&
productId.value in (57, 69) ) from
$subscription.getAllChildSubscribedServices())
then
validationResult.addValidationMessage("2069", "For product offer
rule event with id '3' and product offer with id=31963 subscription must
have one of the following VProducts: 57, 69.");
end
------------------------------------
Regards
Christian Nedregård
14 years, 9 months
Call class method from LHS of a rule
by orchid
Hi All,
I'm trying to call a class method from the LHS of a rule in the following
way:
public class Cheese{
private string type;
//setters and getters
public boolean existsInShop(String shop){
...
return true;
}
}
I would like to call the method "existsInShop" from a rule:
Rule "Rule1"
when
$c:Cheese(type == "chedar", existsInShop "shopName")
then
System.out.println("Rule1 is fired");
end
I get the compilation error: "no viable alternative at input "shopName" in
rule "Rule1" in pattern document". How can I call the method from the rule?
Thanks in advance.
--
View this message in context: http://n3.nabble.com/Call-class-method-from-LHS-of-a-rule-tp108383p108383...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 9 months
Task Server gives error cannot use getTransaction()
by Todd Pagni
When I configure the Task Server(org.drools.task) to be JTA I get the
following error when adding a Human Task work item. Is the following
Persistence Unit configuration valid? It works when the org.drools.task
trans type is set to LOCAL_RESOURCE.
Using drools 5.1.0.M1 in JBoss 5.1
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence version="1.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="org.drools.persistence.jpa"
transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/processInstanceDS</jta-data-source>
<mapping-file>META-INF/orm.xml</mapping-file>
<class>org.drools.persistence.session.SessionInfo</class>
<class>org.drools.persistence.processinstance.ProcessInstanceInfo</class
>
<class>org.drools.persistence.processinstance.WorkItemInfo</class>
<class>org.drools.persistence.processinstance.variabletypes.JPAPersisted
Variable</class>
<class>org.drools.persistence.processinstance.variabletypes.VariableInst
anceInfo</class>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.SQLServerDialect" />
<property name="hibernate.max_fetch_depth" value="3"
/>
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="update"
/>
<property name="hibernate.connection.release_mode"
value="auto" />
<property
name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.JBossTransactionManagerLookup" />
<property
name="jboss.entity.manager.factory.jndi.name"
value="java:/WorkflowServerPU" />
</properties>
</persistence-unit>
<persistence-unit name="org.drools.task" transaction-type="
RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/processInstanceDS</jta-data-source>
<mapping-file>META-INF/taskorm.xml</mapping-file>
<class>org.drools.task.Attachment</class>
<class>org.drools.task.Content</class>
<class>org.drools.task.BooleanExpression</class>
<class>org.drools.task.Comment</class>
<class>org.drools.task.Deadline</class>
<class>org.drools.task.Comment</class>
<class>org.drools.task.Deadline</class>
<class>org.drools.task.Delegation</class>
<class>org.drools.task.Escalation</class>
<class>org.drools.task.Group</class>
<class>org.drools.task.I18NText</class>
<class>org.drools.task.Notification</class>
<class>org.drools.task.EmailNotification</class>
<class>org.drools.task.EmailNotificationHeader</class>
<class>org.drools.task.PeopleAssignments</class>
<class>org.drools.task.Reassignment</class>
<class>org.drools.task.Status</class>
<class>org.drools.task.Task</class>
<class>org.drools.task.TaskData</class>
<class>org.drools.task.SubTasksStrategy</class>
<class>org.drools.task.OnParentAbortAllSubTasksEndStrategy</class>
<class>org.drools.task.OnAllSubTasksEndParentEndStrategy</class>
<class>org.drools.task.User</class>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.SQLServerDialect" />
<property name="hibernate.max_fetch_depth" value="3"
/>
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="update"
/>
<property name="hibernate.connection.release_mode"
value="auto" />
<property
name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.JBossTransactionManagerLookup" />
<property
name="jboss.entity.manager.factory.jndi.name"
value="java:/WorkflowServerPU" />
</properties>
</persistence-unit>
</persistence>
10:48:22,887 INFO [STDOUT] Hibernate: update WorkItemInfo set
creationDate=?, name=?, processInstanceId=?, state=?, OPTLOCK=?,
workItemByteArray=? where workItemId=? and OPTLOCK=?
10:48:22,887 INFO [STDOUT] [2010:01:20 10:01:887:debug] Message
receieved on server : AddTaskRequest
10:48:22,887 INFO [STDOUT] [2010:01:20 10:01:887:debug] Arguments :
[org.drools.task.Task@537c3c9e,
org.drools.task.service.ContentData@b2a90]
10:48:22,887 INFO [STDOUT] [2010:01:20 10:01:887:exception] A JTA
EntityManager cannot use getTransaction()
10:48:22,887 INFO [STDOUT] java.lang.IllegalStateException: A JTA
EntityManager cannot use getTransaction()
10:48:22,887 INFO [STDOUT] at
org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction(AbstractEntit
yManagerImpl.java:324)
10:48:22,887 INFO [STDOUT] at
org.drools.task.service.TaskServiceSession.doOperationInTransaction(Task
ServiceSession.java:676)
10:48:22,887 INFO [STDOUT] at
org.drools.task.service.TaskServiceSession.addTask(TaskServiceSession.ja
va:118)
10:48:22,887 INFO [STDOUT] at
org.drools.task.service.TaskServerHandler.messageReceived(TaskServerHand
ler.java:88)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.message
Received(DefaultIoFilterChain.java:752)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageRec
eived(DefaultIoFilterChain.java:414)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(Defaul
tIoFilterChain.java:49)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messag
eReceived(DefaultIoFilterChain.java:832)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputIm
pl.flush(ProtocolCodecFilter.java:379)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(Protoco
lCodecFilter.java:173)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageRec
eived(DefaultIoFilterChain.java:414)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(Defaul
tIoFilterChain.java:49)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messag
eReceived(DefaultIoFilterChain.java:832)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.filter.logging.LoggingFilter.messageReceived(LoggingFilt
er.java:95)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageRec
eived(DefaultIoFilterChain.java:414)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(Defaul
tIoFilterChain.java:49)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messag
eReceived(DefaultIoFilterChain.java:832)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain$HeadFilter.message
Received(DefaultIoFilterChain.java:616)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageRec
eived(DefaultIoFilterChain.java:414)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceive
d(DefaultIoFilterChain.java:408)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPol
lingIoProcessor.java:578)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(Abstract
PollingIoProcessor.java:540)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(Abstract
PollingIoProcessor.java:532)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(Abstr
actPollingIoProcessor.java:58)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.polling.AbstractPollingIoProcessor$Worker.run(Abstr
actPollingIoProcessor.java:857)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.j
ava:51)
10:48:22,887 INFO [STDOUT] at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecuto
r.java:651)
10:48:22,887 INFO [STDOUT] at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.ja
va:676)
10:48:22,887 INFO [STDOUT] at java.lang.Thread.run(Thread.java:595)
10:48:22,887 ERROR [STDERR] java.lang.IllegalStateException: A JTA
EntityManager cannot use getTransaction()
10:48:22,887 ERROR [STDERR] at
org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction(AbstractEntit
yManagerImpl.java:324)
10:48:22,887 ERROR [STDERR] at
org.drools.task.service.TaskServiceSession.doOperationInTransaction(Task
ServiceSession.java:676)
10:48:22,887 ERROR [STDERR] at
org.drools.task.service.TaskServiceSession.addTask(TaskServiceSession.ja
va:118)
10:48:22,887 ERROR [STDERR] at
org.drools.task.service.TaskServerHandler.messageReceived(TaskServerHand
ler.java:88)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.message
Received(DefaultIoFilterChain.java:752)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageRec
eived(DefaultIoFilterChain.java:414)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(Defaul
tIoFilterChain.java:49)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messag
eReceived(DefaultIoFilterChain.java:832)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputIm
pl.flush(ProtocolCodecFilter.java:379)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(Protoco
lCodecFilter.java:173)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageRec
eived(DefaultIoFilterChain.java:414)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(Defaul
tIoFilterChain.java:49)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messag
eReceived(DefaultIoFilterChain.java:832)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.filter.logging.LoggingFilter.messageReceived(LoggingFilt
er.java:95)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageRec
eived(DefaultIoFilterChain.java:414)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(Defaul
tIoFilterChain.java:49)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messag
eReceived(DefaultIoFilterChain.java:832)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain$HeadFilter.message
Received(DefaultIoFilterChain.java:616)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageRec
eived(DefaultIoFilterChain.java:414)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceive
d(DefaultIoFilterChain.java:408)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPol
lingIoProcessor.java:578)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(Abstract
PollingIoProcessor.java:540)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(Abstract
PollingIoProcessor.java:532)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(Abstr
actPollingIoProcessor.java:58)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.polling.AbstractPollingIoProcessor$Worker.run(Abstr
actPollingIoProcessor.java:857)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.j
ava:51)
10:48:22,887 ERROR [STDERR] at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecuto
r.java:651)
10:48:22,887 ERROR [STDERR] at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.ja
va:676)
10:48:22,887 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
10:48:22,903 INFO [LoggingFilter] SENT: HeapBuffer[pos=0 lim=2200
cap=4096: 00 00 08 94 AC ED 00 05 73 72 01 00 1F 6F 72 67...]
10:48:22,903 INFO [LoggingFilter] SENT: HeapBuffer[pos=0 lim=0 cap=0:
empty]
10:48:22,903 INFO [STDOUT] [2010:01:20 10:01:903:debug] Message
receieved on client : AddTaskResponse
10:48:22,903 INFO [STDOUT] [2010:01:20 10:01:903:debug] Arguments :
[java.lang.IllegalStateExcep
14 years, 9 months
Re: [rules-users] [planner] Questions about employee shift rostering example
by Geoffrey De Smet
[CC'd to the user list]
Hi Samuel,
> Happy new year and all the best for you and your family.
Happy new year too :)
> As you can see below, I tried posting a message on the mailing list but
> unfortunately I am not authorized.
If that doesn't work out (it should!), try the nabble.com forum or the
gmane.org newsgroup:
http://n3.nabble.com/Drools-User-f47000.html
I use gmane.org myself from Thunderbird.
> Geoffrey, I saw a paper on the trunk of drools planner where you address
> the issue about employee shift rostering.
> There is no source, I don't know what level of thinking you're in, but I
> have two questions:
>
I haven't made an example of employee shift rostering (or bin packaging
or vehicle routing) yet.
Employee shift rostering is closely related too curriculum course
scheduling,
so I advice to get to know the curriculum course example inside and out :)
Drools (Planner) is kinda like JPA:
you can model your domain pretty much how you like,
but how you model your domain can impact the complexity of your rules (~
JPA-QL's).
Don't make your domain too smart to help your first rules,
because it will strangle rules (and even moves) you implement later.
Keep your domain on low level details.
> "Each shift has for each specialism a minimal staff size"
> how do you manage the team size ?
> Is there a list of people in the Shift object ? Or an accumulate function
> in the rule ?
>
I'd say: experiment with both and let me know which works best :)
Until now, I 've always gone for the "accumulate function in a rule" manner.
I strongly believe in keeping the domain diagram very simple:
http://beta.parleys.com/#id=1714&st=5&sl=14
So only one "red class".
Only one class that the moves change, only one class that you need to
tell the working memory that has changed.
I believe (and I think I 've seen) that this improves delta based score
calculation.
The problem is that some rules, require to check the sum of thing and
you need an accumulate,
like this rule in examinationScoreRules.drl:
rule "roomCapacityTooSmall" // TODO improve performance, as it takes 50%
of the performance
when
$period : Period();
$room : Room($capacity : capacity);
$totalStudentSize : Number(intValue > $capacity) from accumulate(
Exam(period == $period, room == $room, $studentSize :
topicStudentSize),
sum($studentSize) // Vote for
http://jira.jboss.com/jira/browse/JBRULES-1075
);
...
And Drools 5.0's forward chaining becomes backward chaining once you do
this.
Forward chaining = delta based score calculation.
Backward chaining = NO delta based score calculation.
The answer is "true modify", which mark is working on, but probably
won't make 5.1 I fear.
http://blog.athico.com/2010/01/rete-and-true-modify.html
https://jira.jboss.org/jira/browse/JBRULES-2240
Despite that, I still go for "accumulate function in a rule" each time
and take the performance hit.
Meanwhile I poke Mark :)
Remember: StartingSolutionInitializer and
relativeSelection/absoluteSelection bring far greater peformance rewards.
The "a list of people in the Shift object" approach might be better
untill "true modify"'s been solved,
but I believe it hurts your design in the long run.
But do experiment with both approaches, I 'd love to get some feed-back
on this.
> "minimal 35 hours rest each week"
> How do you check that constraint ? Is there a week object that you parse to
> check that there are 2 consecutive days each week? Or is that the generated
> movements already meet this hard constraint ?
>
How do you define a week? From monday to monday or any 7 days in a row?
In either case, just search for a pattern where that does _not_ happen.
It does depend on how you modeled your domain, I 'd have to see the code
in detail.
Take a look at this rule:
// CurriculumCompactness: Lectures belonging to a curriculum should be
adjacent
// to each other (i.e., in consecutive periods).
// For a given curriculum we account for a violation every time there is
one lecture not adjacent
// to any other lecture within the same day.
// Each isolated lecture in a curriculum counts as 2 points of penalty.
rule "curriculumCompactness"
when
$curriculum : Curriculum();
$lecture : Lecture(curriculumList contains $curriculum,
$day : day, $timeslotIndex : timeslotIndex
);
not Lecture(curriculumList contains $curriculum,
day == $day, timeslotIndex == ($timeslotIndex - 1)
);
not Lecture(curriculumList contains $curriculum,
day == $day, timeslotIndex == ($timeslotIndex + 1)
);
then
insertLogical(new
IntConstraintOccurrence("curriculumCompactness",
ConstraintType.NEGATIVE_SOFT,
2,
$lecture, $curriculum));
end
PS: next week I 'll be presenting Drools Planner in a Lille JUG.
With kind regards,
Geoffrey De Smet
Samuel Deballon schreef:
> Hello Geoffrey,
>
> Happy new year and all the best for you and your family.
>
> As you can see below, I tried posting a message on the mailing list but
> unfortunately I am not authorized.
>
> I sent an email to the administrator, but until you can answer questions in
> the email below.
>
> Note : I'll post the discussion once I have access.
> Do not worry I understand if you do not respond (I have not forgotten the
> remarks in your previous mail)
>
> If my questions aren't specific enough, let me know.
>
> In any case, thank you in advance for your response..
>
> With kind regards,
>
> Samuel Deballon
>
> CSC • This is a PRIVATE message. If you are not the intended recipient,
> please delete without copying and kindly advise us by e-mail of the mistake
> in delivery. NOTE: Regardless of content, this e-mail shall not operate to
> bind CSC to any order or other contract unless pursuant to explicit written
> agreement or government initiative expressly permitting the use of e-mail
> for such purpose • CSC Computer Sciences SAS • Registered Office: Immeuble
> Le Balzac, 10 Place des Vosges, 92072 Paris La Défense Cedex, France •
> Registered in France: RCS Nanterre B 315 268 664
> ----- Forwarded by Samuel Deballon/FRA/CSC on 14/01/2010 16:30 -----
> |------------>
> | From: |
> |------------>
> >--------------------------------------------------------------------------------------------------------------------------------------------------|
> |rules-users-owner(a)lists.jboss.org |
> >--------------------------------------------------------------------------------------------------------------------------------------------------|
> |------------>
> | To: |
> |------------>
> >--------------------------------------------------------------------------------------------------------------------------------------------------|
> |Samuel Deballon/FRA/CSC@CSC |
> >--------------------------------------------------------------------------------------------------------------------------------------------------|
> |------------>
> | Date: |
> |------------>
> >--------------------------------------------------------------------------------------------------------------------------------------------------|
> |14/01/2010 10:24 |
> >--------------------------------------------------------------------------------------------------------------------------------------------------|
> |------------>
> | Subject: |
> |------------>
> >--------------------------------------------------------------------------------------------------------------------------------------------------|
> |[Drools-planner] : Questions about employee shift rostering example |
> >--------------------------------------------------------------------------------------------------------------------------------------------------|
>
>
>
>
>
> You are not allowed to post to this mailing list, and your message has
> been automatically rejected. If you think that your messages are
> being rejected in error, contact the mailing list owner at
> rules-users-owner(a)lists.jboss.org.
>
>
> ----- Message from Samuel Deballon <sdeballon(a)csc.com> on Thu, 14 Jan 2010
> 10:26:06 +0100 -----
>
> To: rules-users(a)lists.jboss.org
>
> Subject: [Drools-planner] : Questions about employee shift
> rostering example
>
>
>
> Hi all, Hi Geoffrey,
>
> Geoffrey, I saw a paper on the trunk of drools planner where you address
> the issue about employee shift rostering.
> There is no source, I don't know what level of thinking you're in, but I
> have two questions:
>
> "Each shift has for each specialism a minimal staff size"
> how do you manage the team size ?
> Is there a list of people in the Shift object ? Or an accumulate function
> in the rule ?
>
> "minimal 35 hours rest each week"
> How do you check that constraint ? Is there a week object that you parse to
> check that there are 2 consecutive days each week? Or is that the generated
> movements already meet this hard constraint ?
>
> Thanks in advance for your answer,
>
> Samuel
>
>
> CSC • This is a PRIVATE message. If you are not the intended recipient,
> please delete without copying and kindly advise us by e-mail of the mistake
> in delivery. NOTE: Regardless of content, this e-mail shall not operate to
> bind CSC to any order or other contract unless pursuant to explicit written
> agreement or government initiative expressly permitting the use of e-mail
> for such purpose • CSC Computer Sciences SAS • Registered Office: Immeuble
> Le Balzac, 10 Place des Vosges, 92072 Paris La Défense Cedex, France •
> Registered in France: RCS Nanterre B 315 268 664
>
>
14 years, 10 months
Weblogic rules to Drools rules.
by kashif10
Hi,
We have a product using weblogic server & weblogic rules.
We are planning to move our application to jboss As using drool rules.
Brief intro of our rules:
Currently we have around 20K rules in our databse. We load all those rules
form our database in to weblogic Rule Manger. All those rules loaded in to
Rule manger with rule ID as key & Rule Data as values. we can simply add
new ruels on run time we can remove any rule form RuleMnager at runtime.
Then we have catalogs in out databse pointing those rules.
So whenever user inputs some data & ask to evaluate that data with some
catalog.
Then we simply add user data in WM & get rules from Rule manager one by one
& evaliate the rule on the basisi of WM. In the end we send the
alerts/result to user.
My questions:
i) Is there a rule manger Api in drools to whoch we provide rule Id along
with rule data to load rules in memory.
& we can remove & add furtgur rules in to it.
Also how effecient is it to load & evaluate more than 20K rules.
ii) I don't find RuleSet in ApI, whats the replacement of it?
iii) Any link having good example to load rules & then evaluate a set from
this a caalog type of case.
I hope your precious answers will help us a lot to make the decision.
Thanks.
--
View this message in context: http://n3.nabble.com/Weblogic-rules-to-Drools-rules-tp126265p126265.html
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 10 months
Stateless Vs Stateful Sessions in Webtier
by Pritam
It isn't clear from the documentation and examples on the recommended usage
of knowledge sessions. From Michael Bali's book, it is highly recommended to
use StatelessKnowledgeSession, since it's threadsafe, but a quick look at
the API shows that it doesn't support many of the features of stateful
ksession.
-- cannot pass agendaFilter
-- cannot use agenda-group, activation-group or ruleflow-group in statelss
ksession
-- It looks like one cannot get Agenda from a statelss ksession and hence
cannot use clear() or setFocus()
...
Drools says, for rules itself, "it doesn't matter whether you use stateless
or stateful ksession ..." then why is that an entire set of metadata like
grouping and ordering is ignored?
If statefulknowledge session isn't threadsafe, then what are the best
practices and considerations for making it threadsafe?
--
View this message in context: http://n3.nabble.com/Stateless-Vs-Stateful-Sessions-in-Webtier-tp130284p1...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 11 months
prevent infinite loops
by Garner, Shawn
Is there a good way to globally prevent infinite loops.
I had rule A and rule B and they both have FactA on the condition.
They also both modify FactA.
I tried no-loop and it prevents a loop of repeating RuleA over and over.
However it then goes from Rule A back to Rule B back to Rule A.
I fixed it by lock-on-active instead of no-loop.
However I was wondering if there was either a timeout feature or a maximum number of times you could set a rule to be executed to error out on infinite loops.
Any guidance would be appreciated.
Thanks,
SDG
-----Message Disclaimer-----
This e-mail message is intended only for the use of the individual or
entity to which it is addressed, and may contain information that is
privileged, confidential and exempt from disclosure under applicable law.
If you are not the intended recipient, any dissemination, distribution or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify us immediately by
reply email to Connect(a)principal.com and delete or destroy all copies of
the original message and attachments thereto. Email sent to or from the
Principal Financial Group or any of its member companies may be retained
as required by law or regulation.
Nothing in this message is intended to constitute an Electronic signature
for purposes of the Uniform Electronic Transactions Act (UETA) or the
Electronic Signatures in Global and National Commerce Act ("E-Sign")
unless a specific statement to the contrary is included in this message.
While this communication may be used to promote or market a transaction
or an idea that is discussed in the publication, it is intended to provide
general information about the subject matter covered and is provided with
the understanding that The Principal is not rendering legal, accounting,
or tax advice. It is not a marketed opinion and may not be used to avoid
penalties under the Internal Revenue Code. You should consult with
appropriate counsel or other advisors on all matters pertaining to legal,
tax, or accounting obligations and requirements.
14 years, 11 months