How to troubleshoot Drools planner doing nothing?
by aitchnyu
I wrote a program in Drools. But it does not do anything. As the logs show,
the solver finishes in 2 ms and the 'best solution' is an untouched version
of the initial state.
I also noted that not a single movefactory object was created. And at 500
moves/sec and 2 milliseconds of execution, only one move was attempted.
Where do I start troubleshooting?
SudokuGenerator sg = new SudokuGenerator();
Solution sudoku = sg.createSudoku();
Solver solver = createSolver();
solver.setPlanningProblem(sudoku);
solver.solve();
System.out.println("solver over");
Sudoku result = (Sudoku) solver.getBestSolution();
result.displaySolution(); //a method that prints the state of the solution
*Output logs in TRACE mode*
jesvin@Jesvin-Technovia:~/dev/drools/sudoku$ java in.co.technovia.sudoku.App
2012-01-30 17:23:33,795 [main] INFO Solver started: time spend (1), score
(0), new best score (0), random seed (0).
2012-01-30 17:23:33,796 [main] INFO Solved: time spend (2), best score (0),
average calculate count per second (500).
*Contents of the solver XML*
<?xml version="1.0" encoding="UTF-8"?>
<solver>
<environmentMode>DEBUG</environmentMode>
<solutionClass>in.co.technovia.sudoku.domain.Sudoku</solutionClass>
<planningEntityClass>in.co.technovia.sudoku.domain.Digit</planningEntityClass>
<scoreDrl>/score.drl</scoreDrl>
<scoreDefinition>
<scoreDefinitionType>SIMPLE</scoreDefinitionType>
</scoreDefinition>
<termination>
<scoreAttained>0</scoreAttained>
</termination>
<constructionHeuristic>
<constructionHeuristicType>FIRST_FIT</constructionHeuristicType>
</constructionHeuristic>
<localSearch>
<selector>
<moveFactoryClass>in.co.technovia.sudoku.solution.RowChangeMoveFactory</moveFactoryClass>
</selector>
<acceptor>
<completeSolutionTabuSize>1000</completeSolutionTabuSize>
</acceptor>
<forager>
</forager>
</localSearch>
</solver>
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-troubleshoot-Drools-planner-doin...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
How to enable logging in my application?
by aitchnyu
I want to enable logging in my application. Since Drools planner uses log4j,
how can I enable it's logging in my application?
In the current form, my application runs as:
jesvin@Jesvin-Technovia:~/dev/drools/sudoku$ java in.co.technovia.sudoku.App
log4j:WARN No appenders could be found for logger
(org.drools.planner.core.solver.DefaultSolver).
log4j:WARN Please initialize the log4j system properly.
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-enable-logging-in-my-application...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
Planner has trouble creating a configurer: how to debug
by aitchnyu
I tried to create a solver from XML configuration. But the entire process
returns a *cryptic error message *that makes no sense.
How do I fix this? And how can I make sense of this to actually solve
similar problems like this?
Please excuse me if I made any bad karma. This is my first post on this (and
any) mailing list.
jesvin@Jesvin-Technovia:~/dev/drools/sudoku$ java App
Exception in thread "main" java.lang.NullPointerException
at
org.drools.planner.core.domain.solution.SolutionDescriptor.processPropertyAnnotations(SolutionDescriptor.java:69)
at
org.drools.planner.core.domain.solution.SolutionDescriptor.<init>(SolutionDescriptor.java:61)
at
org.drools.planner.config.solver.SolverConfig.buildSolutionDescriptor(SolverConfig.java:197)
at
org.drools.planner.config.solver.SolverConfig.buildSolver(SolverConfig.java:167)
at
org.drools.planner.config.XmlSolverConfigurer.buildSolver(XmlSolverConfigurer.java:103)
at App.createSolver(App.java:62)
at App.main(App.java:40)
The function that throws it is listed here. The line is of course `return
configurer.buildSolver();`.
private static Solver createSolver(){
XmlSolverConfigurer configurer = new XmlSolverConfigurer();
File file = new File("solver.xml");
FileInputStream fin = null;
try{
fin = new FileInputStream(file);
}
catch(IOException e){
System.out.println("Unable to read drl");
}
configurer.configure(fin);
//configurer.configure("/home/jesvin/dev/drools/sudoku/solver.xml");
return configurer.buildSolver();
}
The content of the XML:
<?xml version="1.0" encoding="UTF-8"?>
<solver>
<environmentMode>DEBUG</environmentMode>
<solutionClass>domain.Sudoku</solutionClass>
<planningEntityClass>domain.Digit</planningEntityClass>
<scoreDrl>score.drl</scoreDrl>
<scoreDefinition>
<scoreDefinitionType>SIMPLE</scoreDefinitionType>
</scoreDefinition>
<termination>
<scoreAttained>0</scoreAttained>
</termination>
<constructionHeuristic>
<constructionHeuristicType>FIRST_FIT</constructionHeuristicType>
<moveFactoryClass>solution.RowChangeMoveFactory</moveFactoryClass>
</selector>
<acceptor>
<completeSolutionTabuSize>1000</completeSolutionTabuSize>
</acceptor>
<forager>
</forager>
</localSearch>
</solver>
--
View this message in context: http://drools.46999.n3.nabble.com/Planner-has-trouble-creating-a-configur...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
declarative agenda & ruleflow
by Michal Bali
Hi Mauricio
in response to:
http://drools.46999.n3.nabble.com/rules-users-Declarative-agenda-final-AP...
here is an example with declarative agenda and ruleflow, the knowledgebase
consists of the following rule file plus bpmn ruleflow file that has only
two ruleflow groups "setup" and then "validation".
if I turn on the
knowledgeBaseConfiguration.setOption(DeclarativeAgendaOption.ENABLED); no
rule is fired
tried with
<drools.ver>5.3.0.Final</drools.ver>
<jbpm.version>5.1.2.Final</jbpm.version>
----------------
package droolsbestpractices;
import org.drools.runtime.rule.Activation;
dialect "mvel"
declare Customer
name : String @key
level : Integer @key
end
//user can decide to bypass ...
rule initialize
ruleflow-group "setUp"
when
then
System.out.println(kcontext.rule.name);
Customer customer1 = new Customer("John", 1);
insert(customer1);
end
rule customerLevelLow @bypass('customerValidation')
ruleflow-group "validate"
when
Customer( level < 3 )
then
System.out.println(kcontext.rule.name);
end
rule customerLevelBypass @activationListener('direct')
when
$a : Activation( bypass == 'customerValidation' )
then
System.out.println(kcontext.rule.name);
kcontext.blockActivation( $a );
end
--------------------------
Best regards,
Michal
12 years, 10 months
query created in guvnor 5.3.0.final does not return expected results
by vadlam
I have created a query in guvnor 5.3 in a separate drl file as follows.
query "get total Documents created"
document : Document( )
end
I have several rules that create Documents as part of the ruleflow.
on the java side
ksession.fireAllRules(new RuleFilter()); // the rulefilter does not really
do anything except log the
//rules
executing
org.drools.runtime.rule.QueryResults results =
ksession.getQueryResults("get total Documents created");
System.out.println( "we have " + results.size() +"
Documents" );
I see that the returned results size is 0
but the following code returns the documents as expected.
Collection responseObjects = ksession.getObjects();
is there anything I am missing with respect to the query ? I use a ruleflow
. does the query need to be part of any of the ruleflowgroups within the
ruleflow ?
is there a way to know whether the query ran or not ?
--
View this message in context: http://drools.46999.n3.nabble.com/query-created-in-guvnor-5-3-0-final-doe...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
Declarative agenda final API
by Marcin Bednarek
Hello,
Looks like my previous post was not sent to mailing list bu only to nabble
forum so I am resending it.
I plan to use declarative agenda API: kcontext.blockActivation,
kcontext.unblockAllActivations, kcontext.cancelActivation.
In Drools documentation there is written that this API is highly
experimental:
*This feature is off by default and must be explicitly enabled, that is
because it is considered highly experimental for the moment and will be
subject to change.*
Could you please let me know in which version you plan to make declarative
agenda API, solution final?
Thanks,
Marcin
12 years, 10 months
java.lang.ArrayIndexOutOfBoundsException at Frame
by mujoko mujoko
Hi Drools Users,
I'm new member, Mujoko.
I got issue regarding my rules. Several times got exception when trying to
create KnowledgeSession. I used drools-core 5.3.0.Final and drools-compiler
5.3.0.Final.
java.lang.ArrayIndexOutOfBoundsException: -1
at org.mvel2.asm.Frame.merge(Frame.java:1373)
at org.mvel2.asm.Frame.merge(Frame.java:1350)
at org.mvel2.asm.MethodWriter.visitMaxs(MethodWriter.java:1282)
at
org.drools.rule.builder.dialect.asm.ClassGenerator$MethodDescr.write(ClassGenerator.java:480)
at
org.drools.rule.builder.dialect.asm.ClassGenerator.generateBytecode(ClassGenerator.java:50)
at
org.drools.rule.builder.dialect.asm.ASMEvalBuilder.createEvalBytecode(ASMEvalBuilder.java:63)
at
org.drools.rule.builder.dialect.asm.AbstractASMEvalBuilder.build(AbstractASMEvalBuilder.java:49)
at
org.drools.rule.builder.dialect.asm.AbstractASMEvalBuilder.build(AbstractASMEvalBuilder.java:15)
at
org.drools.rule.builder.GroupElementBuilder.build(GroupElementBuilder.java:65)
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:80)
at
org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:2289)
at
org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:822)
--
Mujoko
http://www.linkedin.com/in/mujoko
12 years, 10 months