Re: [rules-users] simple subtraction in drools 5.3 fires rules
by George
Your first rule did not fire for me as expected using drools 5.3. Please ignore my previous post.
oranoh <olaf.raether(a)emerson.com> wrote:
>I have a simple class
>
>public class Dummy {
>
> private int x1, x2, y1, y2;
> public Dummy(int x1, int y1, int x2, int y2) {
> this.x1 = x1;
> this.y1 = y1;
> this.x2 = x2;
> this.y2 = y2;
> }
> public int getX1() {
> return x1;
> }
> public int getX2() {
> return x2;
> }
> public int getX2M150() {
> return x2-150;
> }
> public int getY1() {
> return y1;
> }
> public int getY2() {
> return y2;
> }
>}
>
>And a the following Rule:
>
>rule "DummyRule"
>ruleflow-group "DummyTest"
> when
> d1 : Dummy()
> d2 : Dummy(y2 == d1.y1, (x1 == (d1.x2 -150) || x2 == (d1.x2 -150)))
> then
> System.out.println("Rule DummyTest fired");
>end
>
>Executing the rule with the following Data - The Rule fires !!! - WRONG
>
>Dummy d1 = new Dummy(-1050, -900, -750, -600);
>Dummy d2 = new Dummy(-1050, -1200, -750, -900);
>
>When I modify the Rule the follow way
>
>rule "DummyRule"
>ruleflow-group "DummyTest"
> when
> d1 : Dummy()
> d2 : Dummy(y2 == d1.y1, (x1 == d1.x2M150 || x2 == d1.x2M150))
> then
> System.out.println("Rule DummyTest fired");
>end
>
>
>with the same Data - The Rule fires not !!!! - What is CORRECT
>
>
>This problem comes up, when I move from drools 5.01 to 5.3
>
>Can anybody help ?
>
>
>
>
>
>--
>View this message in context: http://drools.46999.n3.nabble.com/simple-subtraction-in-drools-5-3-fires-...
>Sent from the Drools: User forum mailing list archive at Nabble.com.
>_______________________________________________
>rules-users mailing list
>rules-users(a)lists.jboss.org
>https://lists.jboss.org/mailman/listinfo/rules-users
13 years, 8 months
drools-planner drl file help
by Ricardo
Hi, My use case is 2 rooms and multiple table in various size, I want planner
to organize the table in the available rooms in our case 2 rooms.
room1 - 10x10 (length x width)
room2 - 5x5
table1 - 5x5 (length X width)
table2 - 2x3
table4 - 2x3
table5 - 7x4
table6 - 4x2
*my drl file as follows...*
rule "requiredRoomSpace"
when
$room : Room($length : length, $width : width, $size : size)
$requiredSizeTotal : Number(intValue > $size) from accumulate(
Table(
room == $room, length < $length, width < $width,
$requiredSize : requiredSize),
sum($requiredSize)
)
then
insertLogical(new IntConstraintOccurrence("requiredRoomSpace",
ConstraintType.NEGATIVE_HARD,
$requiredSizeTotal.intValue() - $size, $room));
end
//
############################################################################
// Calculate score
//
############################################################################
// Accumulate hard constraints
rule "hardConstraintsBroken"
salience -1 // Do the other rules first (optional, for performance)
when
$hardTotal : Number() from accumulate(
IntConstraintOccurrence(constraintType ==
ConstraintType.NEGATIVE_HARD, $weight : weight),
sum($weight) // Vote for
http://jira.jboss.com/jira/browse/JBRULES-1075
)
then
scoreHolder.setHardConstraintsBroken($hardTotal.intValue());
end
*/when i run the program...it assign all the tables into room1 only...I am
not sure what went to wrong...help will be appriciated....if need more info
..I will provide.../*
warm regards,
-----
with kind regards,
--
View this message in context: http://drools.46999.n3.nabble.com/drools-planner-drl-file-help-tp4018104....
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months
Re: [rules-users] Planner and domain modeling
by ge0ffrey
Yes, you're right: it's because of performance reasons during incremental
score calculation.
If a CloudComputer changes during planning too, it should be set as dirty in
Drools by Planner calling (workingMemory.modify(computer)). If the whole
computer is made dirty, that has a serious effect on incremental score
calculation. However, since recently drools supports making individual
fields dirty, so there is definitely room for innovation there.
I 've been thinking about supporting bi-directional planning variables in
Planner (think JPA mappedBy), but haven't gotten around to it yet.
Now, currently, that doesn't mean you can't model CloudComputer with a
getProcessList, it just means you can't use CloudComputer.getProcessList()
in the score rules or custom planner code (if any) currently (until
bi-directional planning variables are supported). Also, you might need to
take the getBestSolution() and refresh all it's computer's
getProcessList()'s before sending it to your other systems.
--
View this message in context: http://drools.46999.n3.nabble.com/Planner-and-domain-modeling-tp4018117p4...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months
Drools Number to String Coercion Issue
by gqmulligan
Is there any way to let Drools handle a String, Number comparison without
having to manually do type conversions?
I am having trouble comparing a string to an integer in a rule. The rule can
be simplified to the following where fields is just a
The problem is that given this rule, even when a = "10", the consequence is
never fired. According to the documentation at section 4.8.3.3.3 "Coercion
is always in favor of the field type and not the value type". So this rule
seems like the 10 should be coerced to "10" and then this comparison should
return true, but it doesn't.
If a change the 10 to "10" the rule succeeds. Also if I do
Integer.parseInt(fields["a"]) the rule succeeds.
The more interesting part is if I change the operator to > or < and change
the value of fields["a"] appropriately the rule still succeeds! Is this
because > and < aren't technically valid operators on Strings so the two
operands are converted to numeric values and compared?
I just noticed if I change the dialect to "java" then everything works as I
want. However, I still do not understand why it didn't work at first or if
it is safe to count on a different dialect to fix the issue.
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Number-to-String-Coercion-Issue-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months
Please I can I do this???
by paco
I want to detect the conflict between the rules with Drools Verifier. For
example the first condition of the second rule is present in the first rule
and the actions to perform are the same in both rules as they demonstrate in
the following case. It works very well when these rules belong to the same
drl file.
--------- fichier a.drl---------------------------
rule "a"
no-loop true
ruleflow-group "group1"
dialect "mvel"
when
A==0
then
Action1
end
rule "b"
no-loop true
ruleflow-group "group1"
dialect "mvel"
when
A==0 && B==1
then
Action1
end
The problem arises when I separated its rules and that I have to put each in
its own file
---------------- a.drl----------------
rule "a"
no-loop true
ruleflow-group "group1"
dialect "mvel"
when
A==0
then
Action1
end
------------------b.drl--------------------
rule "b"
no-loop true
ruleflow-group "group1"
dialect "mvel"
when
A==0 && B==1
then
Action1
end
I can no longer detect this problem with Drools Verifier.
Does anyone ever encountered this problem?
How can I do to write a small program to audit if this case?
--
View this message in context: http://drools.46999.n3.nabble.com/Please-I-can-I-do-this-tp4018135.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months
Not able to debug Drools Rules
by Annie
Hi,
I am using 'drools-distribution-5.4.0.Final' and 'eclipse helios 3.6.2' . I
have created a simple example using rules, it runs correctly but when trying
to debug it as drools application I got the following error in 'error log' :
Plug-in 'com.google.gwt.eclipse.core' contributed an invalid Menu Extension
(Path:
'com.google.gdt.eclipse.suite.popupMenu.file' is invalid):
com.google.gwt.eclipse.core.actions.AddResourcesToClientBundleAction
Can anyone help me to identify the problem?
Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/Not-able-to-debug-Drools-Rules-tp401813...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months
issue with date comparison
by sumatheja
Hi,
I've a fact which is retrieved from database using hibernate. The date
format that comes in is "yyyy-mm-dd", java.util.Date. The fact has two
variables *startDate* and *endDate. *I want to check if the the *current
date* lies between these two. Since the current date is not constant I'm
trying to use a global variable, which I would setbefore firing the rules.
My question is what should be the datatype of this global variable. If I
use Date the format is completely different. If I use String it says that
date can't be compared with string.
However if I hard code the value of current date in "*dd-MMM-yyyy*"
rule fire fine. Can someone please suggest me a way to achieve this. Thanks
in advance.
--
cheers
Sumatheja Dasararaju
13 years, 8 months