Hi all,
I am currently looking at Drools planner. I try to solve a simple 4 queens
problem with the following
code:
XmlSolverConfigurer configurer = new XmlSolverConfigurer();
configurer.configure("/org/drools/planner/myexamples/nqueens/app/nqueensSolverConfig.xml");
Solver solver = configurer.buildSolver();
NQueensGenerator generator=new NQueensGenerator();
Solution startingSolution = generator.createNQueens(4);
solver.setStartingSolution(startingSolution);
solver.solve();
Solution bestSolution = solver.getBestSolution();
System.out.println((NQueens) bestSolution);
The config file is the usual one:
<?xml version="1.0" encoding="UTF-8"?>
<localSearchSolver>
<environmentMode>DEBUG</environmentMode>
<scoreDrl>/org/drools/planner/examples/nqueens/solver/nQueensScoreRules.drl</scoreDrl>
<scoreDefinition>
<scoreDefinitionType>SIMPLE</scoreDefinitionType>
</scoreDefinition>
<!-- Real world problems require to use of
<startingSolutionInitializerClass>. -->
<termination>
<terminationCompositionStyle>OR</terminationCompositionStyle>
<maximumStepCount>100</maximumStepCount>
<scoreAttained>0</scoreAttained>
</termination>
<selector>
<moveFactoryClass>org.drools.planner.examples.nqueens.solver.move.factory.NQueensMoveFactory</moveFactoryClass>
</selector>
<acceptor>
<completeSolutionTabuSize>1000</completeSolutionTabuSize>
</acceptor>
<forager>
<pickEarlyType>NEVER</pickEarlyType>
<!-- Real world problems require to use of
<minimalAcceptedSelection> -->
</forager>
</localSearchSolver>
I do not understand why but it does not work:
2010-11-17 11:15:13,791 [main] INFO Solving with random seed (0).
2010-11-17 11:15:13,793 [main] INFO Initialization time spend (4) for score
(0). Updating best solution and best score.
Exception in thread "main" java.lang.ClassCastException:
org.drools.planner.myexamples.nqueens.domain.NQueens
at
org.drools.planner.examples.nqueens.solver.move.factory.NQueensMoveFactory.createCachedMoveList(NQueensMoveFactory.java:35)
at
org.drools.planner.core.move.factory.CachedMoveFactory.solvingStarted(CachedMoveFactory.java:39)
at
org.drools.planner.core.localsearch.decider.selector.MoveFactorySelector.solvingStarted(MoveFactorySelector.java:58)
at
org.drools.planner.core.localsearch.decider.DefaultDecider.solvingStarted(DefaultDecider.java:91)
at
org.drools.planner.core.localsearch.DefaultLocalSearchSolver.solvingStarted(DefaultLocalSearchSolver.java:188)
at
org.drools.planner.core.localsearch.DefaultLocalSearchSolver.solveImplementation(DefaultLocalSearchSolver.java:125)
at org.drools.planner.core.AbstractSolver.solve(AbstractSolver.java:57)
at org.drools.planner.myexamples.nqueens.app.Main.main(Main.java:32)
Any idea ?
Thanks in advance,
MM.
--
View this message in context:
http://drools-java-rules-engine.46999.n3.nabble.com/Simple-Drools-Planner...
Sent from the Drools - User mailing list archive at
Nabble.com.