Event insert to session with 'not( after this..)'
by RichardAmbridge
If I declare an event like:
declare Signature
@role ( event )
@timestamp(timestamp)
end
where timestamp is a long value set to the System.currentTimestamp()
and if I have a rule that has in it
$s : Signature(name=="YYYY")
not(Signature(name=="XXX", this after [0s,50h] $s))
If i insert a Signature that has name=YYYY, then after 50 hours this rule
will fire.. which is great.
However, we have a situation where sometimes we need to reload all our
rules.
Today, I grab all the Objects from the session
engine.getKsession().getObjects()
and store them in a file (serialize), then recreate the session and reinsert
all the objects again.
However, this resets the time window for the event...
So if i insert Signature with name=YYYY, wait 48 hours, reload the session
then the rule will not fire for another 50 hours, instead of in 2 hours
time.
The value of @timestamp is still set to the original time (48 hours ago) and
if I check
EventFactHandle handle=(EventFactHandle) ksession.insert(s);
handle.getStartTimestamp();
the value of StartTimestamp is set to 48 hours ago..
Is there anyway I can get the rule to fire at the correct time?
Many thanks
Ric
Running Drools 5.3.0
--
View this message in context: http://drools.46999.n3.nabble.com/Event-insert-to-session-with-not-after-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 2 months
Decision table layouts
by vamsi goli
Hello,
We are trying to incorporate Drools to our architecture and make sure all
rules are separated from our current code base. So I am totally new and I
am working on creating a decision table using the Guvnor Web guided editor.
So my question: I am trying to create a decision table with vertical
layout, I cannot find anywhere in the documentation on how to do it, Our
company has given us some training documentation from redhat which has
sample examples of different decision table layouts but I am unable to find
a way of doing that way.
Please help.
thanks
13 years, 2 months
SimpleScoreCalculator
by André Fróes
Hello, since i'm not moving a step from where I am at dsl rule, I'm trying
to do it with SimpleScoreCalculator, but the same is happening.
------------
public HardAndSoftScore calculateScore(Distributor distributor) {
int hardScore = 0;
int softScore = 0;
for (Engineer e : distributor.getEngineerList()){
long skill = e.getSkillEngineerList().get(0).getSkill().getId();
int requiredWorktime = 0;
long requiredSkill = 0l;
for (WorkOrder o : distributor.getWorkOrderList()){
if (e.equals(o.getEngineer())){
requiredWorktime += o.getRequiredWorktime();
requiredSkill = o.getRequiredSkills().get(0).getSkill().getId();
}
}
int engineerAvailableTime = e.getWorktime() - requiredWorktime;
if (engineerAvailableTime < 0 ){
hardScore += engineerAvailableTime;
}
if (requiredSkill == skill){
softScore += requiredSkill;
}
}
return DefaultHardAndSoftScore.valueOf(hardScore, softScore);
}
------------
wouldn't that have to fit since i'm comparing the 1st attribute of each
skill list from engineers and workorders? And how can I weight which
engineer would be better to a determined workorder if the workorder have
more skills and so does the engineer?
13 years, 2 months
Comparing 2 Lists [Planner]
by André Fróes
Hello everyone!
How can I compare 2 lists with a rule?
I upgraded my basic model to a more complex one now, but now I hit a wall.
My WorkOrder have a List of skills, and my Engineer also have a list of
Skills and I have to compare one with another.
Example:
Engineer A have skill ABC 1
Engineer B have skill ABC 2
Engineer C have skill ABC 3
WorkOrder A needs an engineer with skill ABC 3
WorkOrder B needs an engineer with skill ABC 1
WorkOrder C needs an engineer with skill ABC 2
The result should be this:
Engineer A will receive WorkOrder B
Engineer B will receive WorkOrder C
Engineer C will receive WorkOrder A
---------------
I am able to sort it by time, but not by skill, and I don't know how to
loop over each list to find if one have the skills needed to fulful the
other. These are my classes involved:
WorkOrder attributes:
--------
private int requiredWorktime;
private Priority priority;(enum)
private Severity severity;(enum)
private List<SkillWorkOrder> requiredSkills;
--------
Engineer attributes:
--------
private int worktime;
private String name;
private List<SkillEngineer> skillEngineerList;
--------
Skill attributes:
--------
private String name;
--------
both SkillEngineer and SkillWorkOrder are classes that simple receives the
named class and a Skill:
Eg:
private Engineer engineer; //Or WorkOrder
private Skill skill;
Is it possible to iterate over these 2 lists, by drool rule, to check wich
engineer have most coincidences with an workorder? (Eg: if and Engineer
have skill ABC1, ABC2 and a WorkOrder needs an engineer with skill ABC1,
ABC2 and ABC3 he would be choseng among the others because his skills)
13 years, 2 months
how to get the pkg from guvnor by KnowledgeAgent?
by ethan
Dear all, I want to deploy pkg from guvnor by KnowledgeAgent. The code like
below:
KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent(
"MyAgent" );
kagent.applyChangeSet(
ResourceFactory.newUrlResource("http://localhost:8080/guvnor/org.drools.guvnor.Guvnor/package/test/LATEST...")
);
KnowledgeBase kbase = kagent.getKnowledgeBase();
But I got an error from guvnor:
WARN 19-02 01:02:56,853 (RulesRepositoryManager.java:getRulesRepository:70)
Creating RulesRepository with default username.
=============== session-guest-33
INFO 19-02 01:02:56,856 (DemoAuthenticator.java:authenticate:54) Demo
login for user (null) failed: unsupported username/credential.
WARN 19-02 01:02:56,857 (AuthorizationHeaderChecker.java:loginByHeader:65)
Unable to authenticate for rest api: null
I think the problem is the knowledgeAgent can't authenticate sucessful, but
I don't know how to set the username and password when knowledgeAgent send
request to get pkg. Anybody can help me? Thanks.
--
View this message in context: http://drools.46999.n3.nabble.com/how-to-get-the-pkg-from-guvnor-by-Knowl...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 2 months
Garbage collection and sliding windows (Drools 5.5.0 Final)
by tai-atari
Hi everyone,
I'm currently doing some performance tests with Drools Fusion (5.5.0) and
have run into some issues with EventFactHandles which are not being garbage
collected. VisualVM tells me that for every 200k inserted events, about 15k
EventFactHandle objects are still left as live objects.
Current setup:
1) Drools 5.5.0 Final
2) Oracle JVM 1.7.0_06 on Windows 7
3) STREAM mode
4) 1 ksession at startup
5) 1 drl file with
- a single sliding window "over window:time(10s)"
- 1 entry-point
- declared event class as '@role( event )'
- only action being taken as events shows up is a println()
Events are being expired (and removed) properly from the 10 second sliding
window, which is verified by checking the
getFactCount() from the WorkingMemoryEntryPoint. Iterating through all
EventFactHandles also show that isExpired is false on all of them (and the
count is correct). But even though the events are removed from the sliding
window, they do not seem to be available to the GC.
If dispose() is called on the ksession, garbage collection is performed
properly. I get this same behavior with over "window:length" as well. And
even without using sliding windows at all unless I specifically add a
"@expires ( 1s )" to the event class declaration.
Has anyone else seen this behavior? After a couple of million events the
memory consumption becomes a pain and the only recovery action which seems
to be available is to dispose the ksession and start over. This means state
is lost and it requires the application to save and reinsert all facts to
the ksession, then start adding events again.
Any help on how to troubleshoot this further would be really appreciated.
--
View this message in context: http://drools.46999.n3.nabble.com/Garbage-collection-and-sliding-windows-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 2 months