Planer: Rule design causing problem
by Reinis
Hi,
I have application similar to nurse rostering. You have projects,
resources and dates. You assign resource on date to project (thus you
have an assignment).
Now, I have rule that is supposed to keep assignments "together". Most
of the assignments are indeed kept together with some few but very nasty
exceptions.
I have attached the image (Schedule.png) to visualize this. In the image
you see assignments for Project 9 being planed en block from 13. July
till 20. July (green box at the bottom). But then there are couple of
assignments (above, underlined in red on 2. January and on 22. February)
totally "out of the row".
I attempt to "pull" assignments together with this rule:
rule "penalize assignment dispersion to goLive"
when
$project : Project(goLive != null)
$furthestAssignment : Assignment(project == $project, interval
!= null, $project.goLive.compareTo(interval.end) >= 0)
not Assignment(id > $furthestAssignment.id, project ==
$project, interval != null, $project.goLive.compareTo(interval.end) >=
0, distanceToGoLive >= $furthestAssignment.distanceToGoLive)
then
insertLogical( new IntConstraintOccurrence("penalizing
assignment dispersion", ConstraintType.NEGATIVE_SOFT,
$furthestAssignment.distanceToGoLive(),
$project) );
end
There are number of other rules. The ones checking hard constraints are
trivial and I will just omit them, the soft constraint rules might have
impact on this issue although unlikely (I removed all the other soft
constraint rules and still got similar weird result). Here are the other
rules:
rule "penalize assignment with the resource without the capability
required by project option"
when
$projectOption : ProjectOption()
$penalizedAssignments : Number(intValue > 0)
from accumulate ( Assignment($penalizedAssignment : this,
project == $projectOption.project, resource != null,
resource.capabilities not contains $projectOption.name),
count($penalizedAssignment) )
then
insertLogical( new IntConstraintOccurrence("there are
assignments with the resource without the capability required by project
option", ConstraintType.NEGATIVE_SOFT,
$penalizedAssignments.intValue(), $projectOption,
$penalizedAssignments) );
end
rule "penalize assignment with the resource without the capability
required by project constraint"
when
$projectConstraint : ProjectConstraint()
$penalizedAssignments : Number(intValue > 0)
from accumulate ( Assignment($penalizedAssignment : this,
project == $projectConstraint.project, resource != null,
resource.capabilities not contains $projectConstraint.name),
count($penalizedAssignment) )
then
insertLogical( new IntConstraintOccurrence("there are
assignments with the resource without the capability required by project
constraint", ConstraintType.NEGATIVE_SOFT,
$penalizedAssignments.intValue(), $projectConstraint,
$penalizedAssignments) );
end
Am using Drools Planer 5.3. and biting out my teeth on this issue for
about 3 moth already. Any help is worth half the kingdom to me right now.
br
Reinis
13 years, 4 months
How can I nested rules
by leonardo_josue
Hi everybody, I hope some of you can tell me if I can do something with my
problem.
I have a table in a DB with medical information from too many patients. This
information was captured in paper and after put into the table. The
questions have a sequence, and a few answers depend of other answers, for
example:
P1. Age:____
P2. Gander: 1: Female, 2: Male
--> if P1 >= 12 and P2 = 1 then go to p3, else go to p5
P3. How many times have you been pregnant? 0, 1, 2, 3, 4, 5, ______
--> if number > 1 go to P3 else P5
P4. How many babes were born alive? 0, 1, 2, 3, 4, 5, _______
P5. Do you smoke? 1: no, 2: yes
In the table I have something like this:
mysql> SELECT * FROM table;
|id||P1|P2|P3|P4|P5|STATUS
------------------------------
|1|34|1|3|2|1|NULL
|2|10|1|3|2|1|NULL
|3|21|2|1|1|1|NULL
|4|66|1|0|1|1|NULL
|5|14|2|NULL|NULL|1|NULL
|6|09|1|NULL|NULL|1|NULL
I try to set STATUS = "OK" when information was consistent, i.e.
ID = 2. A girl of 10 years hardly been pregnant 3 times
ID = 3. A man can't get pregnant or abort
ID = 4. A woman can't abort if the number of times she has become pregnant
is zero
I'll try to use Drools to do something like this.
rule "Age and gender women"
no-loop
when
p : Person(p1 >= 12 && p2 = 1)
then
//execute rule "Pregnant"
end
rule "Pregnant"
no-loop
when
p : Person(p3 > 1)
then
//execute rule "Aborts"
end
rule "Pregnant"
no-loop
when
p : Person(p4 <= P3)
then
//it's ok
p.Status = 'OK'
end
Is this possible??? I read than you can't nested rules, but I want to know
if exist some way to do. Since now my thanks for any help.
Best regards.
Leo.
--
View this message in context: http://drools.46999.n3.nabble.com/How-can-I-nested-rules-tp4020488.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 4 months
Calling queries or collect() from functions
by Miguel Paraz
Hi,
I have a rule like:
rule "Rule1"
when
$fact: Fact1()
$allFacts: ArrayList() from collect(Fact1())
then
insert(new Fact2($allFacts.size()));
end
I want to compute $allFacts inside a function since I will use it across
different rules.
This doesn't work because it is not valid Java syntax:
function int size() {
ArrayList a = ArrayList() from collect(InQueuePredicate());
return a.size();
}
Could I put this in a named query, and call it from a function?
Thanks!
Miguel
13 years, 4 months
Best practices for Web UI and REST Services
by Miguel Paraz
Hi,
I'm connecting Drools to the Web, both for UI (via JSON+JavaScript),
and REST services.
What are the best practices, or, are there reference apps for this?
As I understand it, the architecture is like: there must be a single
thread running Drools, then with concurrent data structures (e.g.
BlockingQueue) to talk to the web threads.
For synchronous requests, we can send Commands from the web, and
receive BatchExecutionRequests to send back to the UI.
For asynchronous events, this is more challenging - we can have live
queries that are connected to listeners which push the changes to the
UI layer. For the Web UI, the results will need to be queued up until
the client picks them up, For the REST service, we can trigger a
callback to the client's URL.
Any experiences here?
Thanks!
Miguel
13 years, 4 months
Re: [rules-users] Eclipse Debugging Drl file
by benq2188
Hello,
I faced with the same problem. Breakpoints are not being hit by debugger. I
have Eclipse SDK version: 4.2.1 and went through the reference manual of
Drools and followed each step carefully.
-Installed GEF
- Downloaded drools-distribution-5.4.0.Final.zip
-Unzipped it into Eclipse main folder
-Restarted Eclipse
-Defined run time based on the latest Drools project jars included in the
plugin
itself.
-Created Drools Project
-Created new launch configuration for Drools Application.
-Put a breakpoint in the helloworld simple project on the first line of the
section "then".
When I debug it as Drools Application, debugger stops in Java breakpoints
but doesn't stop in drl rule.
Any solutions, how can I fix it?
Thanks in advance.
--
View this message in context: http://drools.46999.n3.nabble.com/Eclipse-Debugging-Drl-file-tp3870257p40...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 4 months
Drools 5.5.0.CR1 is using a broken cdi-api version
by Cristiano Gavião
Hello,
I'm using Tycho to create a dependency P2 repository (OSGi environment)
containing JBPM 5.4.0.CR1 and DROOLS 5.5.0.CR1.
I got some problem to properly setup the dependencies for the cdi-api.
The bundle knowledge-internal-api has a dependency to cdi-api (version
1.0-SP4), but this version is tied to this:
<groupId>org.jboss.spec.javax.interceptor</groupId>
<artifactId>jboss-interceptors-api_1.1_spec</artifactId>
<version>1.0.0.Beta1</version>
And this 1.0.0.Beta1 version of org.jboss.spec.javax.interceptor was not
well osgified. it doesn't have a Bundle-SymbolicName !
I could handle this problem using a newer version of it:
<dependency>
<groupId>org.jboss.spec.javax.interceptor</groupId>
<artifactId>jboss-interceptors-api_1.1_spec</artifactId>
<version>1.0.1.Final</version>
</dependency>
I won't use cdi anyway, but it could help others that decide to use jbpm
with eclipse.
regards,
Cristiano
13 years, 4 months