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

## org.optaplanner.core.impl.score.director
Class AbstractScoreDirector<F extends AbstractScoreDirectorFactory>

    java.lang.Object
      org.optaplanner.core.impl.score.director.AbstractScoreDirector<F>

All Implemented Interfaces:
  Cloneable, InnerScoreDirector, ScoreDirector

Direct Known Subclasses:
  DroolsScoreDirector, EasyScoreDirector, IncrementalScoreDirector

    public abstract class AbstractScoreDirector<F extends AbstractScoreDirectorFactory>

extends Object
implements InnerScoreDirector, Cloneable

Abstract superclass for `ScoreDirector`.

Implementation note: Extending classes should follow these guidelines:

- before* method: last statement should be a call to the super method
- after* method: first statement should be a call to the super method

See Also:
  `ScoreDirector`

Field Summary
`protected boolean` | `allChangesWillBeUndoneBeforeStepEnds`
`protected long` | `calculateCount`
`protected boolean` | `constraintMatchEnabledPreference`
`protected org.slf4j.Logger` | `logger`
`protected F` | `scoreDirectorFactory`
`protected TrailingEntityMapSupport` | `trailingEntityMapSupport`
`protected VariableListenerSupport` | `variableListenerSupport`
`protected long` | `workingEntityListRevision`
`protected Solution` | `workingSolution`

Constructor Summary
`protected` | `AbstractScoreDirector(F scoreDirectorFactory)`

Method Summary
`void` | `afterEntityAdded(EntityDescriptor entityDescriptor, Object entity)`
`void` | `afterEntityAdded(Object entity)`
`void` | `afterEntityRemoved(EntityDescriptor entityDescriptor, Object entity)`
`void` | `afterEntityRemoved(Object entity)`
`void` | `afterProblemFactAdded(Object problemFact)`
`void` | `afterProblemFactChanged(Object problemFact)`
`void` | `afterProblemFactRemoved(Object problemFact)`
`void` | `afterShadowVariableChanged(Object entity, String variableName)`
`void` | `afterVariableChanged(GenuineVariableDescriptor variableDescriptor, Object entity)`
`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` | `beforeEntityAdded(EntityDescriptor entityDescriptor, Object entity)`
`void` | `beforeEntityAdded(Object entity)`
`void` | `beforeEntityRemoved(EntityDescriptor entityDescriptor, Object entity)`
`void` | `beforeEntityRemoved(Object entity)`
`void` | `beforeProblemFactAdded(Object problemFact)`
`void` | `beforeProblemFactChanged(Object problemFact)`
`void` | `beforeProblemFactRemoved(Object problemFact)`
`void` | `beforeShadowVariableChanged(Object entity, String variableName)`
`void` | `beforeVariableChanged(GenuineVariableDescriptor variableDescriptor, Object entity)`
`void` | `beforeVariableChanged(Object entity, String variableName)`
`protected String` | `buildScoreCorruptionAnalysis(ScoreDirector uncorruptedScoreDirector)`
`AbstractScoreDirector` | `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()`
`F` | `getScoreDirectorFactory()`
`SolutionDescriptor` | `getSolutionDescriptor()`
`Object` | `getTrailingEntity(GenuineVariableDescriptor chainedVariableDescriptor, Object planningValue)`
`int` | `getWorkingEntityCount()`
`List<Object>` | `getWorkingEntityList()`
`long` | `getWorkingEntityListRevision()`
`Solution` | `getWorkingSolution()` The `Solution` that is used to calculate the `Score`.
`int` | `getWorkingValueCount()`
`boolean` | `isAllChangesWillBeUndoneBeforeStepEnds()`
`boolean` | `isConstraintMatchEnabled()`
`boolean` | `isWorkingEntityListDirty(long expectedWorkingEntityListRevision)`
`boolean` | `isWorkingSolutionInitialized()`
`void` | `setAllChangesWillBeUndoneBeforeStepEnds(boolean allChangesWillBeUndoneBeforeStepEnds)` Do not waste performance by propagating changes to step (or higher) mechanisms.
`protected void` | `setCalculatedScore(Score score)`
`protected void` | `setWorkingEntityListDirty()`
`void` | `setWorkingSolution(Solution workingSolution)` The `workingSolution` must never be the same instance as the `bestSolution`, it should be a (un)changed clone.
`String` | `toString()`

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

Methods inherited from interface org.optaplanner.core.impl.score.director.ScoreDirector
`calculateScore`

Field Detail

### logger

    protected final transient org.slf4j.Logger logger

### scoreDirectorFactory

    protected final F extends AbstractScoreDirectorFactory scoreDirectorFactory

### constraintMatchEnabledPreference

    protected boolean constraintMatchEnabledPreference

### trailingEntityMapSupport

    protected TrailingEntityMapSupport trailingEntityMapSupport

### variableListenerSupport

    protected VariableListenerSupport variableListenerSupport

### workingSolution

    protected Solution workingSolution

### workingEntityListRevision

    protected long workingEntityListRevision

### allChangesWillBeUndoneBeforeStepEnds

    protected boolean allChangesWillBeUndoneBeforeStepEnds

### calculateCount

    protected long calculateCount

Constructor Detail

### AbstractScoreDirector

    protected AbstractScoreDirector(F scoreDirectorFactory)

Method Detail

### getScoreDirectorFactory

    public F getScoreDirectorFactory()

  Specified by:
    `getScoreDirectorFactory` in interface `InnerScoreDirector`
  Returns:
    never null

### getSolutionDescriptor

    public SolutionDescriptor getSolutionDescriptor()

  Specified by:
    `getSolutionDescriptor` in interface `InnerScoreDirector`
  Returns:
    never null

### getScoreDefinition

    public ScoreDefinition getScoreDefinition()

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

### getWorkingSolution

    public Solution getWorkingSolution()

  Description copied from interface: `ScoreDirector`
  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 `ScoreDirector.calculateScore()` has been called, the `Solution.getScore()` of this `Solution` won't be correct.

  Specified by:
    `getWorkingSolution` in interface `ScoreDirector`
  Returns:
    never null

### getWorkingEntityListRevision

    public long getWorkingEntityListRevision()

  Specified by:
    `getWorkingEntityListRevision` in interface `InnerScoreDirector`
  Returns:
    used to check `InnerScoreDirector.isWorkingEntityListDirty(long)` later on

### isAllChangesWillBeUndoneBeforeStepEnds

    public boolean isAllChangesWillBeUndoneBeforeStepEnds()

### setAllChangesWillBeUndoneBeforeStepEnds

    public void setAllChangesWillBeUndoneBeforeStepEnds(boolean allChangesWillBeUndoneBeforeStepEnds)

  Description copied from interface: `InnerScoreDirector`
  Do not waste performance by propagating changes to step (or higher) mechanisms.

  Specified by:
    `setAllChangesWillBeUndoneBeforeStepEnds` in interface `InnerScoreDirector`
  Parameters:
    `allChangesWillBeUndoneBeforeStepEnds` - true if all changes will be undone

### getCalculateCount

    public long getCalculateCount()

  Specified by:
    `getCalculateCount` in interface `InnerScoreDirector`
  Returns:
    at least 0L

### setWorkingSolution

    public void setWorkingSolution(Solution workingSolution)

  Description copied from interface: `ScoreDirector`
  The `workingSolution` must never be the same instance as the `bestSolution`, it should be a (un)changed clone.

  Only call this method on a separate `ScoreDirector` instance, build by `Solver.getScoreDirectorFactory()`, not on the one used inside the `Solver` itself.

  Specified by:
    `setWorkingSolution` in interface `ScoreDirector`
  Parameters:
    `workingSolution` - never null

### isWorkingEntityListDirty

    public boolean isWorkingEntityListDirty(long expectedWorkingEntityListRevision)

  Specified by:
    `isWorkingEntityListDirty` in interface `InnerScoreDirector`
  Parameters:
    `expectedWorkingEntityListRevision` - an
  Returns:
    true if the entityList might have a different set of instances now

### setWorkingEntityListDirty

    protected void setWorkingEntityListDirty()

### cloneWorkingSolution

    public Solution cloneWorkingSolution()

  Specified by:
    `cloneWorkingSolution` in interface `InnerScoreDirector`

### getWorkingEntityCount

    public int getWorkingEntityCount()

  Specified by:
    `getWorkingEntityCount` in interface `InnerScoreDirector`
  Returns:
    >= 0

### getWorkingEntityList

    public List<Object> getWorkingEntityList()

  Specified by:
    `getWorkingEntityList` in interface `InnerScoreDirector`
  Returns:
    never null: an empty list if there are none

### getWorkingValueCount

    public int getWorkingValueCount()

  Specified by:
    `getWorkingValueCount` in interface `InnerScoreDirector`
  Returns:
    >= 0

### countWorkingSolutionUninitializedVariables

    public int countWorkingSolutionUninitializedVariables()

  Specified by:
    `countWorkingSolutionUninitializedVariables` in interface `InnerScoreDirector`

### isWorkingSolutionInitialized

    public boolean isWorkingSolutionInitialized()

  Specified by:
    `isWorkingSolutionInitialized` in interface `InnerScoreDirector`
  Returns:
    true if all the movable planning entities are initialized

### setCalculatedScore

    protected void setCalculatedScore(Score score)

### isConstraintMatchEnabled

    public boolean isConstraintMatchEnabled()

  Specified by:
    `isConstraintMatchEnabled` in interface `ScoreDirector`
  Returns:
    true if `ScoreDirector.getConstraintMatchTotals()` can be called

### getConstraintMatchTotals

    public Collection<ConstraintMatchTotal> getConstraintMatchTotals()

  Specified by:
    `getConstraintMatchTotals` in interface `ScoreDirector`
  Returns:
    never null

### clone

    public AbstractScoreDirector clone()

  Description copied from interface: `InnerScoreDirector`
  Clones this `ScoreDirector` and its `workingSolution`. Use `ScoreDirector.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.

  Specified by:
    `clone` in interface `InnerScoreDirector`
  Overrides:
    `clone` in class `Object`
  Returns:
    never null

### dispose

    public void dispose()

  Description copied from interface: `ScoreDirector`
  Needs to be called after use because some implementations needs to clean up their resources.

  Specified by:
    `dispose` in interface `ScoreDirector`

### getTrailingEntity

    public Object getTrailingEntity(GenuineVariableDescriptor chainedVariableDescriptor,
                                    Object planningValue)

  Specified by:
    `getTrailingEntity` in interface `InnerScoreDirector`
  Parameters:
    `chainedVariableDescriptor` - never null, must be `GenuineVariableDescriptor.isChained()` true and known to the `SolutionDescriptor`
    `planningValue` - sometimes null
  Returns:
    never null

### beforeEntityAdded

    public final void beforeEntityAdded(Object entity)

  Specified by:
    `beforeEntityAdded` in interface `ScoreDirector`

### afterEntityAdded

    public final void afterEntityAdded(Object entity)

  Specified by:
    `afterEntityAdded` in interface `ScoreDirector`

### beforeVariableChanged

    public final void beforeVariableChanged(Object entity,
                                            String variableName)

  Specified by:
    `beforeVariableChanged` in interface `ScoreDirector`

### afterVariableChanged

    public final void afterVariableChanged(Object entity,
                                           String variableName)

  Specified by:
    `afterVariableChanged` in interface `ScoreDirector`

### beforeEntityRemoved

    public final void beforeEntityRemoved(Object entity)

  Specified by:
    `beforeEntityRemoved` in interface `ScoreDirector`

### afterEntityRemoved

    public final void afterEntityRemoved(Object entity)

  Specified by:
    `afterEntityRemoved` in interface `ScoreDirector`

### beforeEntityAdded

    public void beforeEntityAdded(EntityDescriptor entityDescriptor,
                                  Object entity)

### afterEntityAdded

    public void afterEntityAdded(EntityDescriptor entityDescriptor,
                                 Object entity)

### beforeVariableChanged

    public void beforeVariableChanged(GenuineVariableDescriptor variableDescriptor,
                                      Object entity)

### afterVariableChanged

    public void afterVariableChanged(GenuineVariableDescriptor variableDescriptor,
                                     Object entity)

### beforeShadowVariableChanged

    public void beforeShadowVariableChanged(Object entity,
                                            String variableName)

### afterShadowVariableChanged

    public void afterShadowVariableChanged(Object entity,
                                           String variableName)

### beforeEntityRemoved

    public void beforeEntityRemoved(EntityDescriptor entityDescriptor,
                                    Object entity)

### afterEntityRemoved

    public void afterEntityRemoved(EntityDescriptor entityDescriptor,
                                   Object entity)

### beforeProblemFactAdded

    public void beforeProblemFactAdded(Object problemFact)

  Specified by:
    `beforeProblemFactAdded` in interface `ScoreDirector`

### afterProblemFactAdded

    public void afterProblemFactAdded(Object problemFact)

  Specified by:
    `afterProblemFactAdded` in interface `ScoreDirector`

### beforeProblemFactChanged

    public void beforeProblemFactChanged(Object problemFact)

  Specified by:
    `beforeProblemFactChanged` in interface `ScoreDirector`

### afterProblemFactChanged

    public void afterProblemFactChanged(Object problemFact)

  Specified by:
    `afterProblemFactChanged` in interface `ScoreDirector`

### beforeProblemFactRemoved

    public void beforeProblemFactRemoved(Object problemFact)

  Specified by:
    `beforeProblemFactRemoved` in interface `ScoreDirector`

### afterProblemFactRemoved

    public void afterProblemFactRemoved(Object problemFact)

  Specified by:
    `afterProblemFactRemoved` in interface `ScoreDirector`

### assertExpectedWorkingScore

    public void assertExpectedWorkingScore(Score expectedWorkingScore,
                                           Object completedAction)

  Description copied from interface: `InnerScoreDirector`
  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 `ScoreDirector.calculateScore()` (when the score is otherwise determined) is correct,

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

### assertWorkingScoreFromScratch

    public void assertWorkingScoreFromScratch(Score workingScore,
                                              Object completedAction)

  Description copied from interface: `InnerScoreDirector`
  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.

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

### buildScoreCorruptionAnalysis

    protected String buildScoreCorruptionAnalysis(ScoreDirector uncorruptedScoreDirector)

  Parameters:
    `uncorruptedScoreDirector` - never null
  Returns:
    never null

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| OptaPlanner distribution 6.1.0.Beta4
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.