Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2011 JBoss Inc
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   * http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.drools.planner.config.constructionheuristic.greedyFit;
 
 import java.util.List;
 import java.util.Set;
 
 
 @XStreamAlias("greedyFit")
 @Deprecated // Use ConstructionHeuristicSolverPhaseConfig
 public class GreedyFitSolverPhaseConfig extends SolverPhaseConfig {
 
     // Warning: all fields are null (and not defaulted) because they can be inherited
     // and also because the input config file should match the output config file
 
     @XStreamImplicit(itemFieldName = "greedyFitPlanningEntity")
 
 
         return ;
     }
 
     public void setGreedyFitPlanningEntityConfigList(List<GreedyFitPlanningEntityConfiggreedyFitPlanningEntityConfigList) {
         this. = greedyFitPlanningEntityConfigList;
     }
 
         return ;
     }
 
     public void setConstructionHeuristicPickEarlyType(ConstructionHeuristicPickEarlyType constructionHeuristicPickEarlyType) {
         this. = constructionHeuristicPickEarlyType;
     }
 
     // ************************************************************************
     // Builder methods
     // ************************************************************************
 
     public GreedyFitSolverPhase buildSolverPhase(EnvironmentMode environmentModeSolutionDescriptor solutionDescriptor,
             ScoreDefinition scoreDefinitionTermination solverTermination) {
         DefaultGreedyFitSolverPhase greedySolverPhase = new DefaultGreedyFitSolverPhase();
         configureSolverPhase(greedySolverPhaseenvironmentModescoreDefinitionsolverTermination);
         greedySolverPhase.setGreedyPlanningEntitySelector(buildGreedyPlanningEntitySelector(solutionDescriptor));
         greedySolverPhase.setGreedyDecider(buildGreedyDecider(solutionDescriptorenvironmentMode));
         if (environmentMode == . || environmentMode == .) {
             greedySolverPhase.setAssertStepScoreIsUncorrupted(true);
         }
         return greedySolverPhase;
     }
 
         GreedyPlanningEntitySelector greedyPlanningEntitySelector = new GreedyPlanningEntitySelector();
         List<PlanningEntitySelectorplanningEntitySelectorList = new ArrayList<PlanningEntitySelector>(.size());
         for (GreedyFitPlanningEntityConfig greedyFitPlanningEntityConfig : ) {
             planningEntitySelectorList.add(greedyFitPlanningEntityConfig.buildPlanningEntitySelector(solutionDescriptor));
         }
         greedyPlanningEntitySelector.setPlanningEntitySelectorList(planningEntitySelectorList);
         return greedyPlanningEntitySelector;
     }
 
     private GreedyDecider buildGreedyDecider(SolutionDescriptor solutionDescriptorEnvironmentMode environmentMode) {
         DefaultGreedyDecider greedyDecider = new DefaultGreedyDecider();
         ConstructionHeuristicPickEarlyType constructionHeuristicPickEarlyType = (this. == null)
        Set<Class<?>> planningEntityImplementationClassSet = solutionDescriptor.getPlanningEntityImplementationClassSet();
        if (planningEntityImplementationClassSet.size() != 1) {
            // TODO Multiple MUST BE SUPPORTED TOO
            throw new UnsupportedOperationException("Currently the greedyFit implementation only supports " +
                    "1 planningEntityImplementationClass.");
        }
        Class<?> planningEntityImplementationClass = planningEntityImplementationClassSet.iterator().next();
        PlanningEntityDescriptor planningEntityDescriptor = solutionDescriptor.getPlanningEntityDescriptor(planningEntityImplementationClass);
        PlanningVariableWalker planningVariableWalker = new PlanningVariableWalker(planningEntityDescriptor);
        List<PlanningValueWalkerplanningValueWalkerList = new ArrayList<PlanningValueWalker>();
        for (PlanningVariableDescriptor planningVariableDescriptor
                : planningEntityDescriptor.getPlanningVariableDescriptors()) {
            PlanningValueSelector planningValueSelector = new PlanningValueSelector(planningVariableDescriptor);
            // TODO should be configured to do BEST etc.
            PlanningValueWalker planningValueWalker = new PlanningValueWalker(
                    planningVariableDescriptorplanningValueSelector);
            planningValueWalkerList.add(planningValueWalker);
        }
        planningVariableWalker.setPlanningValueWalkerList(planningValueWalkerList);
        greedyDecider.setPlanningVariableWalker(planningVariableWalker);
        
        greedyDecider.setConstructionHeuristicPickEarlyType(constructionHeuristicPickEarlyType);
        if (environmentMode == .) {
            greedyDecider.setAssertMoveScoreIsUncorrupted(true);
        }
        return greedyDecider;
    }
    public void inherit(GreedyFitSolverPhaseConfig inheritedConfig) {
        super.inherit(inheritedConfig);
        if ( == null) {
             = inheritedConfig.getGreedyFitPlanningEntityConfigList();
        } else if (inheritedConfig.getGreedyFitPlanningEntityConfigList() != null) {
            // The inherited greedyFitPlanningEntityConfigList should be before the non-inherited one
            List<GreedyFitPlanningEntityConfigmergedList = new ArrayList<GreedyFitPlanningEntityConfig>(
                    inheritedConfig.getGreedyFitPlanningEntityConfigList());
            mergedList.addAll();
             = mergedList;
        }
        if ( == null) {
        }
    }
New to GrepCode? Check out our FAQ X