Drools verifier
by FrankVhh
Hi all,
Triggered by a post on this forum, I decided to try a testcase
implementation of Drool Verifiier.
I manage to write some code that does not produce any errors at runtime,
which is good. Unfortunately, it doesn't produce any errors/warnings/notes
on my rulefile either, which isn't good.
The drl file consists of some duplicate rules, and since the file is only
part of a ruleset, there might be some gaps as well.
I pasted the java-code below. Does anyone see where I am going wrong?
Thanks in advance!
Regards,
Frank
VerifierBuilder vBuilder =
VerifierBuilderFactory.newVerifierBuilder();
Verifier verifier = vBuilder.newVerifier();
String ruleText =
"C:\\Users\\Frank\\Documents\\DroolsWorkSpaces\\EmpiricalExperiments\\Financial
Rules\\src\\main\\rules\\clearancerules.drl";
verifier.addResourcesToVerify( ResourceFactory.newReaderResource(
new StringReader( ruleText ) ), ResourceType.DRL );
verifier.fireAnalysis();
VerifierReport result = verifier.getResult();
for(VerifierMessageBase base: result.getBySeverity(
Severity.ERROR ) ){
System.out.println( base );
}
for(VerifierMessageBase base: result.getBySeverity(
Severity.WARNING ) ){
System.out.println( base );
}
for(VerifierMessageBase base: result.getBySeverity( Severity.NOTE )
){
System.out.println( base );
}
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-verifier-tp268...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years
simple subtraction in drools 5.3 fires rules
by oranoh
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.
14 years
Re: [rules-users] Planner and domain modeling
by ge0ffrey
Garf wrote
>
> Ah, I see.
> It would be handy to update the docs to clarify such (is there a community
> wiki around?)
>
Not sure. Normally, I'd like to document as much as possible, but I 'd
rather leave this one undefined for now and see how people solve, instead of
pushing people into a certain direction which I haven't tried out decently
in any of the examples yet (or any of the alternative directions).
Try it out, let me know what works best for you. Also, a pull request for
the docs is welcome, if you've verified the changes :)
--
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.
14 years
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
14 years
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.
14 years
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.
14 years
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.
14 years
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.
14 years