コード例 #1
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);
 }
コード例 #2
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);
   }
 }