public void phaseEnded(ConstructionHeuristicPhaseScope<Solution_> phaseScope) { super.phaseEnded(phaseScope); Solution_ newBestSolution = phaseScope.getScoreDirector().cloneWorkingSolution(); bestSolutionRecaller.updateBestSolution(phaseScope.getSolverScope(), newBestSolution); entityPlacer.phaseEnded(phaseScope); decider.phaseEnded(phaseScope); phaseScope.endingNow(); logger.info( "Construction Heuristic phase ({}) ended: time spent ({}), best score ({})," + " score calculation speed ({}/sec), step total ({}).", phaseIndex, phaseScope.calculateSolverTimeMillisSpentUpToNow(), phaseScope.getBestScore(), phaseScope.getPhaseScoreCalculationSpeed(), phaseScope.getNextStepIndex()); }
public void stepEnded(ConstructionHeuristicStepScope<Solution_> stepScope) { super.stepEnded(stepScope); entityPlacer.stepEnded(stepScope); decider.stepEnded(stepScope); if (logger.isDebugEnabled()) { long timeMillisSpent = stepScope.getPhaseScope().calculateSolverTimeMillisSpentUpToNow(); logger.debug( " CH step ({}), time spent ({}), score ({}), selected move count ({})," + " picked move ({}).", stepScope.getStepIndex(), timeMillisSpent, stepScope.getScore(), stepScope.getSelectedMoveCount(), stepScope.getStepString()); } }
@Override public void solve(DefaultSolverScope<Solution_> solverScope) { ConstructionHeuristicPhaseScope<Solution_> phaseScope = new ConstructionHeuristicPhaseScope<>(solverScope); phaseStarted(phaseScope); for (Placement placement : entityPlacer) { ConstructionHeuristicStepScope<Solution_> stepScope = new ConstructionHeuristicStepScope<>(phaseScope); stepStarted(stepScope); decider.decideNextStep(stepScope, placement); if (stepScope.getStep() == null) { if (termination.isPhaseTerminated(phaseScope)) { logger.trace( " Step index ({}), time spent ({}) terminated without picking a nextStep.", stepScope.getStepIndex(), stepScope.getPhaseScope().calculateSolverTimeMillisSpentUpToNow()); } else if (stepScope.getSelectedMoveCount() == 0L) { logger.warn( " No doable selected move at step index ({}), time spent ({})." + " Terminating phase early.", stepScope.getStepIndex(), stepScope.getPhaseScope().calculateSolverTimeMillisSpentUpToNow()); } else { throw new IllegalStateException( "The step index (" + stepScope.getStepIndex() + ") has selected move count (" + stepScope.getSelectedMoveCount() + ") but failed to pick a nextStep (" + stepScope.getStep() + ")."); } // Although stepStarted has been called, stepEnded is not called for this step break; } doStep(stepScope); stepEnded(stepScope); phaseScope.setLastCompletedStepScope(stepScope); if (termination.isPhaseTerminated(phaseScope)) { break; } } phaseEnded(phaseScope); }
@Override public void solvingEnded(DefaultSolverScope<Solution_> solverScope) { super.solvingEnded(solverScope); entityPlacer.solvingEnded(solverScope); decider.solvingEnded(solverScope); }
public void stepStarted(ConstructionHeuristicStepScope<Solution_> stepScope) { super.stepStarted(stepScope); entityPlacer.stepStarted(stepScope); decider.stepStarted(stepScope); }
public void phaseStarted(ConstructionHeuristicPhaseScope<Solution_> phaseScope) { super.phaseStarted(phaseScope); entityPlacer.phaseStarted(phaseScope); decider.phaseStarted(phaseScope); }