Redundancy check option not working in Drools Verifier 5.4
by worldofprasanna
Hi All,
I tried to use Drools Verifier to validate the available rules. I got all
the warning types like MISSING_EQUALITY, ALWAYS_FALSE. But I couldn t get
the redundancy warning, eventhough i have given the duplicate rules
explicitly.
I am using Drools Verifier 5.4.0.Final.
Herewith given the following details,
1. Sample rule file
rule "rule 1"
when
$server : Server(processors==2, memory==1024)
then
System.out.println("rule 1")
end
rule "rule 2"
when
$server : Server(processors==2, processors!=2)
then
System.out.println("rule")
end
rule "rule 3"
when
$server : Server(processors==2, memory==1024)
then
System.out.println("rule 3")
end
2. Code which verifies the validity of the rule.
VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
Verifier verifier = vBuilder.newVerifier();
verifier.addResourcesToVerify(new
ClassPathResource("sample.drl",
DroolsVerifierCheck.class),
ResourceType.DRL);
verifier.fireAnalysis();
VerifierReport result = verifier.getResult();
// To display the warnings in verifier.
Collection<VerifierMessageBase> warningMessages =
result.getBySeverity(Severity.WARNING);
for (VerifierMessageBase msg : warningMessages) {
System.out.println("Note: " + msg.getMessage() +
" type: " + msg.getMessageType() +
" on: " + msg.getFaulty());
}
Problem
In the sample rule, you can find rule 1 and rule 3 are same. But I didn t
get the warning for redundancy.
Research done
When i debug the code, i found like the rule "Find redundant pattern
possibilities from rule possibilities" and "Find redundant restrictions from
pattern possibilities" are loaded into the Knowledge base created and tagged
with Agenda group as Main, but those are not present in the Knowledge
session created (I mean after inserting the objects into the Knowledge
session in the code : VerifierImpl.java).
Also can anybody explain when a rule will be present in the knowledge base
but not selected by the agenda. I haven t modified anything in the
AgendaFilter and its given the default value ScopeAgendaFilter.
Kindly let me know why the redundancy warning is not given in my case ?
P.S : I have gone through the post below,
http://http://drools.46999.n3.nabble.com/Drools-verifier-td2681002.html
http://drools.46999.n3.nabble.com/Drools-verifier-td2681002.html
and at the bottom they have asked the same question, but there is no answer
available for it.
Thanks,
Prasanna.
--
View this message in context: http://drools.46999.n3.nabble.com/Redundancy-check-option-not-working-in-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months
Guvnor guided editor and non argument constructor
by Sean Su
It seems that the new fact created by the guided editor must be from
the java class that has the default non argument constructor in
Guvnor. There seems no way we can customize it to pass arguments in.
This would force us to provide setters to the object.
Is this a true statement?
Thanks
Sean
Sent from my iPad
13 years, 8 months
looking for advice
by Bobby Richards
I have not yet determined how I want to implement my problem and was hoping
to get some feedback.
I am using drools to migrate the logic from my automated currency trading
infrastructure. Each currency pair, i.e. eurusd has around
200 attributes associated with it.
This includes range values (high, low, average) for multiple time periods,
volatility information, bid/ask updates etc.
Currently I have classes associated for each, so say for range:
class Range {
double high;
double low;
double avg;
}
Range europe = new Range(); //european trading hours
Range us = new Range(); //us trading hours
Questions:
1. I am wondering if I should not just create a map that lists every
attribute per pair as a key ("eurusd:range:europe:high")? So essentially
my drools session will have one fact, not counting the incoming quotes. I
see on the list that this was a problem before the mvel updates but that
was a while ago.
2. When an incoming quote might modify a value, what is the performance
difference between using a rule to change the value or making the changes
outside of the ksession and referencing the facthandler to modify? Is one
method considered 'cleaner'?
Thanks,
Bobby
13 years, 8 months
Using GUVNOR for FUSION RULES
by Matteo Cusmai
Hi all,
i am novice on GUVNOR, but i would like to define my fusion rules by
graphical tool.
An example of my rules is:
rule "radiation-event"
salience 10
no-loop
when
$obs : RadiationObservation( $obsLocation : location, value > 10
) over window:length(1) from entry-point lowLevelSensorStream
not RadiationEvent( this meets[ 25s ] $obs, location
geoIsWithinDistance[ 5m ] $obsLocation )
then
insert(new RadiationEvent( $obs, "Radiation over 10",
Event.THREAT_HIGH, $obsLocation, $obs.getSensor() ));
end
rule "radiation-update"
salience 5
no-loop
when
$obs : RadiationObservation( $obsLocation : location, value > 10
) over window:length(1) from entry-point lowLevelSensorStream
$event : RadiationEvent( this meets[ 25s ] $obs, location
geoIsWithinDistance[ 5m ] $obsLocation )
then
Event e = Event.clone($event);
e.addObservation($obs);
insert( e );
retract($event);
retract($obs);
end
Is it possibile to define rules such the above using GUVNOR?
Are there some documentation or tutorial?
Thanks a lot in advance,
Matteo Cusmai.
13 years, 8 months
Best practice for 0..1 relations
by Christopher Dolan
What's the best way to encode a fact that's needed in the RHS but is not important in the LHS?
Consider a contrived example of computing total household income for single or married persons. I can think of two ways to encode this rule, but I don't like either of them:
Style 1: one rule for each scenario
rule "household income, single"
when
$p1 : Person()
not Relation(person1 == $p1, type == "spouse")
then
insertLogical(new Income($p1.getIncome()));
end
rule "household income, married"
when
$p1 : Person()
Relation(person1 == $p1, type == "spouse", $p2: person2)
then
insertLogical(new Income($p1.getIncome() + $p2.getIncome()));
end
Style 2: a single rule with a collection
rule "household income "
when
$p1 : Person()
$rels : List() from collect(Relation($p1 == person1, type == "spouse"))
then
insertLogical(new Income($p1.getIncome() + ($rels.size() == 0 ? 0 : $rels.get(0).getPerson2().getIncome()));
end
(please ignore the bug that the income may get inserted twice because people are spouses of each other)
Style 1 is more verbose, but more straightforward: it's how I think of the problem intuitively. Style 2 is much more compact, and is more maintainable if I need to add more predicates or a more complicated RHS. But the idea of needing a List when I know there will be exactly 0 or 1 related facts just seems wrong.
I've searched for some LHS syntax that assigns a variable without participating in boolean evaluation, but I've failed to find anything.
Chris
13 years, 8 months