// ************************************************************************
// Worker methods
// ************************************************************************
public void solve(DefaultSolverScope solverScope) {
GreedyFitSolverPhaseScope phaseScope = new GreedyFitSolverPhaseScope(solverScope);
phaseStarted(phaseScope);
GreedyFitStepScope stepScope = createNextStepScope(phaseScope, null);
Iterator it = greedyPlanningEntitySelector.iterator();
while (!termination.isPhaseTerminated(phaseScope) && it.hasNext()) {
Object planningEntity = it.next();
stepScope.setPlanningEntity(planningEntity);
stepStarted(stepScope);
greedyDecider.decideNextStep(stepScope);
Move nextStep = stepScope.getStep();
if (nextStep == null) {
logger.warn(" Cancelled step index ({}), time spend ({}): there is no doable move. Terminating phase early.",
stepScope.getStepIndex(),
phaseScope.calculateSolverTimeMillisSpend());
break;
}
nextStep.doMove(stepScope.getScoreDirector());
// there is no need to recalculate the score, but we still need to set it
phaseScope.getWorkingSolution().setScore(stepScope.getScore());
if (assertStepScoreIsUncorrupted) {
phaseScope.assertWorkingScore(stepScope.getScore());
}
if (!it.hasNext()) {
stepScope.setSolutionInitialized(true);
}
stepEnded(stepScope);