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

## org.drools.planner.core.solver
Class DefaultSolver

    java.lang.Object
      org.drools.planner.core.solver.DefaultSolver

All Implemented Interfaces:
  Solver

    public class DefaultSolver

extends Object
implements Solver

Default implementation for `Solver`.

See Also:
  `Solver`

Field Summary
`protected BasicPlumbingTermination` | `basicPlumbingTermination`
`protected BestSolutionRecaller` | `bestSolutionRecaller`
`protected org.slf4j.Logger` | `logger`
`protected Long` | `randomSeed`
`protected SolverEventSupport` | `solverEventSupport`
`protected List<SolverPhase>` | `solverPhaseList`
`protected DefaultSolverScope` | `solverScope`
`protected AtomicBoolean` | `solving`
`protected Termination` | `termination`

Constructor Summary
`DefaultSolver()`

Method Summary
`void` | `addEventListener(SolverEventListener eventListener)`
`boolean` | `addProblemFactChange(ProblemFactChange problemFactChange)` Schedules a `ProblemFactChange` to be processed.
`void` | `addSolverPhaseLifecycleListener(SolverPhaseLifecycleListener solverPhaseLifecycleListener)`
`Solution` | `getBestSolution()`
`ScoreDefinition` | `getScoreDefinition()`
`List<SolverPhase>` | `getSolverPhaseList()`
`DefaultSolverScope` | `getSolverScope()`
`long` | `getTimeMillisSpend()` TODO timeMillisSpend should not continue to increase after the solver has been terminated
`boolean` | `isSolving()` This method is thread-safe.
`boolean` | `isTerminateEarly()` This method is thread-safe.
`void` | `removeEventListener(SolverEventListener eventListener)`
`void` | `removeSolverPhaseLifecycleListener(SolverPhaseLifecycleListener solverPhaseLifecycleListener)`
`protected void` | `runSolverPhases()`
`void` | `setBasicPlumbingTermination(BasicPlumbingTermination basicPlumbingTermination)`
`void` | `setBestSolutionRecaller(BestSolutionRecaller bestSolutionRecaller)`
`void` | `setPlanningProblem(Solution planningProblem)`
`void` | `setRandomSeed(long randomSeed)`
`void` | `setSolutionDirector(DefaultSolutionDirector solutionDirector)`
`void` | `setSolverPhaseList(List<SolverPhase> solverPhaseList)`
`void` | `setTermination(Termination termination)`
`void` | `solve()` Solves the planning problem.
`void` | `solvingEnded(DefaultSolverScope solverScope)`
`void` | `solvingStarted(DefaultSolverScope solverScope)`
`boolean` | `terminateEarly()` Notifies the solver that it should stop at its earliest convenience.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### logger

    protected final transient org.slf4j.Logger logger

### solverEventSupport

    protected SolverEventSupport solverEventSupport

### randomSeed

    protected Long randomSeed

### basicPlumbingTermination

    protected BasicPlumbingTermination basicPlumbingTermination

### termination

    protected Termination termination

### bestSolutionRecaller

    protected BestSolutionRecaller bestSolutionRecaller

### solverPhaseList

    protected List<SolverPhase> solverPhaseList

### solving

    protected AtomicBoolean solving

### solverScope

    protected DefaultSolverScope solverScope

Constructor Detail

### DefaultSolver

    public DefaultSolver()

Method Detail

### setRandomSeed

    public void setRandomSeed(long randomSeed)

### setSolutionDirector

    public void setSolutionDirector(DefaultSolutionDirector solutionDirector)

### getScoreDefinition

    public ScoreDefinition getScoreDefinition()

  Specified by:
    `getScoreDefinition` in interface `Solver`
  Returns:
    never null

### setBasicPlumbingTermination

    public void setBasicPlumbingTermination(BasicPlumbingTermination basicPlumbingTermination)

### setTermination

    public void setTermination(Termination termination)

### setBestSolutionRecaller

    public void setBestSolutionRecaller(BestSolutionRecaller bestSolutionRecaller)

### getSolverPhaseList

    public List<SolverPhase> getSolverPhaseList()

### setSolverPhaseList

    public void setSolverPhaseList(List<SolverPhase> solverPhaseList)

### setPlanningProblem

    public void setPlanningProblem(Solution planningProblem)

  Specified by:
    `setPlanningProblem` in interface `Solver`
  Parameters:
    `planningProblem` - never null

### getBestSolution

    public Solution getBestSolution()

  Specified by:
    `getBestSolution` in interface `Solver`
  Returns:
    never null after solving

### getTimeMillisSpend

    public long getTimeMillisSpend()

  Description copied from interface: `Solver`
  TODO timeMillisSpend should not continue to increase after the solver has been terminated

  Specified by:
    `getTimeMillisSpend` in interface `Solver`
  Returns:
    the amount of millis spend since this solver started

### getSolverScope

    public DefaultSolverScope getSolverScope()

### isSolving

    public boolean isSolving()

  Description copied from interface: `Solver`
  This method is thread-safe.

  Specified by:
    `isSolving` in interface `Solver`
  Returns:
    true if the `Solver.solve()` method is still running.

### terminateEarly

    public boolean terminateEarly()

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

  This method is thread-safe.

  Specified by:
    `terminateEarly` in interface `Solver`
  Returns:
    true if successful
  See Also:
    `Solver.isTerminateEarly()`, `Future.cancel(boolean)`

### isTerminateEarly

    public boolean isTerminateEarly()

  Description copied from interface: `Solver`
  This method is thread-safe.

  Specified by:
    `isTerminateEarly` in interface `Solver`
  Returns:
    true if terminateEarly has been called since the started.
  See Also:
    `Future.isCancelled()`

### addProblemFactChange

    public boolean addProblemFactChange(ProblemFactChange problemFactChange)

  Description copied from interface: `Solver`
  Schedules a `ProblemFactChange` to be processed.

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

  Follows specifications of `BlockingQueue.add(Object)` with by default a capacity of `Integer.MAX_VALUE`.

  Specified by:
    `addProblemFactChange` in interface `Solver`
  Parameters:
    `problemFactChange` - never null
  Returns:
    `true` (as specified by `Collection.add(E)`)

### solve

    public final void solve()

  Description copied from interface: `Solver`
  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 `Solver.terminateEarly()`.

  Specified by:
    `solve` in interface `Solver`
  See Also:
    `Solver.terminateEarly()`

### solvingStarted

    public void solvingStarted(DefaultSolverScope solverScope)

### runSolverPhases

    protected void runSolverPhases()

### solvingEnded

    public void solvingEnded(DefaultSolverScope solverScope)

### addEventListener

    public void addEventListener(SolverEventListener eventListener)

  Specified by:
    `addEventListener` in interface `Solver`
  Parameters:
    `eventListener` - never null

### removeEventListener

    public void removeEventListener(SolverEventListener eventListener)

  Specified by:
    `removeEventListener` in interface `Solver`
  Parameters:
    `eventListener` - never null

### addSolverPhaseLifecycleListener

    public void addSolverPhaseLifecycleListener(SolverPhaseLifecycleListener solverPhaseLifecycleListener)

### removeSolverPhaseLifecycleListener

    public void removeSolverPhaseLifecycleListener(SolverPhaseLifecycleListener solverPhaseLifecycleListener)

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

Copyright © 2001-2012 JBoss by Red Hat. All Rights Reserved.