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.core.constructionheuristic.greedyFit.decider;
public class DefaultGreedyDecider implements GreedyDecider {
    protected boolean assertMoveScoreIsUncorrupted = false;
    public void setPlanningVariableWalker(PlanningVariableWalker planningVariableWalker) {
        this. = planningVariableWalker;
    }
            ConstructionHeuristicPickEarlyType constructionHeuristicPickEarlyType) {
        this. = constructionHeuristicPickEarlyType;
    }
    public void setAssertMoveScoreIsUncorrupted(boolean assertMoveScoreIsUncorrupted) {
        this. = assertMoveScoreIsUncorrupted;
    }
    // ************************************************************************
    // Worker methods
    // ************************************************************************
    public void phaseStarted(GreedyFitSolverPhaseScope greedyFitSolverPhaseScope) {
        .phaseStarted(greedyFitSolverPhaseScope);
    }
    public void beforeDeciding(GreedyFitStepScope greedyFitStepScope) {
        .beforeDeciding(greedyFitStepScope);
    }
    public void decideNextStep(GreedyFitStepScope greedyFitStepScope) {
        GreedyFitSolverPhaseScope greedyFitSolverPhaseScope = greedyFitStepScope.getGreedyFitSolverPhaseScope();
        .initWalk(greedyFitStepScope.getPlanningEntity());
        Score lastStepScore = greedyFitSolverPhaseScope.getLastCompletedStepScope().getScore();
        Score maxScore = greedyFitSolverPhaseScope.getScoreDefinition().getPerfectMinimumScore();
        while (.hasWalk()) {
            .walk();
            Score score = greedyFitSolverPhaseScope.calculateScoreFromWorkingMemory();
            if () {
                greedyFitSolverPhaseScope.assertWorkingScore(score);
            }
            if (score.compareTo(maxScore) > 0) {
                greedyFitStepScope.setVariableToValueMap(.getVariableToValueMap());
                maxScore = score;
            }
            if (
                    && lastStepScore != null
                    && score.compareTo(lastStepScore) >= 0) {
                break;
            }
        }
        greedyFitStepScope.setScore(maxScore);
    }
    public void stepDecided(GreedyFitStepScope greedyFitStepScope) {
        .stepDecided(greedyFitStepScope);
    }
    public void stepTaken(GreedyFitStepScope greedyFitStepScope) {
        .stepTaken(greedyFitStepScope);
    }
    public void phaseEnded(GreedyFitSolverPhaseScope greedyFitSolverPhaseScope) {
        .phaseEnded(greedyFitSolverPhaseScope);
    }
New to GrepCode? Check out our FAQ X