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;
 
 
A Solver solves planning problems.

Most methods are not thread-safe and should be called from the same thread.

 
 public interface Solver {

    

Parameters:
planningProblem never null
 
     void setPlanningProblem(Solution planningProblem);

    

Returns:
never null after solving
 
     Solution getBestSolution();

    
TODO timeMillisSpend should not continue to increase after the solver has been terminated

Returns:
the amount of millis spend since this solver started
 
     long getTimeMillisSpend();

    
Solves the planning problem. It can take minutes, even hours or days before this method returns, depending on the termination configuration. To terminate a Solver early, call terminateEarly().

 
     void solve();

    
This method is thread-safe.

Returns:
true if the solve() method is still running.
 
     boolean isSolving();

    
Notifies the solver that it should stop at its earliest convenience. This method returns immediately, but it takes an undetermined time for the solve() to actually return.

This method is thread-safe.

 
     boolean terminateEarly();

    
This method is thread-safe.

Returns:
true if terminateEarly has been called since the started.
See also:
java.util.concurrent.Future.isCancelled()
 
     boolean isTerminateEarly();

    
Schedules a org.drools.planner.core.solver.ProblemFactChange to be processed.

As a side-effect this restarts the Solver, effectively resetting all org.drools.planner.core.termination.Terminations, but not terminateEarly().

Follows specifications of java.util.concurrent.BlockingQueue.add(java.lang.Object) with by default a capacity of java.lang.Integer.MAX_VALUE.

Parameters:
problemFactChange never null
Returns:
true (as specified by java.util.Collection.add(java.lang.Object))
 
     boolean addProblemFactChange(ProblemFactChange problemFactChange);

    

Parameters:
eventListener never null
    void addEventListener(SolverEventListener eventListener);

    

Parameters:
eventListener never null
    void removeEventListener(SolverEventListener eventListener);

    

Returns:
never null
New to GrepCode? Check out our FAQ X