davidglassborow/drools-planner — comment on commit 781f8e8dbe6792215f46c8a4ef3070bbc3e2678a
File:  line 0
By davidglassborow:

Yep I saw the changes, the trouble is your example code only works when the solver has finished, using the SolutionDirector change from inside the change event also gets an empty working memory.

Any idea a simple change I could do to my commit to get the correct working memory ?

> Hi David,
>
> Thanks for sharing this change. Even though I don't want to change the BestSolutionEvent API like this (as it leaks the solver's "working" WorkingMemory), it does give me a very good insight on what you want to do.
>
> Furthermore, I 've recently specced out that the user provides a bestSolution and the workingMemory is a clone of that. So that means the bestSolution is never in the WorkingMemory. See the changes here:
> https://github.com/droolsjbpm/drools-planner/commit/5690541a567e5db36c6f2f5a66fda4f9c99d4086#diff-6
>
> Next improvement in this will be to split up the SolutionDirector into SolutionDirectorFactory (holds RuleBase) and SolutionDirector (holds WorkingMemory) so the user can use the same SolutionDirectorFactory to create it's own, isolated SolutionDirector.
> That would mean you'd have to take the bestSolution and set it on your SolutionDirector (instead of sharing a WorkingMemory with the Solver). Can you live with that? It might be a small performance hit (but premature optimization is the root of all evil because not doing it would hinder multi-threaded solving in the future).
>
> ---
> Reply to this email directly or view it on GitHub:
> https://github.com/davidglassborow/drools-planner/commit/781f8e8dbe6792215f46c8a4ef3070bbc3e2678a#commitcomment-954072