コード例 #1
0
 @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;
 }
コード例 #2
0
 public void inherit(SolverConfig inheritedConfig) {
   if (environmentMode == null) {
     environmentMode = inheritedConfig.getEnvironmentMode();
   }
   if (randomSeed == null) {
     randomSeed = inheritedConfig.getRandomSeed();
   }
   if (solutionClass == null) {
     solutionClass = inheritedConfig.getSolutionClass();
   }
   planningEntityClassList =
       ConfigUtils.inheritMergeableListProperty(
           planningEntityClassList, inheritedConfig.getPlanningEntityClassList());
   if (scoreDirectorFactoryConfig == null) {
     scoreDirectorFactoryConfig = inheritedConfig.getScoreDirectorFactoryConfig();
   } else if (inheritedConfig.getScoreDirectorFactoryConfig() != null) {
     scoreDirectorFactoryConfig.inherit(inheritedConfig.getScoreDirectorFactoryConfig());
   }
   if (terminationConfig == null) {
     terminationConfig = inheritedConfig.getTerminationConfig();
   } else if (inheritedConfig.getTerminationConfig() != null) {
     terminationConfig.inherit(inheritedConfig.getTerminationConfig());
   }
   solverPhaseConfigList =
       ConfigUtils.inheritMergeableListProperty(
           solverPhaseConfigList, inheritedConfig.getSolverPhaseConfigList());
 }
コード例 #3
0
 @Override
 public void inherit(KOptMoveSelectorConfig inheritedConfig) {
   super.inherit(inheritedConfig);
   entitySelectorConfig =
       ConfigUtils.inheritConfig(entitySelectorConfig, inheritedConfig.getEntitySelectorConfig());
   valueSelectorConfig =
       ConfigUtils.inheritConfig(valueSelectorConfig, inheritedConfig.getValueSelectorConfig());
 }
コード例 #4
0
 @Override
 public void inherit(CustomPhaseConfig inheritedConfig) {
   super.inherit(inheritedConfig);
   customPhaseCommandClassList =
       ConfigUtils.inheritMergeableListProperty(
           customPhaseCommandClassList, inheritedConfig.getCustomPhaseCommandClassList());
   customProperties =
       ConfigUtils.inheritMergeableMapProperty(
           customProperties, inheritedConfig.getCustomProperties());
   forceUpdateBestSolution =
       ConfigUtils.inheritOverwritableProperty(
           forceUpdateBestSolution, inheritedConfig.getForceUpdateBestSolution());
 }
コード例 #5
0
 public void inherit(ValueSelectorConfig inheritedConfig) {
   super.inherit(inheritedConfig);
   if (variableName == null) {
     variableName = inheritedConfig.getVariableName();
   }
   cacheType = ConfigUtils.inheritOverwritableProperty(cacheType, inheritedConfig.getCacheType());
   selectionOrder =
       ConfigUtils.inheritOverwritableProperty(
           selectionOrder, inheritedConfig.getSelectionOrder());
   probabilityWeightFactoryClass =
       ConfigUtils.inheritOverwritableProperty(
           probabilityWeightFactoryClass, inheritedConfig.getProbabilityWeightFactoryClass());
 }
コード例 #6
0
 public void inherit(LocalSearchSolverPhaseConfig inheritedConfig) {
   super.inherit(inheritedConfig);
   moveSelectorConfigList =
       ConfigUtils.inheritMergeableListProperty(
           moveSelectorConfigList, inheritedConfig.getMoveSelectorConfigList());
   if (acceptorConfig == null) {
     acceptorConfig = inheritedConfig.getAcceptorConfig();
   } else if (inheritedConfig.getAcceptorConfig() != null) {
     acceptorConfig.inherit(inheritedConfig.getAcceptorConfig());
   }
   if (foragerConfig == null) {
     foragerConfig = inheritedConfig.getForagerConfig();
   } else if (inheritedConfig.getForagerConfig() != null) {
     foragerConfig.inherit(inheritedConfig.getForagerConfig());
   }
 }
コード例 #7
0
 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;
 }
コード例 #8
0
 @Override
 public VariableListener buildVariableListener(InnerScoreDirector scoreDirector) {
   return ConfigUtils.newInstance(this, "variableListenerClass", variableListenerClass);
 }
コード例 #9
0
ファイル: PhaseConfig.java プロジェクト: aretesw/optaplanner
 @Override
 public void inherit(C inheritedConfig) {
   terminationConfig =
       ConfigUtils.inheritConfig(terminationConfig, inheritedConfig.getTerminationConfig());
 }