@Override public CustomPhase buildPhase( int phaseIndex, HeuristicConfigPolicy solverConfigPolicy, BestSolutionRecaller bestSolutionRecaller, Termination solverTermination) { HeuristicConfigPolicy phaseConfigPolicy = solverConfigPolicy.createPhaseConfigPolicy(); DefaultCustomPhase customPhase = new DefaultCustomPhase(); configurePhase( customPhase, phaseIndex, phaseConfigPolicy, bestSolutionRecaller, solverTermination); if (ConfigUtils.isEmptyCollection(customPhaseCommandClassList)) { throw new IllegalArgumentException( "Configure at least 1 <customPhaseCommandClass> in the <customPhase> configuration."); } List<CustomPhaseCommand> customPhaseCommandList = new ArrayList<>(customPhaseCommandClassList.size()); Map<String, String> customProperties_ = customProperties != null ? customProperties : Collections.<String, String>emptyMap(); for (Class<? extends CustomPhaseCommand> customPhaseCommandClass : customPhaseCommandClassList) { CustomPhaseCommand customPhaseCommand = ConfigUtils.newInstance(this, "customPhaseCommandClass", customPhaseCommandClass); customPhaseCommand.applyCustomProperties(customProperties_); customPhaseCommandList.add(customPhaseCommand); } customPhase.setCustomPhaseCommandList(customPhaseCommandList); customPhase.setForceUpdateBestSolution( forceUpdateBestSolution == null ? false : forceUpdateBestSolution); EnvironmentMode environmentMode = phaseConfigPolicy.getEnvironmentMode(); if (environmentMode.isNonIntrusiveFullAsserted()) { customPhase.setAssertStepScoreFromScratch(true); } return customPhase; }
private ValueSelector applyProbability( SelectionCacheType resolvedCacheType, SelectionOrder resolvedSelectionOrder, ValueSelector valueSelector) { if (resolvedSelectionOrder == SelectionOrder.PROBABILISTIC) { if (probabilityWeightFactoryClass == null) { throw new IllegalArgumentException( "The valueSelectorConfig (" + this + ") with resolvedSelectionOrder (" + resolvedSelectionOrder + ") needs a probabilityWeightFactoryClass (" + probabilityWeightFactoryClass + ")."); } SelectionProbabilityWeightFactory probabilityWeightFactory = ConfigUtils.newInstance( this, "probabilityWeightFactoryClass", probabilityWeightFactoryClass); if (!(valueSelector instanceof EntityIndependentValueSelector)) { throw new IllegalArgumentException( "The valueSelectorConfig (" + this + ") with resolvedSelectionOrder (" + resolvedSelectionOrder + ") needs to be based on a EntityIndependentValueSelector." + " Check your @" + ValueRange.class.getSimpleName() + " annotations."); } valueSelector = new ProbabilityValueSelector( (EntityIndependentValueSelector) valueSelector, resolvedCacheType, probabilityWeightFactory); } return valueSelector; }
@Override public VariableListener buildVariableListener(InnerScoreDirector scoreDirector) { return ConfigUtils.newInstance(this, "variableListenerClass", variableListenerClass); }