Your suggestions for rules for pretty simple problem
by Jason Parekh
I'm new to constraint programming and Drools Planner. I've read through the
docs and built some rules that would probably get me to the right answer,
eventually :)
I was hoping to get your suggestions for better concrete rules.
The problem is I need to order items in a performance with the following
logical rules:
1) All items of the same category must appear together.
2) A performer can be in multiple items, but ideally there'd be at least
three items between any of her two items
The approaches I took are:
- For (1), count the number of transitions from one category to another.
Subtract this to the hard score.
- For (2), three separate rules, each of which assert that an item at
position i does not share performers with an item at position i+1, i+2 and
i+3 (one of these per rule). The number of shared performers would be
subtracted from the hard score.
The scoring and my choice for construction heuristic (FIRST_FIT) are just
naive selections. I haven't gotten to optimizing either of these -- just
wanted to check with you guys to make sure my rules are sane.
Thanks in advance,
jason
14 years, 2 months
5.3.0: combination of KnowledgeAgent and declare broken
by Wolfgang Laun
5.3.0 Final
Using a KnowledgeAgent to build a KnowledgeBase containing a DRL with the
declaration of a new type may result in some rules not firing at all.
The very same code compiled via KnowledgeBuilder API works perfectly
correct.
-W
14 years, 2 months
Truth maintenance and RHS variables
by Juanker Atina
Hi there,
I'm working on a rule that will alert me when there is no events from the
sensors for a while.
So, first idea was to use time window and matches in condition side, to
match all types of sensors, and then to print that something is wrong.
rule "Alert if there is no activity"
when
not StateEvent(itemName matches "door.*|presence.*|luminosity.*") over
window:time( 1m ) from entry-point "EventStream"
then
System.out.println("Alert: one sensor is not working");
end
First change was to add a timer, as truth maintenance will fire this rule
the first time, but not forever. So i add a timer to fire the rule every 20
seconds, for example.
rule "Alert if there is no activity"
timer (cron:0/20 * * * * ?)
when
not StateEvent(itemName matches "door.*|presence.*|luminosity.*") over
window:time( 1m ) from entry-point "EventStream"
then
System.out.println("Alert: one sensor is not working");
end
The second thing i want to achieve is to print what specific sensor is not
working, but i understand that as there is no StateEvent, i can't declare a
variable, for example.
rule "Alert if there is no activity"
timer (cron:0/20 * * * * ?)
when
not $event: StateEvent(itemName matches
"door.*|presence.*|luminosity.*") over window:time( 1m ) from entry-point
"EventStream"
then
System.out.println("Alert: one sensor is not working: " +
$event.getItemName());
So, do you know how can i know which sensor is not working? must i rewrite
the rule to achieve this? is this possible?
Thanks for your help.
end
14 years, 2 months
problem binding variable to map value
by Ming Fang
Below is a very simple rule that binds a variable to a map value...
rule "how many times is map.get() called?"
when
p:Parameter(
$value:tags[1]==1,
$value == 1,
$value != 2,
$value != null,
$value in ("1","2")
)
then
System.out.println("value=" + $value);
end
The problem is map.get() is called 6 times when executing this rule using a Stateless session.
To test this I implement a mock Map that the get(key) simply returns the key.
So in this example tags[1] return 1.
And in the get() I simply print a test message to see how many times it's been called.
Here is the sequence...
1x = tags[1]
2x = tags[1] == 1
3x = $value == 1
4x = $value != 2
5x = $value != null
and most surprisingly none for $value in ("1","2")
but
6x == System.out.println("value="+$value)
Is this a bug?
It's a huge problem for my application since the call to get() is expensive for my map implementation.
Thanks
--ming
14 years, 2 months
GUVNOR
by Olfa h
HI ,
how to install DROOLS Guvnor ?
14 years, 2 months
Ruleflow: two flow exits (or equivalent?) from reusable sub-process?
by George Georgovassilis
Hello list,
I modeled (v5.3) a reusable sub-process which can either finish in a
desired state (i.e. validations ok) or an undesired state (some validations
failed and I need to route to a different flow). Ideally the sub-process
would allow for two outgoing connections, but as far as I see that is
currently not possible. Can anybody advise on how to achieve a similar
functionality?
Is there a chance I could build a workitem that extends the reusable
sub-process but allows for two exit connections, and if yes, how?
Can signals or fault nodes achieve a similar effect and if yes, then how?
Thanks in advance,
G.
14 years, 2 months
Low Date question in drools
by Nancy Henggeler
I have a simple rule where I want to bypass elements that have a low date but
drools seems to be interpreting the date different then I am expecting.
Drools statement and error follows:
ClientSupplement ( dateOfBirth : dateOfBirth != null && != 0001-01-01)
throws error -- Error: [Error: badly formatted number: For input string:
"001-01-01"] [Near : {... 0001-01-01 ....}] ^ [Line: 1, Column: 1]
How do I get drools to understand this low date? I have tried single,
double, and no quotes around the low date and all result in a similiar error
message. Please Help!
--
View this message in context: http://drools.46999.n3.nabble.com/Low-Date-question-in-drools-tp3729940p3...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 2 months
Protection from malicious rules
by Shur, Bob
We're considering a system in which partners could write and deploy their own rules, but we are worried about security. Is there any support for preventing harmful rules? For example:
rule "bad"
when
then
File f = new File("important.doc");
f.delete();
end
14 years, 2 months
Rule does not fire when JBPM asks to do so in BPMN 2.0 process
by argaldo
Hi,
We're running an application that uses Drools + JBPM 5 + Drools
integration our set-up can be seen as:
Some rule fires and creates a JBPM process ( a fact gets inserted into
drools using "kcontext.getKnowledgeRuntime().startProcess()" ), after a few
nodes processed, the JBPM engine arrives to a node of type
"businessRuleTask" which in turn tells drools to evaluate a group of rules (
which at the moment consists on only one rule ).
Well, the problem is that what we see is that everything runs ok before
the businessRuleTask and at the moment when the rule group would be
evaluated we could see that in drools the rule gets created, activated, but
never fired.
We did some debug and realized that the reason the rule group never got
fired is because this check in RuleFlowGroupImpl.java ( method
setActive(boolean) ):
if ( this.list.isEmpty() ) {
if ( this.autoDeactivate ) {
// if the list of activations is empty and
// auto-deactivate is on, deactivate this group
WorkingMemoryAction action = new DeactivateCallback(
this );
this.workingMemory.queueWorkingMemoryAction( action );
}
}
The problem is that at the moment when drools calls setActive() and
performs the check, this.list is in fact empty and autoDeactivate is true by
default ). Then drools enqueues a deactivation task afterwords, which
deactivates the rule *before* even firing it.
From now on, things get a little weirder, every subsequent invocation of
the method setActive ( in response of bussinessRuleTask from our bussiness
process ) runs ok as that list now is not empty ( has one rule ).
Seems a race condition to me, but,..., Is there any way to deactivate
autodeactivation by default? Are we doing something wrong? Bug report?
Greets,
--
View this message in context: http://drools.46999.n3.nabble.com/Rule-does-not-fire-when-JBPM-asks-to-do...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 2 months