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

## org.optaplanner.core.impl.score.director
Interface ScoreDirector

All Known Implementing Classes:
  AbstractScoreDirector, DroolsScoreDirector, IncrementalScoreDirector, SimpleScoreDirector

    public interface ScoreDirector

The ScoreDirector holds the `workingSolution` and calculates the `Score` for that `Solution`.

Method Summary
`void` | `afterAllVariablesChanged(Object entity)`
`void` | `afterEntityAdded(Object entity)`
`void` | `afterEntityRemoved(Object entity)`
`void` | `afterProblemFactAdded(Object problemFact)`
`void` | `afterProblemFactChanged(Object problemFact)`
`void` | `afterProblemFactRemoved(Object problemFact)`
`void` | `afterVariableChanged(Object entity, String variableName)`
`void` | `assertExpectedWorkingScore(Score expectedWorkingScore, Object completedAction)` Asserts that if the `Score` is calculated for the current `workingSolution` in the current `ScoreDirector` (with possibly incremental calculation residue), it is equal to the parameter `expectedWorkingScore`.
`void` | `assertWorkingScoreFromScratch(Score workingScore, Object completedAction)` Asserts that if the `Score` is calculated for the current `workingSolution` in a fresh `ScoreDirector` (with no incremental calculation residue), it is equal to the parameter `workingScore`.
`void` | `beforeAllVariablesChanged(Object entity)`
`void` | `beforeEntityAdded(Object entity)`
`void` | `beforeEntityRemoved(Object entity)`
`void` | `beforeProblemFactAdded(Object problemFact)`
`void` | `beforeProblemFactChanged(Object problemFact)`
`void` | `beforeProblemFactRemoved(Object problemFact)`
`void` | `beforeVariableChanged(Object entity, String variableName)`
`Score` | `calculateScore()` Calculates the `Score` and updates the `workingSolution` accordingly.
`ScoreDirector` | `clone()` Clones this `ScoreDirector` and its `workingSolution`.
`Solution` | `cloneWorkingSolution()`
`int` | `countWorkingSolutionUninitializedVariables()`
`void` | `dispose()` Needs to be called after use because some implementations needs to clean up their resources.
`long` | `getCalculateCount()`
`Collection<ConstraintMatchTotal>` | `getConstraintMatchTotals()`
`ScoreDefinition` | `getScoreDefinition()`
`ScoreDirectorFactory` | `getScoreDirectorFactory()`
`SolutionDescriptor` | `getSolutionDescriptor()`
`Object` | `getTrailingEntity(PlanningVariableDescriptor chainedVariableDescriptor, Object planningValue)`
`int` | `getWorkingEntityCount()`
`List<Object>` | `getWorkingEntityList()`
`Solution` | `getWorkingSolution()` The `Solution` that is used to calculate the `Score`.
`int` | `getWorkingValueCount()`
`boolean` | `isConstraintMatchEnabled()`
`boolean` | `isWorkingSolutionInitialized()`
`void` | `setWorkingSolution(Solution workingSolution)` The `workingSolution` must never be the same instance as the `bestSolution`, it should be a (un)changed clone.

Method Detail

### getScoreDirectorFactory

    ScoreDirectorFactory getScoreDirectorFactory()

  Returns:
    never null

### getSolutionDescriptor

    SolutionDescriptor getSolutionDescriptor()

  Returns:
    never null

### getScoreDefinition

    ScoreDefinition getScoreDefinition()

  Returns:
    never null

### getWorkingSolution

    Solution getWorkingSolution()

  The `Solution` that is used to calculate the `Score`.

  Because a `Score` is best calculated incrementally (by delta's), the `ScoreDirector` needs to be notified when it's `workingSolution` changes.

  If the `Solution` has been changed since `calculateScore()` has been called, the `Solution.getScore()` of this `Solution` won't be correct.

  Returns:
    never null

### setWorkingSolution

    void setWorkingSolution(Solution workingSolution)

  The `workingSolution` must never be the same instance as the `bestSolution`, it should be a (un)changed clone.

  Parameters:
    `workingSolution` - never null

### cloneWorkingSolution

    Solution cloneWorkingSolution()

### beforeEntityAdded

    void beforeEntityAdded(Object entity)

### afterEntityAdded

    void afterEntityAdded(Object entity)

### beforeAllVariablesChanged

    void beforeAllVariablesChanged(Object entity)

### afterAllVariablesChanged

    void afterAllVariablesChanged(Object entity)

### beforeVariableChanged

    void beforeVariableChanged(Object entity,
                               String variableName)

### afterVariableChanged

    void afterVariableChanged(Object entity,
                              String variableName)

### beforeEntityRemoved

    void beforeEntityRemoved(Object entity)

### afterEntityRemoved

    void afterEntityRemoved(Object entity)

### beforeProblemFactAdded

    void beforeProblemFactAdded(Object problemFact)

### afterProblemFactAdded

    void afterProblemFactAdded(Object problemFact)

### beforeProblemFactChanged

    void beforeProblemFactChanged(Object problemFact)

### afterProblemFactChanged

    void afterProblemFactChanged(Object problemFact)

### beforeProblemFactRemoved

    void beforeProblemFactRemoved(Object problemFact)

### afterProblemFactRemoved

    void afterProblemFactRemoved(Object problemFact)

### getWorkingEntityCount

    int getWorkingEntityCount()

  Returns:
    >= 0

### getWorkingEntityList

    List<Object> getWorkingEntityList()

  Returns:
    never null: an empty list if there are none

### getWorkingValueCount

    int getWorkingValueCount()

  Returns:
    >= 0

### countWorkingSolutionUninitializedVariables

    int countWorkingSolutionUninitializedVariables()

### isWorkingSolutionInitialized

    boolean isWorkingSolutionInitialized()

  Returns:
    true if the `workingSolution` is initialized

### calculateScore

    Score calculateScore()

  Calculates the `Score` and updates the `workingSolution` accordingly.

  Returns:
    never null, the `Score` of the `workingSolution`

### getCalculateCount

    long getCalculateCount()

  Returns:
    at least 0L

### isConstraintMatchEnabled

    boolean isConstraintMatchEnabled()

  Returns:
    true if `getConstraintMatchTotals()` can be called

### getConstraintMatchTotals

    Collection<ConstraintMatchTotal> getConstraintMatchTotals()

  Returns:
    never null
  Throws:
    `IllegalStateException` - if `isConstraintMatchEnabled()` returns false

### clone

    ScoreDirector clone()

  Clones this `ScoreDirector` and its `workingSolution`. Use `getWorkingSolution()` to retrieve the `workingSolution` of that clone.

  This is heavy method, because it usually breaks incremental score calculation. Use it sparingly. Therefore it's best to clone lazily by delaying the clone call as long as possible.

  Returns:
    never null

### getTrailingEntity

    Object getTrailingEntity(PlanningVariableDescriptor chainedVariableDescriptor,
                             Object planningValue)

  Parameters:
    `chainedVariableDescriptor` - never null, must be `PlanningVariableDescriptor.isChained()` true and known to the `SolutionDescriptor`
    `planningValue` - sometimes null
  Returns:
    never null

### assertExpectedWorkingScore

    void assertExpectedWorkingScore(Score expectedWorkingScore,
                                    Object completedAction)

  Asserts that if the `Score` is calculated for the current `workingSolution` in the current `ScoreDirector` (with possibly incremental calculation residue), it is equal to the parameter `expectedWorkingScore`.

  Used to assert that skipping `calculateScore()` (when the score is otherwise determined) is correct,

  Parameters:
    `expectedWorkingScore` - never null
    `completedAction` - sometimes null, when assertion fails then the completedAction's `Object.toString()` is included in the exception message

### assertWorkingScoreFromScratch

    void assertWorkingScoreFromScratch(Score workingScore,
                                       Object completedAction)

  Asserts that if the `Score` is calculated for the current `workingSolution` in a fresh `ScoreDirector` (with no incremental calculation residue), it is equal to the parameter `workingScore`.

  Furthermore, if the assert fails, a score corruption analysis might be included in the exception message.

  Parameters:
    `workingScore` - never null
    `completedAction` - sometimes null, when assertion fails then the completedAction's `Object.toString()` is included* in the exception message
  See Also:
    `ScoreDirectorFactory.assertScoreFromScratch(Solution)`

### dispose

    void dispose()

  Needs to be called after use because some implementations needs to clean up their resources.

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

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