Insert fact to be used as semaphore
by webfrank
Hi everybody, I'm new to drools and I would like to solve this simple
situation:
I have a rule which will fire when 3 or more events comes from entry-point
with level > 4 in a 10s window:
rule "Got 3 events"
when
not Alarm()
t : Number(intValue > 2) from accumulate (
e : Event( level > 4) over window:time(10s) from entry-point "queue",
count(e)
)
then
insert(new Alarm());
end
This way if more events comes with level > 4 no more alarms are sent.
I have another rule to retract Alarm object when more than 5 events comes
with level < 6 in a 10s window:
rule "Reset alarm"
when
a : Alarm()
c : Number( intValue > 5) from accumulate (
e : Event( level < 6) over window:time(10s) from entry-point "queue",
count(e)
)
then
retract(a);
end
The problem is that I got an infinite loop once I retract the Alarm object
and a new is inserted by the first rule.
How could I solve the problem? Probably a different approach but I'm still
learning.
--
View this message in context: http://drools.46999.n3.nabble.com/Insert-fact-to-be-used-as-semaphore-tp4...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Guvnor Data Enumeration
by nkhogen
In the Advanced Data Enumeration in Guvnor, it is possible to define list of
values for a field by fixing value on another field as follows
ZipCode, field1 = "55000", field2 = ['1','2','3']
ZipCode, field1 = "66600", field2 = ['10','20','30']
ZipCode is the fact class, field1 and field2 are its members.
But if I have something like
ZipCode, field1 = "OTHER", field2 value should not be bound. I should be
able to fill anything. But, Guvnor does not allow it once field1 is bound to
something else.
Please let me know if anyone has had this issue before.
--
View this message in context: http://drools.46999.n3.nabble.com/Guvnor-Data-Enumeration-tp4026633.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Re: [rules-users] Hi All,
by Davide Sottara
Quite likely though.. given who's involved ;)
T-Mobile. America's First Nationwide 4G Network
Bernard Szlachta <bernard.szlachta(a)nobleprog.co.uk> wrote:
>Thanks Mark.
>
>Regards,
>Bernard Szlachta
>www.nobleprog.co.uk
>+44 7929173122
>skype: nobleprog
>
>
>Check our Special Offers!
>http://www.nobleprog.co.uk/course+discounts
>
>
>On Tue, Nov 5, 2013 at 11:31 AM, Mark Proctor <mproctor(a)codehaus.org> wrote:
>
>> not right now. But there is nothing to stop someone doing an adapter up at
>> github, as a 3rd party project.
>>
>> MArk
>> On 5 Nov 2013, at 11:11, Bernard Szlachta <
>> bernard.szlachta(a)nobleprog.co.uk> wrote:
>>
>> Hi All,
>>
>> Does anyone know whether there is any chance that Drools API may comply
>> with
>> Application Programming Interfaces (API) to Knowledge Bases (KB) RFP) by
>> OMG
>> http://www.omg.org/cgi-bin/doc?ad/2010-6-9?
>>
>>
>>
>> Regards,
>> Bernard Szlachta
>> www.nobleprog.co.uk
>> +44 7929173122
>> skype: nobleprog
>>
>>
>> Check our Special Offers!
>> http://www.nobleprog.co.uk/course+discounts
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
>_______________________________________________
>rules-users mailing list
>rules-users(a)lists.jboss.org
>https://lists.jboss.org/mailman/listinfo/rules-users
12 years, 4 months
How to reduce transaction time
by arpitmittal
Hi All,
My front end application has transaction timeout of 200 milli Sec and my
code is taking upto 1200 ms to load & compile the DRL & store in cache.
So I tried to create a package of compiled DRL so that it saves compilation
time at run time, but to my surprise the reponse time increated to 3000
milli sec.
Please let me know how to reduce the transaction time?
*I was using below method to use DRL:-*
ruleBase = RuleBaseFactory.newRuleBase(
String droolsPath = folder + "/" + <DRL file name>;
File f = new File(droolsPath);
FileInputStream fInputStream = new FileInputStream(f);
Reader source = new InputStreamReader(fInputStream);
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl(source);
File processFile = new File(folder + "/" + < rules Flow File Name>);
FileInputStream processFileInputStream = new FileInputStream(processFile);
Reader processFileSource = new InputStreamReader(processFileInputStream);
builder.addProcessFromXml(processFileSource);
builder.compileAll();
Package[] pkg = builder.getPackages();
ruleBase.addPackages(pkg);
WorkingMemory workingMemory = ruleBase.newStatefulSession();
workingMemory.insert(customer);
workingMemory.startProcess(this.processName);
workingMemory.fireAllRules();
*I am using below code while using package:-*
Resource resourceRuleFlow = (Resource)
ResourceFactory.newFileResource(<rules Flow File path>);
Resource resourcePackage = (Resource)
ResourceFactory.newFileResource(<package File path>);
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(resourceRuleFlow, ResourceType.DRF);
kbuilder.add(resourcePackage, ResourceType.PKG);
kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
ksession.insert(customer);
ksession.startProcess(this.processName);
ksession.fireAllRules();
My understanding is if we are using package which contains compiled rules
then it should take less time as compared to DRL file.
Please help me how to sort out this issue..
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-reduce-transaction-time-tp402663...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Optaplanner - Issue with real-time, chained and shadow variables
by Juan Ignacio Barisich
Hi everybody
I am using optaplanner in real-time style. My application domain is similar
to the "Vehicle Routing" example (
http://docs.jboss.org/drools/release/6.0.0.CR5/optaplanner-docs/html_sing...).
I mean, I am using chained variables and shadow variables. I have a problem
while trying to remove a fact (an entity), via a ProblemFactChange:
java.lang.IllegalArgumentException: The entity instance (...) was never
added to this ScoreDirector. Usually the cause is that that specific
instance was not in your Solution's entities.
The fact removing that I made is like:
solver.addProblemFactChange(new ProblemFactChange() {
@Override
public void doChange(ScoreDirector scoreDirector) {
...
scoreDirector.beforeEntityRemoved(toRemove);
workingSolution.getCustomerList().remove(toRemove);
scoreDirector.afterEntityRemoved(toRemove);
}
});
I think the problem is there. Do you know what I'm doing wrong?
I have attached a test case based on the "Vehicle Routing". To run it, just
put that file into the
optaplanner-distribution-6.0.0.CR5/examples/sources/src/test/java/org/optaplanner/examples/vehiclerouting/app/
directory.
<http://drools.46999.n3.nabble.com/file/n4017760/serverlog.zip>I'd
appreciate any ideas on how to resolve this.
Best regards,
Juan Ignacio Barisich
12 years, 4 months
5.6.0.CR1 causes exceptions
by Jonathan Knehr
Just upgraded to the release candidate. I was using my own version of 5.6 that I had compiled a few months ago and everything was working fine.
Almost every single rule file now throws this exception when it gets added to the knowledge base.
java.lang.NoSuchMethodError: org.drools.base.ClassFieldReader.hasReadAccessor()Z
at org.drools.base.ClassFieldAccessorStore.getReader(ClassFieldAccessorStore.java:129)
at org.drools.base.ClassFieldAccessorStore.getReader(ClassFieldAccessorStore.java:104)
at org.drools.rule.builder.PatternBuilder.getFieldReadAccessor(PatternBuilder.java:1572)
at org.drools.rule.builder.PatternBuilder.buildRuleBindings(PatternBuilder.java:1123)
at org.drools.rule.builder.PatternBuilder.buildCcdDescr(PatternBuilder.java:691)
at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:651)
at org.drools.rule.builder.PatternBuilder.processConstraintsAndBinds(PatternBuilder.java:505)
at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:322)
at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:133)
at org.drools.rule.builder.GroupElementBuilder.build(GroupElementBuilder.java:67)
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:85)
at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:3169)
at org.drools.compiler.PackageBuilder.compileRules(PackageBuilder.java:1036)
at org.drools.compiler.PackageBuilder.compileAllRules(PackageBuilder.java:944)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:936)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:468)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:698)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:51)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:40)
Sent from my iPhone
12 years, 4 months
Data enumeration in Guvnor
by nkhogen
In advanced data enumeration in Guvnor, it is possible to define list of
values for a given condition.
Like
ZipCode, field1 = "55000", field2 = ['1','2','3'], field1 = "55000", field2
= ['1','2','3']
ZipCode, field1 = "66600", field2 = ['10','20','30']
But if I have something like
ZipCode, field1 = "OTHER", field2 value should not be bound. I should be
able to fill anything. But, Guvnor does not allow me once field1 is bound to
something else.
Please let me know if anyone has had this issue before.
--
View this message in context: http://drools.46999.n3.nabble.com/Data-enumeration-in-Guvnor-tp4026631.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months