OptaPlanner: Solver.isEveryProblemFactChangeProcessed() return true before the last fact change is processed
by Hagai
Using OptaPlanner 6.0.1.Final and following the documentation for real-time
planning:
"Alternatively, you can subscribe to the BestSolutionChangedEvent.
A BestSolutionChangedEvent doesn't guarantee that every ProblemFactChange
has been
processed already, so check Solver.isEveryProblemFactChangeProcessed() and
ignore any
BestSolutionChangedEvent fired while that method returns false."
However, Solver.isEveryProblemFactChangeProcessed() return true before the
last fact change is processed.
This is documented in the code DefaultSolver.java: *// TODO bug: the last
ProblemFactChange might already been polled, but not processed yet*
I believe this can be fixed using the following code in
DefaultSolver.checkProblemFactChanges:
ProblemFactChange problemFactChange =
problemFactChangeQueue*.peek()*;
while (problemFactChange != null) {
score = doProblemFactChange(problemFactChange);
*problemFactChangeQueue.poll();*
count++;
problemFactChange = problemFactChangeQueue*.peek()*;
}
This way the queue will not be empty until the fact change is processed.
--
View this message in context: http://drools.46999.n3.nabble.com/OptaPlanner-Solver-isEveryProblemFactCh...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 10 months
Integrate jBPM with OptaPlanner
by jjn
Hi, how can I integrate jBPM with OptaPlanner. I have solved a problem using
OptaPlanner, where there are a number of requests which are optimally
assigned to particular employees, based on certain constraints. Now I want
to create a dispatcher in jBPM, where certain employees(actors) can solve
certain requests(process instances). Any idea how I can go about this
problem ?
--
View this message in context: http://drools.46999.n3.nabble.com/Integrate-jBPM-with-OptaPlanner-tp40293...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 10 months
Rule Orchestration
by swaroop
Hi,
Iam using Drools 5.6 , developing rules on guvnor. I have a scenario where i
have two decision tables , One is supposed to execute after the other.
I want to ensure that DT Two should be executed only after all the
executions in DT one happen . Because IN DT Two the list is being checked if
set of values are not present, currently when i have two Customer objects in
Working memory each having matching rows in Decision Table One .Once the
match is found for a customer object then as per the action a Product fact
is inserted which leads to fire the DT Two and the list is evaluated if set
of d are not present , the rule is fired in DT Two as the list is not
populated for the other customer object and matching rows which is being
checked in DT Two eval list column. Which is not desired . I tried with
salience , ruleflow group with not much of a help
Is there a way to can handle this
<http://drools.46999.n3.nabble.com/file/n4029371/DTIssue.png>
*Decision Table One*
Condition Condition Condition Action
c:Customer
a==$param b in ($param) c == $param "list(Global
Variable).add(d);
insert(Product())"
*Decision Table Two*
Condition Condition Condition
Action
p:Product
a==$param eval(list doesnt not contain ($param)) c == $param
response.setMessage($param);
Regards
Oggu
--
View this message in context: http://drools.46999.n3.nabble.com/Rule-Orchestration-tp4029371.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 10 months
Drools 6 Junit Random Failures
by richardhands
I've written a base class to do the heavy lifting of creating all the Kie
resources etc and to give me a stateless session back that my unit tests can
all use. Each test calls the method in this base class to set up stuff, and
then adds facts and globals and does a fireall.
however, i get random unit test failures. sometimes the suite will work
perfectly, sometimes rule x will fail, sometimes rule f will fail etc. I'm
convinced it's got to be something to do with the way i'm setting up the
initial resources, and maybe they're getting re-used incorrectly from one
test to another (i expect a brand new clean statelesssession on each test)
but i can't see what i'm doing wrong. The documentation around the new Kie
stuff is still being built around how i'm trying to do stuff, so i'm a bit
lost. Each unit test class is designed to test all the rules in on .drl
file, but there can be many .drl files in one package so i don't want to use
the api's for loading a package, i am having to create a filesystem and load
the drl file into it. can anyone see anything obviously wrong in my base
class that might cause this intermittent failure?
thanks
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-6-Junit-Random-Failures-tp402937...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 10 months
How to include Maven repo jar in kbase using KModuleBeanFactoryPostProcessor
by Shrinath Managuli
Hi drools,
Using org.kie.spring.KModuleBeanFactoryPostProcessor, how to include the packages for kbase1 either from Maven repository or through an HTTP call (instead of include packages from class path folder)
Something like,
<kie:kbase name="kbase1" packages="org.test.helloword">
<kie:ksession name="ksession1" type="stateless" />
</kie:kbase>
I had looked into KModuleBeanFactoryPostProcessor and ClasspathKieProject.createInternalKieModule(), it seems all the packages are loaded from class path alone.
Also, if including the packages from Maven repository or through an HTTP URI is feasible, then how can we do a scanner for refreshing the packages?
Please share your views on this?
Thanks,
Shrinath
[Aspire Systems]
This e-mail message and any attachments are for the sole use of the intended recipient(s) and may contain proprietary, confidential, trade secret or privileged information. Any unauthorized review, use, disclosure or distribution is prohibited and may be a violation of law. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
11 years, 10 months
Drools spawning a lot of JIT threads
by Frank Pavageau
Hi.
I'm using Drools 5.5 in a web application, upgraded a few months ago from
5.1. When starting multiple instances of the application on a server *at
the same time*, I recently noticed some problems with the JVMs complaining
of not being able to create native threads.
The stack trace led to Drools, and more specifically MvelConstraint
submitting JIT tasks to an Executor through its jitEvaluator() method. The
Executor is created by ExecutorProviderImpl and is a basic
CachedThreadPool, which means it can create an unbounded number of threads
(which then die after idling for a minute). In my case, it apparently meant
around 900 threads per JVM, which multiplied by the number of running JVMs
saturated the OS for a short while.
Has anyone else been bitten by this? Should there be a more reasonable
default implementation and should I create an issue for this?
I then have a question related to how I fixed this: I created my own
implementation of ExecutorProvider by extending ExecutorProviderImpl and
creating a ThreadPoolExecutor with an upper bound on the number of threads
and a LinkedBlockingQueue to queue the tasks when all the threads are
already busy. That works fine, the only problem is telling Drools to use my
implementation: the only way I've found is by
calling ServiceRegistryImpl.getInstance().registerLocator().
ServiceRegistryImpl implements ServiceRegistry, but the interface doesn't
seem to be exposed through Drools' more public API; it seems a bit wrong to
call the implementing class directly to get its instance, especially given
the Javadoc which states "This is an internal class, not for public
consumption". Am I missing something?
Regards,
Frank
11 years, 10 months
Re: [rules-users] java.lang.NoSuchMethodError thrown in drools api
by DE_Azrael
Good morning !
@snak: That was the first hint I found during my investigation but it could
not be the failure.
It could not be a problem of version incompatibility. As I wrote the
transaction was working 4 times and failed at the 5th transaction
(reproducable).
If it would be a problem of incompatibility no transaction could be
successful.
>From the error stack I was wondering why it was saying
ConditionEvaluatorf4a3f354729241ac8370890200fdf2d8.evaluate(Unknown Source)
Guess this class is generated automaticly and the source that is missing at
this point is the kbase.
I checked again the initialisation of kbase and I found a failure.
The kbase is defined as static and is beeing initialised with the first
transaction. Additionaly it's beeing updated every few minutes.
After I corrected this the failure disappear.
I did the following changes:
*old code:*
if ((knowledgeSetupTimestamp + timeInMillis) < System.currentTimeMillis())
ageReload = true;
if ((kbase == null) || ageReload) {
synchronized (DroolsHelper.class) {
if ((kbase == null) || ageReload) {
.........
}
}
}
*new corrected code:*
if ((kbase == null) || (knowledgeSetupTimestamp + timeInMillis <
System.currentTimeMillis())) {
synchronized (DroolsHelper.class) {
if ((kbase == null) || (knowledgeSetupTimestamp + timeInMillis <
System.currentTimeMillis())) {
.........
}
}
}
I'm still a bit puzzled about the reported failure and it would be great if
someone could explain me this behaviour.
Thanks a lot !
Cheers Johannes
--
View this message in context: http://drools.46999.n3.nabble.com/java-lang-NoSuchMethodError-thrown-in-d...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 10 months
KieScanner with Maven 3
by Maxime Falaize
Hello,
Does the KieScanner support Maven 3? I noted that LATEST, RELEASE and
SNAPSHOT metaversions for Maven are no longer supported by Maven 3 so do I
have to understand that we cannot use the KieScanner with Maven 3?
By the way I noted that if I set my KieContainer with a LATEST version, the
KieScanner systematically redeploy my JAR as the KieScanner compare the
real version with "LATEST". I've seen that there were some changes in the
KieScanner in the 6.1.0, did you fix it? I can't test right now because I
face a rule compilation problem with the new 6.1.0 version and I still have
to figure this out.
Regards
--
Maxime FALAIZE
11 years, 10 months
java.lang.NullPointerException in simple example
by ahgiovanini
Hi guys!
I'm new in the world of jboss and drools and I'm making some simple examples
that existing on
https://github.com/droolsjbpm/drools/tree/master/drools-examples-api
Now, I'm studing the CashFlow example and in my project when I run it, I
receive a error message saying:
Exception in thread "main" java.lang.NullPointerException
at com.sample.CashFlowMain.main(CashFlowMain.java:30)"
I don't know the why this message, because I set the acp at lines 20 and 21.
Someone would help me please?
Thanks
package com.sample;
import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.rule.FactHandle;
import java.text.SimpleDateFormat;
import java.util.Date;
public class CashFlowMain {
public static void main(String[] args) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
KieContainer kc =
KieServices.Factory.get().getKieClasspathContainer();
KieSession ksession = kc.newKieSession("CashFlowKS");
AccountPeriod acp = new AccountPeriod();
acp.setStart(date("2013-01-01")); // set acp - line 20
acp.setEnd(date("2013-03-31")); // set acp - line 21
Account ac = new Account(1, 0);
CashFlow cf1 = new CashFlow(date( "2013-01-12"), 100,
CashFlowType.CREDIT, 1 );
CashFlow cf2 = new CashFlow(date( "2013-02-2"), 200,
CashFlowType.DEBIT, 1 );
CashFlow cf3 = new CashFlow(date( "2013-05-18"), 50,
CashFlowType.CREDIT, 1 );
CashFlow cf4 = new CashFlow(date( "2013-03-07"), 75,
CashFlowType.CREDIT, 1 );
FactHandle fh = ksession.insert(acp);
ksession.insert( ac );
ksession.insert( cf1 );
ksession.insert( cf2 );
ksession.insert( cf3 );
ksession.insert( cf4 );
ksession.fireAllRules();
acp.setStart(date( "2013-04-01"));
acp.setEnd(date( "2013-06-31"));
ksession.update(fh, acp);
ksession.fireAllRules();
}
public static Date date(String str) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.parse( str );
}
}
--
View this message in context: http://drools.46999.n3.nabble.com/java-lang-NullPointerException-in-simpl...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 10 months