Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.drools.planner.core.heuristic.selector.variable;
 
 import java.util.List;
 
Determines the order in which the planning values of 1 planning entity class are selected for an algorithm
        implements Iterable<Object> {
    private boolean roundRobinSelection = false// TODO
    private List<ObjectselectedPlanningValueList = null;
    public PlanningValueSelector(PlanningVariableDescriptor planningVariableDescriptor) {
        this. = planningVariableDescriptor;
    }
    public void setSelectionOrder(PlanningValueSelectionOrder selectionOrder) {
        this. = selectionOrder;
    }
    public void setSelectionPromotion(PlanningValueSelectionPromotion selectionPromotion) {
        this. = selectionPromotion;
    }
    public void setRoundRobinSelection(boolean roundRobinSelection) {
        this. = roundRobinSelection;
    }
    // ************************************************************************
    // Worker methods
    // ************************************************************************
    @Override
    public void phaseStarted(AbstractSolverPhaseScope solverPhaseScope) {
        validateConfiguration();
        initSelectedPlanningValueList(solverPhaseScope);
    }
    private void validateConfiguration() {
            PlanningValueSorter planningValueSorter = .getPlanningValueSorter();
            if (!planningValueSorter.isSortStrengthSupported()) {
                throw new IllegalStateException("The selectionOrder (" + 
                        + ") can not be used on PlanningEntity ("
                        + .getPlanningEntityDescriptor().getPlanningEntityClass().getName()
                        + ")'s planningVariable (" + .getVariablePropertyName()
                        + ") that has no support for strength sorting. Check the @PlanningVariable annotation.");
            }
        }
    }
    private void initSelectedPlanningValueList(AbstractSolverPhaseScope solverPhaseScope) {
        List<ObjectworkingPlanningValueList = .getPlanningValueList(
                solverPhaseScope.getWorkingSolution());
        switch () {
            case :
                break;
            case :
                Collections.shuffle(workingPlanningValueListsolverPhaseScope.getWorkingRandom());
                break;
            case :
                PlanningValueSorter planningValueSorter = .getPlanningValueSorter();
                planningValueSorter.sortStrengthAscending(
                        solverPhaseScope.getWorkingSolution(), workingPlanningValueList);
                break;
            default:
                throw new IllegalStateException("The selectionOrder (" +  + ") is not implemented");
        }
         = workingPlanningValueList;
    }
    @Override
    public void phaseEnded(AbstractSolverPhaseScope solverPhaseScope) {
         = null;
    }
    public Iterator<Objectiterator() {
        return .iterator();
    }
New to GrepCode? Check out our FAQ X