facts hierarchy
by Giovanni Motta
Hi all, i have a question concerning facts hierarchy, i'm looking for some
hint as i suppose the same problem could have been faced by someone on the
list.
I try to eplain with an example:
- Suppose to have a tree of facts, each object representing an UI widget.
<root>
<A id="1">
<B />
</A>
<A id="2">
<B />
</A>
</root>
- The individual elements A(1), B, A(2), B are mapped to facts, that are
inserted in a KnowledgeStatefulSession
- A rule exists that states that when an object A is selected, the B object
is automatically selected
- An event occurs that causes selection of node A(1)
The expected result is, obviously, that only the B element that is
descendant of A(1) must be automatically selected
I'm trying a way to express the 'descendant' relationship in LHS construct.
The rule will look like:
rule "A requires B"
when
$fact1: NodeFact(id == "A", selected == true)
$fact2: NodeFact(id == "B", selected == false, this DESCENDANT-OF $fact1)
then
$fact2.setSelected(true);
end
What is, in your opinion, the best way to handle this situation? What should
replace the fake "DESCENDANT-OF" match?
Do i need to use a function that returns the list of descendant nodes of
$fact1 and then match $fact2 against that?
Will this be fast when dealing with large trees?
Any suggestion will be appreciated, thank you.
Giovanni
16 years
Does not execute => builder.addPackageFromDrl(new InputStreamReader(this.getClass().getResourceAsStream(ruleFile)))
by mikexr
I am trying to execute a proof of concept. I have some code that runs a
rule. It works in Eclipse, but for some reason doesnt in Netbeans. I want
to get it working within a POJO Service Engine in Glassfish ESB and have is
execute as part of a BPEL orchestration. It does not throw an exception,
but it steps over that one piece of code
public void xmlImpl(String is) throws JAXBException,
FileNotFoundException, Exception {
try {
// unmarshal xml file
// JAXBElement<EnrollmentRequest> enrollment =
jaxbUnmarshalFromInputStream(is);
EnrollmentRequest enrollment = jaxbUnmarshalFromInputStream(is);
// setup rules engine
RuleRunner rule = new RuleRunner();
String[] rules = {"../rules/834rules.drl"};
// execute rules on xml file
try {
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
PackageBuilder builder = new PackageBuilder();
for (String ruleFile : rules) {
System.out.println("Loading file: " + ruleFile);
builder.addPackageFromDrl(new
InputStreamReader(this.getClass().getResourceAsStream(ruleFile)));
}
Package pkg = builder.getPackage();
ruleBase.addPackage(pkg);
WorkingMemory workingMemory = ruleBase.newStatefulSession();
Object fact = new Object();
fact.equals(enrollment);
System.out.println("Inserting fact: " + fact);
workingMemory.insert(fact);
System.out.println("Firing Rules");
workingMemory.fireAllRules();
} catch (Exception e) {
e.printStackTrace();
}
// marshall changes out to xml file
jaxbMarshalToOutputStream(enrollment, new
FileOutputStream("F:/data/workspaces/enrollmentPOC/data/xmlenrollment.xml"));
} catch (JAXBException je) {
je.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
try {
} catch (Exception ex) {
java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.SEVERE,
null, ex);
}
return;
}
}
If anyone has any suggestions I would appreciate them. At this point I'm
stuck
Thanks
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Does-not-execute-buil...
Sent from the Drools - User mailing list archive at Nabble.com.
16 years
Getting started with Drools Fusion
by Tina Vießmann
Hello everybody :)
I'm completely new to the Drools universe. I've discovered Drools, or more
specifically Drools Fusion, by looking for a powerful CEP engine.
I've read the DF user guide and came up with some issues about DF features.
It would be great, if anyone can give me some explanations and/or refer to
different information sources.
My questions:
1. Persistence of events:
I know that DF can store events explicitly and implicitly. But does it
store events in persistent (e.g., I can continue my computation after a
reboot)? If it does, how are the events stored?
2. Sliding windows:
It's written that a window contains the last X events/the event occurred
in the last X time units. Is it somehow possible to specify a window for
process only old events - which does not catch up to the latest event?
(Lets assume we have the times A, B and C with: A < B < C and C ==
current time. Is it possible to specify a window that process events
occurred between A and B?)
So are more complex windows like described in chapter 7 of the book 'Event
Processing in Action' (see http://www.manning.com/etzion/) possible?
Are there any (step-to-step) tutorials / how-tos about simple DF programs?
In case my questions are stupid because they can be answered when knowing
Drools, but I've got absolute now experience using Drools. At the moment I
kind of have the feeling, Drools is a little bit too complex for just
using to implement CEP applications...
Thanks for any help! :)
Tina
16 years
Getting started with Drools Fusion
by Tina Vießmann
Hello everybody :)
I'm completely new to the Drools universe. I discovered Drools, or more
specifically Drools Fusion, by searching for a powerful CEP engine.
I've read the DF user guide and came up with some issues about DF
features. It would be great, if anyone can give me some explanations
and/or refer to different information sources.
My questions:
1. Persistence of events:
1. About sliding windows:
It's written that a window contains the last X events/the event
occurred in the last X time units. Is it somehow possible to specify a
time window to
16 years
Frequently updated facts and truth maintenance
by bill simms
Hello,
Recently I've been using Drools (version 5.0.1) to build a small sensor
monitoring application and have run into memory consumption issues that seem
to be related to logically inserted facts. The way it is set up there are
Sensor facts which carry numerically encoded "flags" that can signal certain
properties about that Sensor. My intent was to create rules to detect these
flags and insert marker facts in order to abstract how flagging is handled
and make it easier for other rules to use this information. Here is an
example of the rules I'm using:
declare DeltaFlagged
> sensor : Sensor @key
> end
> rule "Delta Flagged"
> agenda-group "delta flag inference"
> auto-focus true
> when
> $sensor: Sensor(eval(isDeltaFlag(flag)))
> then
> DeltaFlagged flagged = new DeltaFlagged();
> flagged.setSensor($sensor);
> insertLogical(flagged);
> end
>
Each Sensor is updated at regular intervals from outside of the rule engine,
several hundred times a day. Similar to the examples given here (
http://blog.athico.com/2007/03/writing-rules-for-monitoring-and-time.html).
This works very well for short periods of time. However, after many
days of operation I can observe a clear memory leak trend. When I inspect a
memory dump I see that there are many LogicalDependency objects created and
stored by the truth maintenance system (on the order of several million) for
each "flag" fact that has been logically inserted. Only one fact is being
inserted per Sensor as expected. I am working under the impression that
Drool's truth maintenance should not be recording duplicate dependencies, so
I'm wondering what I have done wrong with the equals() and hashcode()
methods of my objects to cause Drools to treat each activation of this rule
as a new dependency. My Sensor objects use the default hashcode and equals
methods. Thank you in advance.
Bill
16 years
Drools Flow: how to get knowledge session ID from WorkItem
by Alan.Gairey@tessella.com
The subject says it all really: is there any way of determining the
knowledge session ID from the WorkItem argument (or WorkItemManager
argument?) passed in to the executeWorkItem method of an implementation of
the WorkItemHandler interface?
Any help would be very much appreciated.
Thanks,
Alan
16 years
Bulk-Retract speed conundrum
by djb
Hi Drools aficionados,
This is further to my request to improve speed. As requested previously, I
am providing an example rule.
So, I found that by only retracting facts after processing multiple claims,
instead of after every claim, I managed to improve speed from 300ms per
claim to 50ms! We need it to be sub-170ms to be a viable option.
But, I need to retract facts. As you can see, if I add new Claim data, it
might match the last guy's claim data (Bad!). It would appear that
'disabling' the data would require an update and take as much time as a
retract.
So, is there any way around this? Am I stuck with 300ms per claim? Would
changing to sequential stateless session be possible, or worthwhile? If I
can't improve the speed, I will have to advice against Drools for the
project.
regards,
Daniel
---------------------
My rules look like this:
rule "RULE_2090"
when
$cl: ClaimLine(historic == false, code == 000000003908, type == "T")
$historic: ClaimLine(historic == true, code >= 000000000052 && <=
000000000052, type == "P", $dt : date)
eval(Utilities.isWithinTimePeriod($dt, $cl.date, "Y", "99"))
$historic_many: ArrayList(size >= 0) from collect(ClaimLine(historic ==
true, code >= 000000000052 && <= 000000000052, type == "P"))
then
String ruleName = drools.getRule().getName();
results.addMessage(ruleName, "000000003908","Only 1 test per day
");
results.setRefer("R");
end
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Bulk-Retract-speed-co...
Sent from the Drools - User mailing list archive at Nabble.com.
16 years
Drools Planner - Time Slots vs Time Periods
by awuttke
Hello,
most of the Drools Planner examples deal with fixed time slots. Lessons are
assigned to defined time slots, nurses are assigned to work at fixed time
slots, etc. So the time slots start at a defined time and have a defined
length.
What I'm looking for is an example which is dealing with flexible time
periods instead (flexible start times and durations).
E.g. a work item needs a defined time to be processed on a machine
(processing time can vary for each work item). In order to keep all machines
busy all the time the work items should be scheduled without gaps if
possible. In addition work items should be assigned only to machines that
have a certain capability required by the work item. Some work items might
have a defined order in which they have to be processed. Some items can have
a defined time when they should start, etc.
I assume that in this case the planner move logic would have to be changed.
Instead of exchanging fixed time slots the time periods would have to be
modified.
Any idea how this could be modelled / implemented?
Thanks for any comment on this,
Andreas
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Planner-Time-S...
Sent from the Drools - User mailing list archive at Nabble.com.
16 years