Example #1
0
 private void checkProblemFactChanges() {
   BlockingQueue<ProblemFactChange> problemFactChangeQueue =
       basicPlumbingTermination.getProblemFactChangeQueue();
   if (!problemFactChangeQueue.isEmpty()) {
     solverScope.setRestartSolver(true);
     solverScope.setWorkingSolutionFromBestSolution();
     Score score = null;
     int count = 0;
     ProblemFactChange problemFactChange = problemFactChangeQueue.poll();
     while (problemFactChange != null) {
       score = doProblemFactChange(problemFactChange);
       count++;
       problemFactChange = problemFactChangeQueue.poll();
     }
     Solution newBestSolution = solverScope.getScoreDirector().cloneWorkingSolution();
     // TODO BestSolutionRecaller.solverStarted() already calls countUninitializedVariables()
     int newBestUninitializedVariableCount =
         solverScope.getSolutionDescriptor().countUninitializedVariables(newBestSolution);
     bestSolutionRecaller.updateBestSolution(
         solverScope, newBestSolution, newBestUninitializedVariableCount);
     logger.info(
         "Done {} ProblemFactChange(s): new score ({}) possibly uninitialized. Restarting solver.",
         count,
         score);
   }
 }
Example #2
0
 public final void solve() {
   solving.set(true);
   basicPlumbingTermination.resetTerminateEarly();
   solverScope.setRestartSolver(true);
   while (solverScope.isRestartSolver()) {
     solverScope.setRestartSolver(false);
     solvingStarted(solverScope);
     runSolverPhases();
     solvingEnded(solverScope);
     checkProblemFactChanges();
   }
   // Must be kept open for doProblemFactChange
   solverScope.getScoreDirector().dispose();
   solving.set(false);
 }
Example #3
0
 public boolean addProblemFactChange(ProblemFactChange problemFactChange) {
   return basicPlumbingTermination.addProblemFactChange(problemFactChange);
 }
Example #4
0
 public boolean isEveryProblemFactChangeProcessed() {
   BlockingQueue<ProblemFactChange> problemFactChangeQueue =
       basicPlumbingTermination.getProblemFactChangeQueue();
   // TODO bug: the last ProblemFactChange might already been polled, but not processed yet
   return problemFactChangeQueue.isEmpty();
 }
Example #5
0
 public boolean isTerminateEarly() {
   return basicPlumbingTermination.isTerminateEarly();
 }