Class AbstractScoreHolder<Score_ extends Score<Score_>>
- java.lang.Object
-
- org.optaplanner.core.impl.score.holder.AbstractScoreHolder<Score_>
-
- Type Parameters:
Score_- theScoretype
- All Implemented Interfaces:
ScoreHolder<Score_>
- Direct Known Subclasses:
BendableBigDecimalScoreHolderImpl,BendableLongScoreHolderImpl,BendableScoreHolderImpl,HardMediumSoftBigDecimalScoreHolderImpl,HardMediumSoftLongScoreHolderImpl,HardMediumSoftScoreHolderImpl,HardSoftBigDecimalScoreHolderImpl,HardSoftLongScoreHolderImpl,HardSoftScoreHolderImpl,SimpleBigDecimalScoreHolderImpl,SimpleLongScoreHolderImpl,SimpleScoreHolderImpl
public abstract class AbstractScoreHolder<Score_ extends Score<Score_>> extends Object implements ScoreHolder<Score_>
Abstract superclass forScoreHolder.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classAbstractScoreHolder.ConstraintActivationUnMatchListener
-
Field Summary
Fields Modifier and Type Field Description protected booleanconstraintMatchEnabledprotected Map<String,ConstraintMatchTotal<Score_>>constraintMatchTotalMapprotected Map<Object,Indictment<Score_>>indictmentMapprotected Score_zeroScore
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractScoreHolder(boolean constraintMatchEnabled, Score_ zeroScore)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidconfigureConstraintWeight(org.kie.api.definition.rule.Rule rule, Score_ constraintWeight)protected List<Object>extractJustificationList(org.kie.api.runtime.rule.RuleContext kcontext)abstract Score_extractScore(int initScore)Map<String,ConstraintMatchTotal<Score_>>getConstraintMatchTotalMap()Map<Object,Indictment<Score_>>getIndictmentMap()voidimpactScore(org.kie.api.runtime.rule.RuleContext kcontext)For internal use only, use penalize() or reward() instead.abstract voidimpactScore(org.kie.api.runtime.rule.RuleContext kcontext, int weightMultiplier)For internal use only, use penalize() or reward() instead.abstract voidimpactScore(org.kie.api.runtime.rule.RuleContext kcontext, long weightMultiplier)For internal use only, use penalize() or reward() instead.abstract voidimpactScore(org.kie.api.runtime.rule.RuleContext kcontext, BigDecimal weightMultiplier)For internal use only, use penalize() or reward() instead.booleanisConstraintMatchEnabled()protected voidregisterConstraintMatch(org.kie.api.runtime.rule.RuleContext kcontext, Runnable constraintUndoListener, Supplier<Score_> scoreSupplier)Requires @OptaPlannerRuleEventListenerto be added as event listener onKieSession, otherwise the score changes caused by the constraint matches would not be undone.voidsetJustificationListConverter(BiFunction<List<Object>,org.kie.api.definition.rule.Rule,List<Object>> converter)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.optaplanner.core.api.score.holder.ScoreHolder
penalize, reward
-
-
-
-
Constructor Detail
-
AbstractScoreHolder
protected AbstractScoreHolder(boolean constraintMatchEnabled, Score_ zeroScore)
-
-
Method Detail
-
isConstraintMatchEnabled
public boolean isConstraintMatchEnabled()
-
getConstraintMatchTotalMap
public Map<String,ConstraintMatchTotal<Score_>> getConstraintMatchTotalMap()
-
getIndictmentMap
public Map<Object,Indictment<Score_>> getIndictmentMap()
-
configureConstraintWeight
public void configureConstraintWeight(org.kie.api.definition.rule.Rule rule, Score_ constraintWeight)
-
registerConstraintMatch
protected void registerConstraintMatch(org.kie.api.runtime.rule.RuleContext kcontext, Runnable constraintUndoListener, Supplier<Score_> scoreSupplier)Requires @OptaPlannerRuleEventListenerto be added as event listener onKieSession, otherwise the score changes caused by the constraint matches would not be undone. SeeDroolsScoreDirector.resetKieSession()for an example.- Parameters:
kcontext- The rule for which to register the match.constraintUndoListener- The operation to run to undo the match.scoreSupplier- The score change to be undone when constraint justification enabled.
-
impactScore
public void impactScore(org.kie.api.runtime.rule.RuleContext kcontext)
For internal use only, use penalize() or reward() instead.- Parameters:
kcontext- never null
-
impactScore
public abstract void impactScore(org.kie.api.runtime.rule.RuleContext kcontext, int weightMultiplier)For internal use only, use penalize() or reward() instead.- Parameters:
kcontext- never nullweightMultiplier- any
-
impactScore
public abstract void impactScore(org.kie.api.runtime.rule.RuleContext kcontext, long weightMultiplier)For internal use only, use penalize() or reward() instead.- Parameters:
kcontext- never nullweightMultiplier- any
-
impactScore
public abstract void impactScore(org.kie.api.runtime.rule.RuleContext kcontext, BigDecimal weightMultiplier)For internal use only, use penalize() or reward() instead.- Parameters:
kcontext- never nullweightMultiplier- any
-
extractScore
public abstract Score_ extractScore(int initScore)
-
extractJustificationList
protected List<Object> extractJustificationList(org.kie.api.runtime.rule.RuleContext kcontext)
-
setJustificationListConverter
public void setJustificationListConverter(BiFunction<List<Object>,org.kie.api.definition.rule.Rule,List<Object>> converter)
-
-