optaplanner-core/src/main/java/org/optaplanner/core/config/exhaustivesearch/ExhaustiveSearchPhaseConfig.java
@Override
    public ExhaustiveSearchPhase buildPhase(int phaseIndex, HeuristicConfigPolicy solverConfigPolicy,
            BestSolutionRecaller bestSolutionRecaller, Termination solverTermination) {
        HeuristicConfigPolicy phaseConfigPolicy = solverConfigPolicy.createPhaseConfigPolicy();
        phaseConfigPolicy.setReinitializeVariableFilterEnabled(true);
        phaseConfigPolicy.setInitializedChainedValueFilterEnabled(true);
        ExhaustiveSearchType exhaustiveSearchType_ = exhaustiveSearchType == null
                ? ExhaustiveSearchType.BRANCH_AND_BOUND : exhaustiveSearchType;
        phaseConfigPolicy.setEntitySorterManner(entitySorterManner != null ? entitySorterManner
                : exhaustiveSearchType_.getDefaultEntitySorterManner());
        phaseConfigPolicy.setValueSorterManner(valueSorterManner != null ? valueSorterManner
                : exhaustiveSearchType_.getDefaultValueSorterManner());
        DefaultExhaustiveSearchPhase phase = new DefaultExhaustiveSearchPhase(
                phaseIndex, solverConfigPolicy.getLogIndentation(), bestSolutionRecaller,
                buildPhaseTermination(phaseConfigPolicy, solverTermination));
        boolean scoreBounderEnabled = exhaustiveSearchType_.isScoreBounderEnabled();
        NodeExplorationType nodeExplorationType_;
        if (exhaustiveSearchType_ == ExhaustiveSearchType.BRUTE_FORCE) {
            nodeExplorationType_ = defaultIfNull(nodeExplorationType, NodeExplorationType.ORIGINAL_ORDER);
            if (nodeExplorationType_ != NodeExplorationType.ORIGINAL_ORDER) {
                throw new IllegalArgumentException("The phaseConfig (" + this
                        + ") has an nodeExplorationType ("  + nodeExplorationType
                        + ") which is not compatible with its exhaustiveSearchType (" + exhaustiveSearchType
                        + ").");
            }
        } else {
            nodeExplorationType_ = defaultIfNull(nodeExplorationType, NodeExplorationType.DEPTH_FIRST);
        }
        phase.setNodeComparator(nodeExplorationType_.buildNodeComparator(scoreBounderEnabled));
        EntitySelectorConfig entitySelectorConfig_ = buildEntitySelectorConfig(phaseConfigPolicy);
        EntitySelector entitySelector = entitySelectorConfig_.buildEntitySelector(phaseConfigPolicy,
                SelectionCacheType.PHASE, SelectionOrder.ORIGINAL);
        phase.setEntitySelector(entitySelector);
        phase.setDecider(buildDecider(phaseConfigPolicy, entitySelector, bestSolutionRecaller, phase.getTermination(),
                scoreBounderEnabled));
        EnvironmentMode environmentMode = phaseConfigPolicy.getEnvironmentMode();
        if (environmentMode.isNonIntrusiveFullAsserted()) {
            phase.setAssertWorkingSolutionScoreFromScratch(true);
            phase.setAssertStepScoreFromScratch(true); // Does nothing because ES doesn't use predictStepScore()
        }
        if (environmentMode.isIntrusiveFastAsserted()) {
            phase.setAssertExpectedWorkingSolutionScore(true);
            phase.setAssertExpectedStepScore(true); // Does nothing because ES doesn't use predictStepScore()
            phase.setAssertShadowVariablesAreNotStaleAfterStep(true); // Does nothing because ES doesn't use predictStepScore()
        }
        return phase;
    }
@Override
    public ExhaustiveSearchPhase buildPhase(int phaseIndex, HeuristicConfigPolicy solverConfigPolicy,
            BestSolutionRecaller bestSolutionRecaller, Termination solverTermination) {
        HeuristicConfigPolicy phaseConfigPolicy = solverConfigPolicy.createPhaseConfigPolicy();
        phaseConfigPolicy.setReinitializeVariableFilterEnabled(true);
        phaseConfigPolicy.setInitializedChainedValueFilterEnabled(true);
        ExhaustiveSearchType exhaustiveSearchType_ = exhaustiveSearchType == null
                ? ExhaustiveSearchType.BRANCH_AND_BOUND : exhaustiveSearchType;
        phaseConfigPolicy.setEntitySorterManner(entitySorterManner != null ? entitySorterManner
                : exhaustiveSearchType_.getDefaultEntitySorterManner());
        phaseConfigPolicy.setValueSorterManner(valueSorterManner != null ? valueSorterManner
                : exhaustiveSearchType_.getDefaultValueSorterManner());
        DefaultExhaustiveSearchPhase phase = new DefaultExhaustiveSearchPhase(
                phaseIndex, solverConfigPolicy.getLogIndentation(), bestSolutionRecaller,
                buildPhaseTermination(phaseConfigPolicy, solverTermination));
        boolean scoreBounderEnabled = exhaustiveSearchType_.isScoreBounderEnabled();
        NodeExplorationType nodeExplorationType_;
        if (exhaustiveSearchType_ == ExhaustiveSearchType.BRUTE_FORCE) {
            nodeExplorationType_ = defaultIfNull(nodeExplorationType, NodeExplorationType.ORIGINAL_ORDER);
            if (nodeExplorationType_ != NodeExplorationType.ORIGINAL_ORDER) {
                throw new IllegalArgumentException("The phaseConfig (" + this
                        + ") has an nodeExplorationType ("  + nodeExplorationType
                        + ") which is not compatible with its exhaustiveSearchType (" + exhaustiveSearchType
                        + ").");
            }
        } else {
            nodeExplorationType_ = defaultIfNull(nodeExplorationType, NodeExplorationType.DEPTH_FIRST);
        }
        phase.setNodeComparator(nodeExplorationType_.buildNodeComparator(scoreBounderEnabled));
        EntitySelectorConfig entitySelectorConfig_ = buildEntitySelectorConfig(phaseConfigPolicy);
        EntitySelector entitySelector = entitySelectorConfig_.buildEntitySelector(phaseConfigPolicy,
                SelectionCacheType.PHASE, SelectionOrder.ORIGINAL);
        phase.setEntitySelector(entitySelector);
        phase.setDecider(buildDecider(phaseConfigPolicy, entitySelector, bestSolutionRecaller, phase.getTermination(),
                scoreBounderEnabled));
        EnvironmentMode environmentMode = phaseConfigPolicy.getEnvironmentMode();
        if (environmentMode.isNonIntrusiveFullAsserted()) {
            phase.setAssertWorkingSolutionScoreFromScratch(true);
            phase.setAssertStepScoreFromScratch(true); // Does nothing because ES doesn't use predictStepScore()
        }
        if (environmentMode.isIntrusiveFastAsserted()) {
            phase.setAssertExpectedWorkingSolutionScore(true);
            phase.setAssertExpectedStepScore(true); // Does nothing because ES doesn't use predictStepScore()
            phase.setAssertShadowVariablesAreNotStaleAfterStep(true); // Does nothing because ES doesn't use predictStepScore()
        }
        return phase;
    }
@ Override public ExhaustiveSearchPhase buildPhase ( int phaseIndex , HeuristicConfigPolicy solverConfigPolicy , BestSolutionRecaller bestSolutionRecaller , Termination solverTermination ) { HeuristicConfigPolicy phaseConfigPolicy = solverConfigPolicy . createPhaseConfigPolicy ( ) ; phaseConfigPolicy . setReinitializeVariableFilterEnabled ( true ) ; phaseConfigPolicy . setInitializedChainedValueFilterEnabled ( true ) ; ExhaustiveSearchType exhaustiveSearchType_ = exhaustiveSearchType == null ? ExhaustiveSearchType . BRANCH_AND_BOUND : exhaustiveSearchType ; phaseConfigPolicy . setEntitySorterManner ( entitySorterManner != null ? entitySorterManner : exhaustiveSearchType_ . getDefaultEntitySorterManner ( ) ) ; phaseConfigPolicy . setValueSorterManner ( valueSorterManner != null ? valueSorterManner : exhaustiveSearchType_ . getDefaultValueSorterManner ( ) ) ; DefaultExhaustiveSearchPhase phase = new DefaultExhaustiveSearchPhase ( phaseIndex , solverConfigPolicy . getLogIndentation ( ) , bestSolutionRecaller , buildPhaseTermination ( phaseConfigPolicy , solverTermination ) ) ; boolean scoreBounderEnabled = exhaustiveSearchType_ . isScoreBounderEnabled ( ) ; NodeExplorationType nodeExplorationType_ ; if ( exhaustiveSearchType_ == ExhaustiveSearchType . BRUTE_FORCE ) { nodeExplorationType_ = defaultIfNull ( nodeExplorationType , NodeExplorationType . ORIGINAL_ORDER ) ; if ( nodeExplorationType_ != NodeExplorationType . ORIGINAL_ORDER ) { throw new IllegalArgumentException ( "The phaseConfig (" + this + ") has an nodeExplorationType (" + nodeExplorationType + ") which is not compatible with its exhaustiveSearchType (" + exhaustiveSearchType + ")." ) ; } } else { nodeExplorationType_ = defaultIfNull ( nodeExplorationType , NodeExplorationType . DEPTH_FIRST ) ; } phase . setNodeComparator ( nodeExplorationType_ . buildNodeComparator ( scoreBounderEnabled ) ) ; EntitySelectorConfig entitySelectorConfig_ = buildEntitySelectorConfig ( phaseConfigPolicy ) ; EntitySelector entitySelector = entitySelectorConfig_ . buildEntitySelector ( phaseConfigPolicy , SelectionCacheType . PHASE , SelectionOrder . ORIGINAL ) ; phase . setEntitySelector ( entitySelector ) ; phase . setDecider ( buildDecider ( phaseConfigPolicy , entitySelector , bestSolutionRecaller , phase . getTermination ( ) , scoreBounderEnabled ) ) ; EnvironmentMode environmentMode = phaseConfigPolicy . getEnvironmentMode ( ) ; if ( environmentMode . isNonIntrusiveFullAsserted ( ) ) { phase . setAssertWorkingSolutionScoreFromScratch ( true ) ; phase . setAssertStepScoreFromScratch ( true ) ; // Does nothing because ES doesn't use predictStepScore() } if ( environmentMode . isIntrusiveFastAsserted ( ) ) { phase . setAssertExpectedWorkingSolutionScore ( true ) ; phase . setAssertExpectedStepScore ( true ) ; // Does nothing because ES doesn't use predictStepScore() phase . setAssertShadowVariablesAreNotStaleAfterStep ( true ) ; // Does nothing because ES doesn't use predictStepScore() } return phase ; }
************************************************************************
************************************************************************