Use of Otherwise in converted decision table in Guvnor.
by Manasi
Hi,
1) I am using new feature of Guvnor 5.4 i.e converting from decision table
in excel format to Guvnor web Decision Table format.
After excel decision table is converted to Guvnor web Decision table format
,I am not able to use *'Otherwise'* feature for rows in guvnor decision
table.
If Guvnor decision table is created manually then only I am able to use
*Otherwise* in rows.
2) Also ,if Guvnor web decision table is created manually then *Otherwise*
in rows can be use only for String literals . Can it be use for Boolean
variables?
Please let me know what steps needs to be taken.
Thanks,
Manasi Damle
--
View this message in context: http://drools.46999.n3.nabble.com/Use-of-Otherwise-in-converted-decision-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 3 months
Re: [rules-users] Best model for planning? technicians, airplanes and shifts => insertLogical problems
by Michiel Vermandel
Hey,
Thank you James for your response.
I manage to solve a 324 tasks for 71 candidate technicians in 11 periods in less than 10 minutes.
I did not do much of optimization yet, as I need to look into that part. My knowledge about selectors and tabu-searches and heuristics is still far to limited.
The main effort I made is enhancing the algorithm to give a weight to the planning-enitities (Tasks) and technicians.
It did not seem to influence the solve-time that much, though it had major impact on the final score.
I have no idea why solving sometimes stops before 3600 seconds if hard-score is less than 0.
This is my termination config:
<termination>
<maximumSecondsSpend>3600</maximumSecondsSpend>
<scoreAttained>0hard/-999999soft</scoreAttained>
</termination>
But as POC (proof of concept) I guess I achieved my goal.
One unanswered question from my previous mail:
While rules are running: why do I get planningentities with uninitialized planningvariables (null)?
If "Task" is the planningentity and period is a planningvariable I need to put:
$task : Task(period != null, ... whatever)
Else the rule is executed with period is null, which results in all sorts of trouble, especially when using this planning variable in 'not equals' comparison.
Example of such rule which needs not-null checking:
rule "tasksInSameJobMustBeInSamePeriod"
when
$taskA : Task(period!=null, $id : id, $jobId : jobId, $periodId : periodId )
$taskB : Task(period!=null, id > $id, jobId == $jobId, periodId != $periodId )
then
insertLogical(new IntConstraintOccurrence("tasksInSameJobMustBeInSamePeriod", $taskA, $taskB));
end
Without the (period!=null you get exceptions thrown complaining about constraints in excess.
Any ideas on why this is needed and if it is possible to never get nulls as planningvariable in the rules?
Regards,
Michiel
-----------------
http://www.codessentials.com - Your essential software, for free!
Follow us at http://twitter.com/#!/Codessentials
________________________________
From: James Owen - North Texas <jco(a)kbsc.com>
To: Michiel Vermandel <mvermand(a)yahoo.com>; Rules Users List <rules-users(a)lists.jboss.org>
Sent: Thursday, September 6, 2012 4:30 PM
Subject: Re: [rules-users] Best model for planning? technicians, airplanes and shifts => insertLogical problems
Greetings:
I started at the beginning of this thread and followed along (skipping only a one or two emails) and I was surprised that along the way that the problem grew and grew. There is an excellent discussion of this very situation in the seminal book on expert systems by Girratano and Riley (about chapter 5 or 6) on pattern matching wherein they discuss this very problem with matching multiple patterns of objects. When pattern matching it does matter the order in which you match the objects and their attributes because of the combinatorial explosion. You have only so much memory with which to work and, sooner or later, you will run out of memory.
You can't just throw all of the objects into a bucket willy-nilly and hope for the best results. The returned error may or may not be the one that you thought that it would be. 500 planes or 1,000 planes matched against multiple tasks matched against 12 months matched against multiple weeks matched against multiple shifts matched against … Well, you get the idea. As the list expands, the possibilities expand by the number of possibilities against which it can be matched. The project has to be architected and broken up into proper "chunks" so that it can be digested properly. You don't eat a steak nor an apple in one bite. You take it one bite at a time and chew it slowly and carefully. So it is with a large problem.
Even virtual memory is limited and will die out, as I have seen it done with benchmarks and the WaltzDB benchmark when programmed poorly. When one more item is added to the problem space you must remember that the memory required expands exponentially ever upwards so it is always best to keep the requirements small at all times and move from small sets to small sets, even when you have GigaBytes of RAM these days. Even later when we have TeraBytes, good programming will still be required for good results.
BTW, it seems that the God Father of benchmarks, Dr. Daniel Miranker (formerly of CMU and now at UT Austin) will be speaking at Intellifest 2012 this year. Visit http://www.IntelliFest.org for more details as they develop. They probably have a gathering of some of the best minds of AI this year if anyone would care to attend. Also, if anyone is looking for employment, they are planning on having recruiters there as well.
Shalom
jco
On Sep 3, 2012, at 7:31 AM, Michiel Vermandel wrote:
Ok,
>
>I changed periodId > $periodId back into periodId != $periodId as I already discovered that this change resulted in invalid solutions.
>Though, then I was back to the exception.
>
>I now made another change which seems to be the solution... I think... I hope
>Though, I do not understand the solution myself for 100%
>
>What I did was testing if period is not null:
>
>rule "tasksInSameJobMustBeInSamePeriod"
> when
> $taskA : MaintenanceTask(period!=null, $id : id, $jobId : jobId, $periodId : periodId )
> $taskB : MaintenanceTask(period!=null, id > $id, jobId == $jobId, periodId != $periodId )
> then
> insertLogical(new IntConstraintOccurrence("tasksInSameJobMustBeInSamePeriod", $taskA, $taskB));
>end
>
>I just tried that because all the sudden I tought checking null != null might not be such a good idea.
>I now get the right combinations.
>
>Can you please tell me if this is a correct change?
>
>Once again one of my earlier questions arises: why is a rule tested upon an entity before the planning variables are set?
>Or am I wrong here?
>
>Thanks,
>
>Michiel
>
>
>
>
>-----------------
>http://www.codessentials.com - Your essential software, for free!
>Follow us at http://twitter.com/#!/Codessentials
>
>
>________________________________
> From: Geoffrey De Smet <ge0ffrey.spam(a)gmail.com>
>To: Rules Users List <rules-users(a)lists.jboss.org>
>Sent: Monday, September 3, 2012 2:15 PM
>Subject: Re: [rules-users] Best model for planning? technicians, airplanes and shifts => insertLogical problems
>
>
>
>
>Op 03-09-12 13:59, Michiel Vermandel schreef:
>
>Hi,
>>
>>I'm not keen on spending time on a temp solution if I cannot
estimate - at this time - how much time it will take me to build
it correctly afterwards.
>>Budgets are limited... (as with anyone I guess :-)
>>Once again, it gives me a bad feeling that such a simple setup
is giving me such a hard to solve issue.
>>
Incremental score calculation isn't a simple concept nor easy to implement.
>But I agree that Drools and Planner should shield you from that
complexity and take the heat there.
>Planner already has extensive support to detect score corruption in
incremental score calculation,
>and Drools's compensation action looks promising to take greatly
simply the complexity to the user.
>
>
>I had thought that - given the project is only a very few classes - it would be peanuts for you or any other expert to pinpoint what I'm doing wrong.
>>
I didn't have the time to read all the classes in detail, just glimpsed over them.
>
>
>>Non the less...
>>
>>I tried to have a look again to a number of examples and I
changed my rules, with a positive result!
>>I seem to get the correct solution. But... I do not know if my
changes are valid.
>>I mean, is it possible that I threw a number of possible
solutions away?
>>Maybe this will not show right now but will have it's effect
when numbers grow and possible solutions shrink.
>>
>>So what I did is going from
>>
>>rule "tasksInSameJobMustBeInSamePeriod"
>> when
>> $taskA : MaintenanceTask($id : id, $jobId : jobId,
$periodId : periodId )
>> MaintenanceTask(id != $id, jobId == $jobId, periodId != $periodId ) // <============ a != $a
>> then
>> System.out.println("r3: " + $taskA );
>> insertLogical(new
IntConstraintOccurrence("tasksInSameJobMustBeInSamePeriod",
$taskA));
>>end
>>
>>
>>
>>to
>>
>>
>>rule "tasksInSameJobMustBeInSamePeriod"
>> when
>> $taskA : MaintenanceTask($id : id, $jobId : jobId,
$periodId : periodId )
>>
$taskB:
>
> MaintenanceTask(id > $id,
>>
Good, because if you count the combination task5-task7, you don't want to count the combination task7-task5 too.
>
>jobId == $jobId, periodId > $periodId ) // <================ a > $a
>>
Bad, keep this on periodId != $periodId (or even period != $period)
>
> then
>> System.out.println("r3: " + $taskA );
>> insertLogical(new
IntConstraintOccurrence("tasksInSameJobMustBeInSamePeriod",
$taskA));
>>
Add $taskB too:
>insertLogical(new IntConstraintOccurrence("tasksInSameJobMustBeInSamePeriod", $taskA, $taskB));
>
>end
>>
>>
>>Can you please tell me if this is THE solution or a dangerous move that works out now but will give issues when numbers grow?
>>
The id > $id change is good, the periodId != $periodId isn't.
>
>The above fixes could explain score corruption. You no longer get
any exceptions in environmentMode DEBUG or TRACE?
>
>Keep looking at the examples: they work and they scale.
>Keep providing feedback as to the pain points too of course.
>
>Hope that helps.
>
>
>>
>>Thanks a lot.
>>
>>
>>Michiel
>>
>>
>>-----------------
>>http://www.codessentials.com - Your essential software, for free!
>>Follow us at http://twitter.com/#!/Codessentials
>>
>>
>>________________________________
>> From: Geoffrey De Smet <ge0ffrey.spam(a)gmail.com>
>>To: Michiel Vermandel <mvermand(a)yahoo.com>; Rules Users List <rules-users(a)lists.jboss.org>
>>Sent: Monday, September 3, 2012 11:56 AM
>>Subject: Re: Best model for planning? technicians, airplanes and shifts => insertLogical problems
>>
>>
>>
>>
>>Op 03-09-12 11:30, Michiel Vermandel schreef:
>>
>>I did not really start on one example. I have scrolled through several to try to figure out how to do it, then started from scratch for the POJO's and Rules.
>>>
>>>The config file was copies from one of the examples because it contained too many things that were hard to get right in the beginning.
>>>I know that is a risk but I needed to start somewhere.
>>>
>>>
I am thinking how to standardize the getting started with planner experience.
>>The cloud balance quick start is the example I pushing
at the moment.
>>But for specific use case, it's better to start from an
example that's similar to the user's use case.
>>The trouble is, it's often hard to see which example is
similar and which is not.
>>
>>
>>>
>>>3) What does "The workingMemory has 2 ConstraintOccurrence(s) in excess:" really mean?
>>> - Are the constraints there more than once?
No, it means that in a clean WorkingMemory, those 2 ConstraintOccurrences aren't there,
>>but in the incremental WorkingMemory, they are there.
>>So they are in excess: they should have been
automatically retracted by the rule engine, but for some
reason, they are not.
>>
>>Read this section about incremental score calculation to
understand why this complexity is needed:
>> http://docs.jboss.org/drools/release/5.4.0.Final/drools-planner-docs/html...
>>
>>If you just want to prove that a Planner POC works for
now (especially if you're close to giving up),
>>just take a few minutes to switch to a simple Java score
calculator for now:
>> http://docs.jboss.org/drools/release/5.4.0.Final/drools-planner-docs/html...
>>It will be _much_ slower especially when it scales out
(but it should still be faster than anything you can
invent yourself within reasonable time).
>>Once that works fine and you get a good result on your
toy problem and you can scale out to 100+ jobs,
>>then switch back to drools to scale out to 10000+ jobs
and follow the rest of this mail.
>>
>>
>> - has this something to do with the equals and hashcode (which I did implement (see below))?
Likely. The equals/hashcode methods are used of all objects in the causes parameter.
>>It's a design issue in Planner that the planner entity's
equals/hashcode() needs to be used for the
ConstraintOccurrence's causes.
>>Compensation action
>>
>>
>>>
>>> About the compensation action: is it already available on 5.4.0 final? Should I try that?
The plumbing is there in Drools Expert, but in Planner there are no decent examples, supporting code or even complex experiments yet.
>>It's a minefield, probably best to stay out until I get
it done or you have more Planner experience :/
>>
>>
>>>
>>>4) I have been looking to the equals and hashcode, though found many examples that implement solutionEquals and solutionHashcode instead.
>>> Currently I implemented them like this:
>>>
>>> @Override
>>> public int hashCode() {
>>> return id.hashCode(); //(*)
>>> }
>>>
>>> @Override
>>> public boolean equals(Object o) {
>>> if (this == o) {
>>> return true;
>>> }
>>> if (id == null || !(o instanceof
MaintenanceTask)) {
>>> return false;
>>> } else {
>>> MaintenanceTask other =
(MaintenanceTask) o;
>>> return id.equals(other.id);
>>> }
>>> }
>>>
>>>
Looks good
>>
>>
>>>
>>> (*) id is a String property which is passed into the entity object through the constructor and upon cloning it is passed from the clone source to the clone target:
>>> public MaintenanceTask clone() {
>>> System.out.println("Cloning task " + id);
>>> MaintenanceTask clone = new MaintenanceTask(job, id);
>>> clone.period = this.period;
>>> clone.technician = this.technician;
>>> return clone;
>>> }
>>>
Looks good.
>>
>>
>>>
>>>
>>>
>>> I am still confused about:
>>>
>>> - Which ones do I need to implement (equals or solutionEquals, ...)?
because of this code:
>> https://github.com/droolsjbpm/drools-planner/blob/master/drools-planner-c...
>>which is called by drools on insertLogical inserted
objects (see drools expert manual on insertLogical)
>>
>> - Should an entity and a cloned entity have the same result for both equals and hashcode? (I guess so)
Yes, definitely.
>>
>> - Should only the entity objects have such implementations? (Planning variables are never cloned, right?)
>>>
It looks good. Only the entity's are cloned indeed during cloneSolution(): they are the only instances that change during planning.
>>
>>
>>>
>>>
>>>-----------------
>>>http://www.codessentials.com - Your essential software, for free!
>>>Follow us at http://twitter.com/#!/Codessentials
>>>
>>>
>>>________________________________
>>> From: Geoffrey De Smet <ge0ffrey.spam(a)gmail.com>
>>>To: Rules Users List <rules-users(a)lists.jboss.org>
>>>Sent: Monday, September 3, 2012 10:44 AM
>>>Subject: Re: [rules-users] Best model for planning? technicians, airplanes and shifts => insertLogical problems
>>>
>>>Op 03-09-12 10:21, Michiel Vermandel schreef:
>>>> Hi Geoffrey,
>>>>
>>>> Thanks for the support so far.
>>>> I understand that you do not provide full
support on this level.
>>>> Though I have the feeling that this is
really
>>>> - a very basic solution setup
>>>> - a beginners-mistake and since I'm looking
into it now for about 3 days
>>>> (since I started with planner) it seems to
be not obvious to find for a
>>>> beginner.
>>>> So I was trying my luck in offering the
code.
>>>> It could be an opportunity to enrich the
documentation ;-) ;-)
>>>
>>>Good point, the score corruption problem is
often a beginner problem and
>>>it's a PITA. I 'll write some more docs about.
>>>
>>>Do note that your 3 day implementation should be
able to scale out to
>>>10000 planes pretty easily, so hang in there :)
>>>I fear you might have started copying from the
wrong example nqueens (if
>>>you did that) :/ Nurse rostering is a far more
similar to this kind of
>>>problem. I am not sure which example to promote
in the docs: the nqueens
>>>is simple enough to explain things on, but it's
too simple to copy from
>>>for real world stuff :/ Feedback welcome.
>>>
>>>>
>>>>
>>>> Ok,
>>>>
>>>> 1) adding the $t2 results in the same sort
of exception, only
>>>> planningEntity seems different:
>>>>
>>>> with insertLogical(new
>>>>
UnweightedConstraintOccurrence("tasksInSameJobMustBeInSamePeriod",
$t1,
>>>> $t2));
>>>>
>>>> Exception in thread "main"
java.lang.IllegalStateException: Score
>>>> corruption: the workingScore (-2) is not
the uncorruptedScore (0):
>>>> The workingMemory has 2
ConstraintOccurrence(s) in excess:
>>>>
tasksInSameJobMustBeInSamePeriod/NEGATIVE_HARD:[Maintenance
of
>>>> Boeing 737 - PJ23.I#1 73111693, Maintenance
of Boeing 737 - PJ23.I#2
>>>> 427578167]
>>>>
tasksInSameJobMustBeInSamePeriod/NEGATIVE_HARD:[Maintenance
of
>>>> Boeing 737 - PJ23.I#2 427578167,
Maintenance of Boeing 737 - PJ23.I#1
>>>> 73111693]
>>>> Check the score rules who created those
ConstraintOccurrences. Verify
>>>> that each ConstraintOccurrence's causes and
weight is correct.
>>>> at
>>>>
org.drools.planner.core.score.director.AbstractScoreDirector.assertWorkingScore(AbstractScoreDirector.java:101)
>>>> at
>>>>
org.drools.planner.core.constructionheuristic.greedyFit.decider.DefaultGreedyDecider.doMove(DefaultGreedyDecider.java:110)
>>>> at
>>>>
org.drools.planner.core.constructionheuristic.greedyFit.decider.DefaultGreedyDecider.decideNextStep(DefaultGreedyDecider.java:78)
>>>> at
>>>>
org.drools.planner.core.constructionheuristic.greedyFit.DefaultGreedyFitSolverPhase.solve(DefaultGreedyFitSolverPhase.java:63)
>>>> at
>>>>
org.drools.planner.core.solver.DefaultSolver.runSolverPhases(DefaultSolver.java:183)
>>>> at
>>>>
org.drools.planner.core.solver.DefaultSolver.solve(DefaultSolver.java:151)
>>>> at
>>>>
be.axi.planner.domain.MaintenancePlanning.main(MaintenancePlanning.java:27)
>>>>
>>>> with insertLogical(new
>>>>
UnweightedConstraintOccurrence("tasksInSameJobMustBeInSamePeriod",
$t1));
>>>>
>>>> Exception in thread "main"
java.lang.IllegalStateException: Score
>>>> corruption: the workingScore (-2) is not
the uncorruptedScore (0):
>>>> The workingMemory has 2
ConstraintOccurrence(s) in excess:
>>>>
tasksInSameJobMustBeInSamePeriod/NEGATIVE_HARD:[Maintenance
of
>>>> Airbus A350 - XJ34.I#2 778813475]
>>>>
tasksInSameJobMustBeInSamePeriod/NEGATIVE_HARD:[Maintenance
of
>>>> Airbus A350 - XJ34.I#0 225744121]
>>>> Check the score rules who created those
ConstraintOccurrences. Verify
>>>> that each ConstraintOccurrence's causes and
weight is correct.
>>>> at
>>>>
org.drools.planner.core.score.director.AbstractScoreDirector.assertWorkingScore(AbstractScoreDirector.java:101)
>>>> at
>>>>
org.drools.planner.core.constructionheuristic.greedyFit.decider.DefaultGreedyDecider.doMove(DefaultGreedyDecider.java:110)
>>>> at
>>>>
org.drools.planner.core.constructionheuristic.greedyFit.decider.DefaultGreedyDecider.decideNextStep(DefaultGreedyDecider.java:78)
>>>> at
>>>>
org.drools.planner.core.constructionheuristic.greedyFit.DefaultGreedyFitSolverPhase.solve(DefaultGreedyFitSolverPhase.java:63)
>>>> at
>>>>
org.drools.planner.core.solver.DefaultSolver.runSolverPhases(DefaultSolver.java:183)
>>>> at
>>>>
org.drools.planner.core.solver.DefaultSolver.solve(DefaultSolver.java:151)
>>>> at
>>>>
be.axi.planner.domain.MaintenancePlanning.main(MaintenancePlanning.java:27)
>>>>
>>>>
>>>> 2) You suggested to replace
UnweightedConstraintOccurrence with
>>>> IntConstraintOccurrence. I will.
>>>> UnweightedConstraintOccurrence is used in
the very basic Queens example
>>>> though...
>>>
>>>Yep, my mistake.
>>>
>>>>
>>>> 3) Where is the best place to read about
what insertLogical and
>>>> IntConstraintOccurrence really do?
>>>> What is the purpose of the Cause -objects,
which should be passed?
>>>> => where is the best place to find
explanation about this?
>>>> (http://docs.jboss.org/drools/release/5.4.0.Final/drools-planner-docs/html...
>>>> doesn't really enlighten me on that part)
>>>
>>>Look for "insertLogical" in the Drools Expert
guide:
>>>
>>>http://docs.jboss.org/drools/release/5.4.0.Final/drools-expert-docs/html_...
>>>
>>>When rules do an insertLogical of an object A,
it's discarded if another
>>>object B in the WorkingMemory equals object A
(through equals() and
>>>through hashcode()). Because the
ConstraintOccurrences need to be unique
>>>so they aren't discarded, they ruleId,
constraintType and causes are
>>>used for equals()/hashcode().
>>>
>>>Future work: "compensation action"
>>>Recently, drools introduced something called
"compensation action",
>>>which can probably replace the use
insertLogical(ConstraintOccurrence)
>>>and make the causes parameter obsolete.
>>>It's also faster.
>>>My first experiments look very promising, but I
haven't got time yet to
>>>experiment with it on all examples and make it
easy for users to use.
>>>
>>>It would allow us to do something like this in
the then part of a rule:
>>> hardAndSoftScoreHelper.addHardScore(-5);
>>>or
>>> hardAndSoftScoreHelper.addSoftScore(- $sum);
>>>or
>>> simpleScoreHelper.addScore(-7);
>>>
>>>No need for causes, insertLogicals, no
equals/hashcode() worries, much
>>>more flexible, ...
>>>
>>>
>>>4) Does your MaintenanceTask implement
equals()/hashcode() other than
>>>Object's original implementation?
>>>
>>>
>>>>
>>>> Thanks in advance.
>>>>
>>>
>>>yw
>>>
>>>_______________________________________________
>>>rules-users mailing list
>>>rules-users(a)lists.jboss.org
>>>https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>>>
>>>
>>>
>>>_______________________________________________
rules-users mailing list rules-users(a)lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>>
>>
>>
>>_______________________________________________
rules-users mailing list rules-users(a)lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
>
>_______________________________________________
>rules-users mailing list
>rules-users(a)lists.jboss.org
>https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>_______________________________________________
>rules-users mailing list
>rules-users(a)lists.jboss.org
>https://lists.jboss.org/mailman/listinfo/rules-users
>
12 years, 3 months
DSL usage in Guvnor
by dme1
Hi,
Do I have to use the Text based DSL Editor in Guvnor if I want to use DSL
which has definition for the Object and the fields within it (using the "-"
at the beginning). If I use this in the Guided editor, it shows are 2
separate rule entries.
Also can I use DSL for defining conditions and actions in a Guided Decision
Table, if yes is there an example which shows how to do this.
Also if I have a Domain Model, and if I use "Enumerations" to define
constraints on some of the fields (map to a list of values), these do not
show up when using DSL based rules in the Guided Editor, is there any way to
get this to work.
Thanks,
dme
--
View this message in context: http://drools.46999.n3.nabble.com/DSL-usage-in-Guvnor-tp4019609.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 3 months
kcontext.getKnowledgeRuntime() returns StatefulKnowledgeSessionImpl even when session is started as a CommandBasedStatefulKnowledgeSession
by Darin Wilcox
Hi,
In my project, I have created a StatefulKnowledgeSession that is
persistent. The StateulfKnowledgeSession implementation is the
CommandBasedStatefulKnowledgeSession. From this
CommandBasedStatefulKnowledgeSession, I started a workflow that contains a
SignalEvent waiting for something to signal into that process.
I then started a second process that contains only an action node with the
following code:
kcontext.getKnowledgeRuntime().signalEvent("TestSignal2", "from
SignalHello"); // Should broadcast to all other processes currently
running in this session.
The signal is never received by the first process because the
kcontext.getKnowledgeRuntime() that is trying to signal the event uses an
instance of StatefulKnowledgeSessionImpl not
CommandBasedStatefulKnowledgeSession. Can anyone explain why the
kcontext.getKnowledgeRuntime() returns a different instance of the
StatefulKnowledgeSession than the one it was started with? Is this a bug?
Thanks,
- Darin
12 years, 3 months
Drools fusion how to I catch an Exception
by RichardAmbridge
If I have a rule that has an error in it, the error isn't being caught by the
compiler and the error doesn't happen as the Object is inserted into the
session, it only happens after a time period completes, then Drools silently
fails.
How can I catch these silent failures.
See below for test case.
Notice in the After5 rule there is a mistake in the then part.
m.status=$m.status;
$m doesn't exist.
If i change this to $m.status=m.status, the compiler detects the error, but
this way of m.status=$m.status is not found.
When the rule fires it just dies.
I need to be able to catch the Exception somehow and report it..
Any help really appreciated..
Thanks
Ric
----------
sample.drl:-
----------
package com.sample
import com.sample.DroolsTest.Message;
declare Message
@role ( event )
end
rule "Hello"
dialect "mvel"
when
m : Message( status == Message.HELLO, myMessage : message )
then
System.out.println( "Hello added" );
end
rule "After5"
dialect "mvel"
when
m : Message( status == Message.HELLO, myMessage : message )
not( Message( status == Message.GOODBYE , this after [0s,5s] m ))
then
System.out.println( "After5 then start" );
m.status=$m.status;
System.out.println( "After5 then stop" );
retract(m);
end
----------
DroolsTest.java:
----------
package com.sample;
import org.drools.KnowledgeBase;
/**
* This is a sample class to launch a rule.
*/
public class DroolsTest {
public static final void main(String[] args) {
try {
// load up the knowledge base
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession = kbase
.newStatefulKnowledgeSession();
KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory
.newFileLogger(ksession, "test");
// go !
Message message = new Message();
message.setMessage("Hello World");
message.setStatus(Message.HELLO);
System.out.println("Inserting message");
ksession.insert(message);
System.out.println("Fire all rules");
ksession.fireAllRules();
System.out.println("Sleep 10");
Thread.sleep(10000);
System.out.println("End sleep");
logger.close();
} catch (Throwable t) {
t.printStackTrace();
}
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBaseConfiguration conf = KnowledgeBaseFactory
.newKnowledgeBaseConfiguration();
conf.setOption(EventProcessingOption.STREAM); // STREAM mode as we are
// dealing with Events
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory
.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("Sample.drl"),
ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error : errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(conf);
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
public static class Message {
public static final int HELLO = 0;
public static final int GOODBYE = 1;
private String message;
private int status;
public String getMessage() {
return this.message;
}
public void setMessage(String message) {
this.message = message;
}
public int getStatus() {
return this.status;
}
public void setStatus(int status) {
this.status = status;
}
}
}
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-fusion-how-to-I-catch-an-Excepti...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 3 months
Fwd: how to import function in drl file on guvnor
by Michael Anstis
Forwarded to mailing list.
You would have to consider use of free-format DRL in this scenario.
---------- Forwarded message ----------
From: <avneesh.sisodia(a)intelegencia.com>
Date: 4 September 2012 12:33
Subject: how to import function in drl file on guvnor
To: michael.anstis(a)gmail.com
Hello mantis,
I am very new in drools and guvnor users. I have a problem during making
rules. I want to use my predefined functions in rule execution.
Suppose I have a rule "companyDivision" and i want to import it into my
rule file like this:
package com.exp.test
import com.abc.bean.CompanyBean
import function
com.abc.util.Validation.companyDivision;
rule "CompanyInfo"
dialect "mvel"
when
CompanyBean( businessType == "ABC" , insuranceProgram ==
"XYZ" )
then
CompanyBean fact0 = new CompanyBean();
fact0.setBusinessType( "ABC" );
fact0.setInsuranceProgram( "XYZ" );
companyDivision(fact0 );
end
How I can do this.
I am doing following steps to c\generate rules::
1. creating com.exp.test package
2. uploading jar(model) file which included all pojo files of application
3. creating "CompanyInfo" rule
rule file generated by guvnor is like this:::
package com.exp.test
import com.abc.bean.CompanyBean
rule "CompanyInfo"
dialect "mvel"
when
CompanyBean( businessType == "ABC" , insuranceProgram ==
"XYZ" )
then
CompanyBean fact0 = new CompanyBean();
fact0.setBusinessType( "ABC" );
fact0.setInsuranceProgram( "XYZ" );
insert(fact0 );
end
I have only two options there 1. insert and 2. insert logically.
but on place of insert and insert logically I want to use "companyDivision"
function.
Please guys tell me how it is possible.
Thanks
12 years, 3 months
Fwd: need help to use drools guvnor.
by Michael Anstis
Forwarded to mailing list.
You could consider using the RSS feed (
http://blog.athico.com/2011/03/atompub-interface-for-guvnor.html) and an
adaptation of this:
https://community.jboss.org/wiki/PublishDroolsArtifactsFromAProductionEnv...
---------- Forwarded message ----------
From: <avneesh.sisodia(a)intelegencia.com>
Date: 4 September 2012 12:32
Subject: need help to use drools guvnor.
To: michael.anstis
Hey manstis,
I need your valuable help. I have a project which is based on Insurance
domain. I have to use drools-guvnor in it to execute some rules.Now I had
deploy guvnor 5.3 on JBoss AS 7.0.Final. And I am able to use static rules
from .drl file by using stateless session. I need to do it dynamic. I mean
when I changed any condition in rule file on guvnor it should be reflect on
application. So I want that you suggest me any link where I can get useful
information. how I can use rules directly from guvnor on java.
Thanks..
12 years, 3 months
IntelliFest Drools & jBPM Workshop Agenda (San Diego Oct 2012)
by Mark Proctor
http://www.dzone.com/links/r/intellifest_drools_amp_jbpm_workshop_agenda_...
---
At IntelliFest this year there are two Drools workshops. There is the "General Drools&jBPM Workshop", which is a series of high level talks explaining the various features of Drools&jBPM. The second is the workshop "Rule Design Patterns in Production Systems", by Dr Wolfgang Laun, which is aimed at rule authoring techniques. The agenda for both is below, you can see the more detailed and up to date agenda here.
Only 7 weeks to go, and there are limited spaces, so register soon here.
General Drools&jBPM Workshop
8.00 AM: Breakfast Social – pre-laptop setup, and QA time with solution Architects.
-Key will be provided to setup your laptop, so you can view and run the examples used during the talks.
9.00 BRMS Product Overview (Prakash Aradhya 15min)
How we turn the Drools and jBPM communtiy parts into a world class product. Supporting and harvesting all the innovation done in the open community, Red Hat delivers reliable, dependable and integrated solutions for enterprise customers.
9.15 Introduction to Drools Expert (Mark Proctor 45min)
Drools Expert covers the business rule engine. A gentle, example driven, dive into the Drools technical rule language and engine features.
10.10 Introduction to Drools Fusion (Edson Tirelli 45min)
Learn how Drools does CEP differently. Our unified approach extends Drools Expert with a series of language and sub-engine extensions to provide temporal reasoning and event correlation.
11.05 Introduction to jBPM and BPMN2 (Kris Verlaenen 45min)
jBPM is a BPM engine designed for flexible processes, implementing and extending the BPMN2 spec. Built form the ground up to be part of a unified strategy for business automation and decision management. jBPM fully integrates with Drools Expert and Fusion.
11.45 Decision Modelling with Graphical Editors (Edson Tirelli 30min)
Drools Expert provides sophisticated web based tooling, around decision tables, guided editors and templates. Our decision modelling approach draws from the very best research found at Dr Jan Vanthienien school of Decision Modelling.
12.30 Working Lunch – Experience Drools and jBPM – Hands on labs (Optional) (1hour)
13.30 Human Tasks up Close and Personal (Kris Verlaenen 40min)
Human tasks are a central component of BPM. This example driven talk will build an example live, demonstrating what jBPM’s Human Task technology can do for you.
14.20 Building Games with Drools – Pong, Snake and Wumpus (Mark Proctor 40min)
Time for some hard play, learn how to build classic computer games with Drools. These also provide interesting exercises in BA requirements gathering.
15.10 Drools Planner a Quick Overview (Geoffrey De Smet 40min)
Whether it’s employee rostering, task scheduling, vehicle routing, bin packing or another planning problem: all organizations try to optimize their limited resources under constraints. Drools Planner optimizes business resources for normal Java programmers.
15.50 Drools Chance for Imperfect Reasoning (Davide Sottara 40min)
Sometimes data quality is not perfect, so facts may not be known with precision and certainty. Likewise, crisp constraints such as hard thresholds might not be able to capture the complexity of a business policy. Drools Chance allows to apply gradual and/or probabilistic constraints to uncertain or vague data.
16.40 UberFire – Drools&jBPM Workbench framework (Mark Proctor 30min)
UberFire is a new project that forms the foundation of our 6.0 web tooling. It’s standalone framework that provides a sophisticated workbench framework for the web; where everything is a plugin. Come learn about the Uberfire, and how you can use the workbench to build your own web applications.
17.10 Drools&jBPM 6.0 and Beyond (Optional : open as long as people remain)
An open presentation and discussion about the design ideas, principles and goals that are driving the development of Drools & jBPM version 6.0. This will be an optional and informal session where attendees will have the opportunity to learn about what is coming, contribute ideas and provide feedback that will be taken in consideration by the development team.
17.10 Hands on Lab
Run at the same time as "Drools&jBPM and Beyond" and Beyond. Solution Architects are on hand to help you with your coding problems, and running examples.
Rule Design Patterns in Production Systems
Rule Design Patterns
What is a “Rule Design Pattern”?
Basic Rule Formats
Fact Classification
Handling Failure to Match
Extending Rules
Reasoning with Interfaces
Active Facts
Marker Facts
Fact Proxies
Application Design Patterns
Short-Term Sessions
Permanent Sessions
12 years, 3 months