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); } }
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); }
public boolean addProblemFactChange(ProblemFactChange problemFactChange) { return basicPlumbingTermination.addProblemFactChange(problemFactChange); }
public boolean isEveryProblemFactChangeProcessed() { BlockingQueue<ProblemFactChange> problemFactChangeQueue = basicPlumbingTermination.getProblemFactChangeQueue(); // TODO bug: the last ProblemFactChange might already been polled, but not processed yet return problemFactChangeQueue.isEmpty(); }
public boolean isTerminateEarly() { return basicPlumbingTermination.isTerminateEarly(); }