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.termination;
A Termination determines when a org.drools.planner.core.Solver or a org.drools.planner.core.phase.SolverPhase should stop.
public interface Termination extends SolverLifecycleListenerSolverPhaseLifecycleListener {

    
Called by the org.drools.planner.core.Solver after every phase to determine if the search should stop.

Parameters:
solverScope never null
Returns:
true if the search should terminate.
    boolean isSolverTerminated(DefaultSolverScope solverScope);

    
Called by the org.drools.planner.core.phase.SolverPhase after every step to determine if the search should stop.

Parameters:
solverPhaseScope never null
Returns:
true if the search should terminate.
    boolean isPhaseTerminated(AbstractSolverPhaseScope solverPhaseScope);

    
A timeGradient is a relative estimate of how long the search will continue. Clients that use a timeGradient should cache it at the start of a single step because some implementations are not time-stable. If a timeGradient can not be calculated, it should return -1.0. Several implementations (such a org.drools.planner.core.localsearch.decider.acceptor.simulatedannealing.SimulatedAnnealingAcceptor) require a correctly implemented timeGradient.

A Termination's timeGradient can be requested after they are terminated, so implementations should be careful not to return a timeGradient above 1.0.

Parameters:
solverScope never null
Returns:
timeGradient t for which 0.0 <= t <= 1.0 or -1.0 when it is not supported. At the start of a solver t is 0.0 and at the end t would be 1.0.
    double calculateSolverTimeGradient(DefaultSolverScope solverScope);

    
See calculateSolverTimeGradient(org.drools.planner.core.solver.DefaultSolverScope).

Parameters:
solverPhaseScope never null
Returns:
timeGradient t for which 0.0 <= t <= 1.0 or -1.0 when it is not supported. At the start of a phase t is 0.0 and at the end t would be 1.0.
    double calculatePhaseTimeGradient(AbstractSolverPhaseScope solverPhaseScope);
New to GrepCode? Check out our FAQ X