Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010 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.phase;
 
 
 
 public abstract class AbstractSolverPhase implements SolverPhaseSolverPhaseLifecycleListener {
 
     protected final transient Logger logger = LoggerFactory.getLogger(getClass());
 
     protected Termination termination;
 
 
 
     public void setTermination(Termination termination) {
         this. = termination;
     }
 
     public void setBestSolutionRecaller(BestSolutionRecaller bestSolutionRecaller) {
         this. = bestSolutionRecaller;
     }
 
     // ************************************************************************
     // Worker methods
     // ************************************************************************
 
     public void phaseStarted(AbstractSolverPhaseScope solverPhaseScope) {
         solverPhaseScope.reset();
         .phaseStarted(solverPhaseScope);
         .firePhaseStarted(solverPhaseScope);
     }
 
     public void beforeDeciding(AbstractStepScope stepScope) {
         .beforeDeciding(stepScope);
     }
 
     public void stepDecided(AbstractStepScope stepScope) {
         .stepDecided(stepScope);
         .fireStepDecided(stepScope);
     }
 
     public void stepTaken(AbstractStepScope stepScope) {
         .extractBestSolution(stepScope);
         .stepTaken(stepScope);
         .fireStepTaken(stepScope);
     }
 
     public void phaseEnded(AbstractSolverPhaseScope solverPhaseScope) {
         DefaultSolverScope solverScope = solverPhaseScope.getSolverScope();
         // At the end of the phase, the best solution should be in the working memory for the next phase
         // TODO WORKAROUND because the best solution might not be initialized yet (and than it's currently null)
         Solution bestSolution = solverScope.getBestSolution();
         if (bestSolution != null) {
             // Clone of bestSolution because next phase will change the working solution but might not improve best
             solverScope.getSolutionDirector().setWorkingSolution(bestSolution.cloneSolution());
         }
         .phaseEnded(solverPhaseScope);
         .firePhaseEnded(solverPhaseScope);
     }
 
     public void addSolverPhaseLifecycleListener(SolverPhaseLifecycleListener lifecycleListener) {
         .addEventListener(lifecycleListener);
     }
 
     public void removeSolverPhaseLifecycleListener(SolverPhaseLifecycleListener lifecycleListener) {
         .removeEventListener(lifecycleListener);
     }
 
New to GrepCode? Check out our FAQ X