Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| OptaPlanner distribution 6.2.0.Beta1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.optaplanner.core.api.solver
Interface Solver

All Known Implementing Classes:
  DefaultSolver

    public interface Solver

A Solver solves a planning problem. Clients usually call `solve(Solution)` and then `getBestSolution()`.

These methods are not thread-safe and should be called from the same thread, except for the methods that are explicitly marked as thread-safe. Note that despite that `solve(Solution)` is not thread-safe for clients of this class, that method is free to do multi-threading inside itself.

Build by a `SolverFactory`.

Method Summary
`void` | `addEventListener(SolverEventListener eventListener)`
`boolean` | `addProblemFactChange(ProblemFactChange problemFactChange)` Schedules a `ProblemFactChange` to be processed.
`Solution` | `getBestSolution()`
`ScoreDirectorFactory` | `getScoreDirectorFactory()`
`long` | `getTimeMillisSpent()`
`boolean` | `isEveryProblemFactChangeProcessed()` Checks if all scheduled `ProblemFactChange`s have been processed.
`boolean` | `isSolving()` This method is thread-safe.
`boolean` | `isTerminateEarly()` This method is thread-safe.
`void` | `removeEventListener(SolverEventListener eventListener)`
`void` | `solve(Solution planningProblem)` Solves the planning problem.
`boolean` | `terminateEarly()` Notifies the solver that it should stop at its earliest convenience.

Method Detail

### getBestSolution

    Solution getBestSolution()

  Returns:
    never null, but it can return the original, uninitialized `Solution` with a `Score` null.

### getTimeMillisSpent

    long getTimeMillisSpent()

  Returns:
    the amount of millis spent between when this solver started and ended

### solve

    void solve(Solution planningProblem)

  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()`.

  Parameters:
    `planningProblem` - never null, usually its planning variables are uninitialized
  See Also:
    `terminateEarly()`

### isSolving

    boolean isSolving()

  This method is thread-safe.

  Returns:
    true if the `solve(Solution)` method is still running.

### terminateEarly

    boolean terminateEarly()

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

  This method is thread-safe.

  Returns:
    true if successful
  See Also:
    `isTerminateEarly()`, `Future.cancel(boolean)`

### isTerminateEarly

    boolean isTerminateEarly()

  This method is thread-safe.

  Returns:
    true if terminateEarly has been called since the started.
  See Also:
    `Future.isCancelled()`

### addProblemFactChange

    boolean addProblemFactChange(ProblemFactChange problemFactChange)

  Schedules a `ProblemFactChange` to be processed.

  As a side-effect, this restarts the `Solver`, effectively resetting all `Termination`s, but not `terminateEarly()`.

  This method is thread-safe. Follows specifications of `BlockingQueue.add(Object)` with by default a capacity of `Integer.MAX_VALUE`.

  Parameters:
    `problemFactChange` - never null
  Returns:
    true (as specified by `Collection.add(E)`)

### isEveryProblemFactChangeProcessed

    boolean isEveryProblemFactChangeProcessed()

  Checks if all scheduled `ProblemFactChange`s have been processed.

  This method is thread-safe.

  Returns:
    true if there are no `ProblemFactChange`s left to do

### addEventListener

    void addEventListener(SolverEventListener eventListener)

  Parameters:
    `eventListener` - never null

### removeEventListener

    void removeEventListener(SolverEventListener eventListener)

  Parameters:
    `eventListener` - never null

### getScoreDirectorFactory

    ScoreDirectorFactory getScoreDirectorFactory()

  Returns:
    never null

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| OptaPlanner distribution 6.2.0.Beta1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006-2014 JBoss by Red Hat. All Rights Reserved.