OptaPlanner core 6.2.0.Beta1

org.optaplanner.core.impl.score.director.incremental
Class IncrementalScoreDirector

java.lang.Object
  extended by org.optaplanner.core.impl.score.director.AbstractScoreDirector<IncrementalScoreDirectorFactory>
      extended by org.optaplanner.core.impl.score.director.incremental.IncrementalScoreDirector
All Implemented Interfaces:
Cloneable, InnerScoreDirector, ScoreDirector

public class IncrementalScoreDirector
extends AbstractScoreDirector<IncrementalScoreDirectorFactory>

Incremental java implementation of ScoreDirector, which only recalculates the Score of the part of the Solution workingSolution that changed, instead of the going through the entire Solution. This is incremental calculation, which is fast.

See Also:
ScoreDirector

Field Summary
 
Fields inherited from class org.optaplanner.core.impl.score.director.AbstractScoreDirector
allChangesWillBeUndoneBeforeStepEnds, calculateCount, constraintMatchEnabledPreference, logger, scoreDirectorFactory, trailingEntityMapSupport, variableListenerSupport, workingEntityListRevision, workingSolution
 
Constructor Summary
IncrementalScoreDirector(IncrementalScoreDirectorFactory scoreDirectorFactory, boolean constraintMatchEnabledPreference, IncrementalScoreCalculator incrementalScoreCalculator)
           
 
Method Summary
 void afterEntityAdded(EntityDescriptor entityDescriptor, Object entity)
           
 void afterEntityRemoved(EntityDescriptor entityDescriptor, Object entity)
           
 void afterProblemFactAdded(Object problemFact)
           
 void afterProblemFactChanged(Object problemFact)
           
 void afterProblemFactRemoved(Object problemFact)
           
 void afterVariableChanged(VariableDescriptor variableDescriptor, Object entity)
           
 void beforeEntityAdded(EntityDescriptor entityDescriptor, Object entity)
           
 void beforeEntityRemoved(EntityDescriptor entityDescriptor, Object entity)
           
 void beforeProblemFactAdded(Object problemFact)
           
 void beforeProblemFactChanged(Object problemFact)
           
 void beforeProblemFactRemoved(Object problemFact)
           
 void beforeVariableChanged(VariableDescriptor variableDescriptor, Object entity)
           
 Score calculateScore()
          Calculates the Score and updates the workingSolution accordingly.
 Collection<ConstraintMatchTotal> getConstraintMatchTotals()
           
 IncrementalScoreCalculator getIncrementalScoreCalculator()
           
 boolean isConstraintMatchEnabled()
           
 void setWorkingSolution(Solution workingSolution)
          The workingSolution must never be the same instance as the bestSolution, it should be a (un)changed clone.
 
Methods inherited from class org.optaplanner.core.impl.score.director.AbstractScoreDirector
afterEntityAdded, afterEntityRemoved, afterVariableChanged, assertExpectedWorkingScore, assertWorkingScoreFromScratch, beforeEntityAdded, beforeEntityRemoved, beforeVariableChanged, buildScoreCorruptionAnalysis, clone, cloneWorkingSolution, countWorkingSolutionUninitializedVariables, dispose, getCalculateCount, getScoreDefinition, getScoreDirectorFactory, getSolutionDescriptor, getTrailingEntity, getWorkingEntityCount, getWorkingEntityList, getWorkingEntityListRevision, getWorkingSolution, getWorkingValueCount, isAllChangesWillBeUndoneBeforeStepEnds, isWorkingEntityListDirty, isWorkingSolutionInitialized, setAllChangesWillBeUndoneBeforeStepEnds, setCalculatedScore, setWorkingEntityListDirty, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IncrementalScoreDirector

public IncrementalScoreDirector(IncrementalScoreDirectorFactory scoreDirectorFactory,
                                boolean constraintMatchEnabledPreference,
                                IncrementalScoreCalculator incrementalScoreCalculator)
Method Detail

getIncrementalScoreCalculator

public IncrementalScoreCalculator getIncrementalScoreCalculator()

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
Overrides:
setWorkingSolution in class AbstractScoreDirector<IncrementalScoreDirectorFactory>
Parameters:
workingSolution - never null

calculateScore

public Score calculateScore()
Description copied from interface: ScoreDirector
Calculates the Score and updates the workingSolution accordingly.

Returns:
never null, the Score of the workingSolution

isConstraintMatchEnabled

public boolean isConstraintMatchEnabled()
Returns:
true if ScoreDirector.getConstraintMatchTotals() can be called

getConstraintMatchTotals

public Collection<ConstraintMatchTotal> getConstraintMatchTotals()
Returns:
never null

beforeEntityAdded

public void beforeEntityAdded(EntityDescriptor entityDescriptor,
                              Object entity)
Overrides:
beforeEntityAdded in class AbstractScoreDirector<IncrementalScoreDirectorFactory>

afterEntityAdded

public void afterEntityAdded(EntityDescriptor entityDescriptor,
                             Object entity)
Overrides:
afterEntityAdded in class AbstractScoreDirector<IncrementalScoreDirectorFactory>

beforeVariableChanged

public void beforeVariableChanged(VariableDescriptor variableDescriptor,
                                  Object entity)
Specified by:
beforeVariableChanged in interface ScoreDirector
Overrides:
beforeVariableChanged in class AbstractScoreDirector<IncrementalScoreDirectorFactory>

afterVariableChanged

public void afterVariableChanged(VariableDescriptor variableDescriptor,
                                 Object entity)
Specified by:
afterVariableChanged in interface ScoreDirector
Overrides:
afterVariableChanged in class AbstractScoreDirector<IncrementalScoreDirectorFactory>

beforeEntityRemoved

public void beforeEntityRemoved(EntityDescriptor entityDescriptor,
                                Object entity)
Overrides:
beforeEntityRemoved in class AbstractScoreDirector<IncrementalScoreDirectorFactory>

afterEntityRemoved

public void afterEntityRemoved(EntityDescriptor entityDescriptor,
                               Object entity)
Overrides:
afterEntityRemoved in class AbstractScoreDirector<IncrementalScoreDirectorFactory>

beforeProblemFactAdded

public void beforeProblemFactAdded(Object problemFact)
Specified by:
beforeProblemFactAdded in interface ScoreDirector
Overrides:
beforeProblemFactAdded in class AbstractScoreDirector<IncrementalScoreDirectorFactory>

afterProblemFactAdded

public void afterProblemFactAdded(Object problemFact)
Specified by:
afterProblemFactAdded in interface ScoreDirector
Overrides:
afterProblemFactAdded in class AbstractScoreDirector<IncrementalScoreDirectorFactory>

beforeProblemFactChanged

public void beforeProblemFactChanged(Object problemFact)
Specified by:
beforeProblemFactChanged in interface ScoreDirector
Overrides:
beforeProblemFactChanged in class AbstractScoreDirector<IncrementalScoreDirectorFactory>

afterProblemFactChanged

public void afterProblemFactChanged(Object problemFact)
Specified by:
afterProblemFactChanged in interface ScoreDirector
Overrides:
afterProblemFactChanged in class AbstractScoreDirector<IncrementalScoreDirectorFactory>

beforeProblemFactRemoved

public void beforeProblemFactRemoved(Object problemFact)
Specified by:
beforeProblemFactRemoved in interface ScoreDirector
Overrides:
beforeProblemFactRemoved in class AbstractScoreDirector<IncrementalScoreDirectorFactory>

afterProblemFactRemoved

public void afterProblemFactRemoved(Object problemFact)
Specified by:
afterProblemFactRemoved in interface ScoreDirector
Overrides:
afterProblemFactRemoved in class AbstractScoreDirector<IncrementalScoreDirectorFactory>

OptaPlanner core 6.2.0.Beta1

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