protected void runSolverPhases() { Iterator<SolverPhase> it = solverPhaseList.iterator(); while (!termination.isSolverTerminated(solverScope) && it.hasNext()) { SolverPhase solverPhase = it.next(); solverPhase.solve(solverScope); if (it.hasNext()) { solverScope.setWorkingSolutionFromBestSolution(); } } // TODO support doing round-robin of phases (only non-construction heuristics) }
public ConstructionHeuristicMoveScope nominateMove(ConstructionHeuristicStepScope stepScope) { Object entity = stepScope.getEntity(); if (!reinitializeVariableEntityFilter.accept(stepScope.getScoreDirector(), entity)) { return null; } // TODO extract to PlacerForager Score maxScore = null; ConstructionHeuristicMoveScope nominatedMoveScope = null; int moveIndex = 0; for (Iterator it = valueSelector.iterator(entity); it.hasNext(); ) { Object value = it.next(); ConstructionHeuristicMoveScope moveScope = new ConstructionHeuristicMoveScope(stepScope); moveScope.setMoveIndex(moveIndex); Move move; if (variableDescriptor.isChained()) { move = new ChainedChangeMove(entity, variableDescriptor, value); } else { move = new ChangeMove(entity, variableDescriptor, value); } moveScope.setMove(move); if (!move.isMoveDoable(stepScope.getScoreDirector())) { logger.trace( " Move index ({}) not doable, ignoring move ({}).", moveScope.getMoveIndex(), move); } else { doMove(moveScope); // TODO extract to PlacerForager if (maxScore == null || moveScope.getScore().compareTo(maxScore) > 0) { maxScore = moveScope.getScore(); // TODO for non explicit Best Fit *, default to random picking from a maxMoveScopeList nominatedMoveScope = moveScope; } if (moveIndex >= selectedCountLimit) { break; } } moveIndex++; if (termination.isPhaseTerminated(stepScope.getPhaseScope())) { break; } } return nominatedMoveScope; }