[rules-users] getting list of broken constraints for some solution(NOT BEST SOLUTION) in drools-planner

Nurlan Rakhimzhanov nurlan.rakhimzhanov at gmail.com
Mon May 7 06:21:32 EDT 2012


Thank you!

On 5 May 2012 15:35, Geoffrey De Smet <ge0ffrey.spam at gmail.com> wrote:

> **
>
>
> Op 05-05-12 08:50, Nurlan schreef:
>
> Hi guys!
> I'm using drools-planner-*5.4.0.CR1*...
>
> Let's say I have some solution(NOT FINAL BEST SOLUTION) which done by human
> manually and I want get list of broken contraints for that solution, I've
> tried
>
> 	this.scoreDirector.setWorkingSolution(someSolution);
> 	this.scoreDirector.calculateScore();
>
>  Something like that should work. For the exact correct usage, see the new
> section for the 5.4.0.Final manual:
>
> https://hudson.jboss.org/hudson/view/Drools%20jBPM/job/drools-planner/lastSuccessfulBuild/artifact/drools-planner-docs/target/docbook/publish/en-US/html_single/index.html#d0e3786
> It should never return null. I do in the examples all the time.
>
> There is a point though, that the code above still requires the creation
> of a Solver (but it doesn't you to actually run it):
>
> ScoreDirectorFactory scoreDirectorFactory = solverFactory.buildSolver().getScoreDirectorFactory();ScoreDirector guiScoreDirector = scoreDirectorFactory.buildScoreDirector();guiScoreDirector.setWorkingSolution(solution);Score score = guiScoreDirector.calculateScore();
>
> Feel free to make a jira if you agree that it shouldn't be needed to do a
> ".buildSolver()" in that code.
>
>
>  it returns *null* since it isn't connected with Solver
>
> then I've tried using Solver with
> <termination><maximumStepCount>0</maximumStepCount></termination>:
> 	this.scoreDirector.setWorkingSolution(someSolution);
> 	this.solver.setPlanningProblem(this.scoreDirector.getWorkingSolution());
> 	
> 	this.solver.solve();
> 		
> 	this.scoreDirector.setWorkingSolution(this.solver.getBestSolution());
> 	this.scoreDirector.calculateScore();
>
> then it shows *java.lang.UnsupportedOperationException* because there is no
> best solution in Solver
>
> java.lang.UnsupportedOperationException: StepCountTermination can only be
> used for phase termination.
> 	at
> org.drools.planner.core.termination.StepCountTermination.isSolverTerminated(StepCountTermination.java:40)
> 	at
> org.drools.planner.core.termination.OrCompositeTermination.isSolverTerminated(OrCompositeTermination.java:42)
> 	at
> org.drools.planner.core.solver.DefaultSolver.runSolverPhases(DefaultSolver.java:181)
> 	at
> org.drools.planner.core.solver.DefaultSolver.solve(DefaultSolver.java:151)
>
>
> how can implement this task? or I have to implement setBestSolution in
> Solver, i think this is bad idea...
>
>  bad idea indeed
>
>  --
> View this message in context: http://drools.46999.n3.nabble.com/getting-list-of-broken-constraints-for-some-solution-NOT-BEST-SOLUTION-in-drools-planner-tp3964160.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing listrules-users at lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/rules-users
>
>
> --
> With kind regards,
> Geoffrey De Smet
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
Regards,
Nurlan Rakhimzhanov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20120507/03f30bed/attachment.html 


More information about the rules-users mailing list