Planner - Initialized solution & local search
by Garf
I'm using v5.4. I've built a prototype which uses the constructionHeuristic,
and localSearch, as the example does, and am able to run the solver (though
it still doesn't do a good job of solving at this point).
I've now added customSolverPhase, and set it to use an initializer class
which implements CustomSolverPhaseCommand.
In my changeWorkingSolution, I call scoreDirector.beforeEntityAdded(), and
then set the planning entity's planning variable, and then call
afterEntityAdded().
If I leave any entities unadded -- and let the constructionHeuristic
(BEST_FIT, etc) do the fitting (which I can verify from the logs)-- I then
get this exception:
/java.lang.IllegalStateException: Phase localSearch started with an
uninitialized Solution. First initialize the Solution. For example, run a
phase constructionHeuristic first./
For now, I can update my code to ensure that all of the entities are fitted
and bypass the constructionHeuristic, but I'm curious why this error is
getting thrown. I did hunt through the source code to look at all the
isInitialized() methods, but I haven't yet stepped through to see which one
returns false any why.
As for turning on TRACE mode, see my
http://drools.46999.n3.nabble.com/drools-planner-5-4-0-Final-java-lang-Il...
recent post .
Jon
--
View this message in context: http://drools.46999.n3.nabble.com/Planner-Initialized-solution-local-sear...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
Serialization issue with StateKnowledgeSession
by chrisLi
Hi, all
I have a requirement to serialzie a stateful session as a snapshot.
private void serialize(OutputStream out) throws IOException{
System.out.println("writing");
DroolsObjectOutputStream droolsOut = new DroolsObjectOutputStream(
(OutputStream) out);
droolsOut.writeLong(counter);
droolsOut.writeLong(clock.getCurrentTime());
droolsOut.writeObject(this.knowledgeBase);
Marshaller marshaller = createSerializableMarshaller(this.knowledgeBase);
marshaller.marshall(droolsOut, this.session);
droolsOut.close();
System.out.println("written");
}
I used the above code to serialize the knowledgebase and session into a file
simultaneously and it works well. Then I used the following code to attempt
to deserialize them, but I failed.
private void deserialize(InputStream in) throws IOException,
ClassNotFoundException {
System.out.println("reading");
DroolsObjectInputStream droolsIn = new DroolsObjectInputStream(
(InputStream) in);
this.counter = droolsIn.readLong();
long clockTime = droolsIn.readLong();
this.knowledgeBase = (KnowledgeBase) droolsIn.readObject();
Marshaller marshaller = createSerializableMarshaller(this.knowledgeBase);
this.session = marshaller.unmarshall(droolsIn);
this.session.getSessionConfiguration().setOption(ClockTypeOption.get("pseudo"));
this.clock = (PseudoClockScheduler) session.getSessionClock();
this.clock.setStartupTime(clockTime);
droolsIn.close();
System.out.println("read");
}
In my other codes, I set the clock type of session to "pseudo" with a
KnowledgeSessionConfiguration
instance. However, when I serialized it, it's clock type was "realtime". It
seems that the some of session's
fields were not serialized.
So, I wonder are there any other ways to serialize a session? I heard about
XStream, is it appropriate to
serialize a session. And how?
Or, are there methods allowing me to set the clock type of a session to
"pseudo" after deserializing it?
Thank you very much!
--
View this message in context: http://drools.46999.n3.nabble.com/Serialization-issue-with-StateKnowledge...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
FireUntilHalt
by crajor
I have a fairly complicated drools program and I want to introduce temporal
reasoning to it. I spent a bit of time writing some proof-of-concept
programs to get the feel of fusion and then tried to slowly introduce things
into my original drools program. When I changed my program from using
fireAllRules() to using fireUntilHalt() on a separate thread, I suddenly get
failures in my unit tests. (My first thought was that there was a race
condition between my unit tests and the thread calling fireUntilHalt() so I
introduced a delay before my unit tests but no luck)
Here are some of the behaviors I am seeing.
1) I occasionally get nullpointerexception from the thread running
fireUntilHalt()
2) My lock-on-active rules aren't firing
I have banged my head on this a while with no success. (I even tried
putting fireAllRules() in a loop because of suggestions I saw but no luck
and same behavior). My questions are, Is there a secret to using
fireUntilHalt() that I am not aware of? Can anybody point me to where I can
educate myself on its proper use?
BTW no persistence and no spring in the code at this point.
Thanks, in advance, for any help you can provide.
Craig
--
View this message in context: http://drools.46999.n3.nabble.com/FireUntilHalt-tp4018610.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
Rule refiring issue !
by abhinay_agarwal
hey all,
i have a scenario like this..
rule "rule1"
agenda-group "1"
salience 0
when
//something
then
setFocus("2")
end
rule "rule1"
agenda-group "1"
salience -1
when
//something
then
//something
end
rule "rule3"
agenda-group "2"
salience 0
when
//something
then
//something
end
when initially my rule 1 gets fired, it executes its work and sets focus on
rule 3....
After the execution of rule 3, when it goes back to agend-group "1"..the
rule 1 is fired again..
can i do something to stop the firing of rule 1 again..i want my rule 2 to
just get fired when the focus is set again to agenda-group "1"..
i have tried using "no-loop" and "lock-on active", but they dont help in my
case !!
thanks,
Abhinay
--
View this message in context: http://drools.46999.n3.nabble.com/Rule-refiring-issue-tp4018618.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
[Solved] Concurrency bug in 5.4.0.Final
by Edson Tirelli
Hi all,
Just a heads up, in case you are using the community release 5.4.0.Final
in a multi-threaded application, be aware that we found a quite serious
racing condition bug:
https://issues.jboss.org/browse/JBRULES-3573
The bug is now fixed in 5.4.x branch, so I strongly recommend that you
build from source and use that instead. The bug was also fixed in the
up-stream branch and will be released in 5.5.0.
IMPORTANT: if you are a Red Hat subscriber, you don't need to do anything
as the problem did not exist in the product release.
Edson
--
Edson Tirelli
JBoss Drools Core Development
JBoss by Red Hat @ www.jboss.com
12 years, 7 months