0

I am working on a Swing based GUI handling my planning problem. The GUI should like in the examples be updated each time a better solution is found. I use the SwingWorker (SolveWorker) from the examples and starting the solving works fine. I add my event listener to the Solver, however it seems that I never get an event on:

public void bestSolutionChanged(final BestSolutionChangedEvent event)

If I then terminate the solver early, I get an event right away and the score is negative for soft and hard constraints. I can understand from the Java Docs that calling ‘bestSolutionChanged’ not guaranteed, so the frequency of calls might depend on the Problem Facts in the planning problem. Is it possible to force events each time a constraint changes or use a other way to get the current solution that is being solved? Thanks

  • What does the log say? Turn on debug logging (see docs about logging). Every time a debug log statement outputs a step (about one per second), it will state if the best solution is a "new best solution". If it is, such an bestSolutionChanged event must happen. – Geoffrey De Smet Mar 19 '15 at 09:13
  • The log contains a lot of : best score (-15520/0/0/0/0/-20/-12385/0/0/0), accepted/selected move count (1/4), picked move. No new best solution. After terminate: Construction Heuristic phase (0) ended: step total (11), time spent (5344), best score (-1715/0/0/0/0/-20/-8247/0 – user2212019 Mar 19 '15 at 09:57
  • Sorry. Found out that a new best actually is generated. It just takes a long time before the first new best is found. After that the GUI is updated. I guess it is not possible to have the GUI updated for each change in score? Or somehow other way to have the effect that the user can see the movements? – user2212019 Mar 19 '15 at 10:09
  • The best score only changes if the best solution changes. Step score/solutions aren't interesting. [See this image](http://docs.jboss.org/optaplanner/release/latest/optaplanner-docs/html_single/images/Chapter-Local_search/localSearchScoreOverTime.png) – Geoffrey De Smet Mar 19 '15 at 10:43
  • 1
    Yep makes sense. After I switched from a Easy to a Incremental calculator - I also got the new best faster – user2212019 Mar 19 '15 at 11:36

0 Answers0