public class BendableLongScoreHolder extends AbstractScoreHolder<BendableLongScore>
BendableLongScore,
Serialized FormAbstractScoreHolder.ConstraintActivationUnMatchListener| Modifier and Type | Field and Description |
|---|---|
protected Map<org.kie.api.definition.rule.Rule,BiConsumer<org.kie.api.runtime.rule.RuleContext,Long>> |
matchExecutorByNumberMap |
protected Map<org.kie.api.definition.rule.Rule,BiConsumer<org.kie.api.runtime.rule.RuleContext,BendableLongScore>> |
matchExecutorByScoreMap
Slower than
matchExecutorByNumberMap |
constraintMatchEnabled, constraintMatchTotalMap, indictmentMap, zeroScore| Constructor and Description |
|---|
BendableLongScoreHolder(boolean constraintMatchEnabled,
int hardLevelsSize,
int softLevelsSize) |
| Modifier and Type | Method and Description |
|---|---|
void |
addHardConstraintMatch(org.kie.api.runtime.rule.RuleContext kcontext,
int hardLevel,
long weight) |
void |
addMultiConstraintMatch(org.kie.api.runtime.rule.RuleContext kcontext,
long[] hardWeights,
long[] softWeights) |
void |
addSoftConstraintMatch(org.kie.api.runtime.rule.RuleContext kcontext,
int softLevel,
long weight) |
void |
configureConstraintWeight(org.kie.api.definition.rule.Rule rule,
BendableLongScore constraintWeight)
Sets up a
ConstraintWeight from the ConstraintConfiguration during initialization. |
BendableLongScore |
extractScore(int initScore)
|
int |
getHardLevelsSize() |
long |
getHardScore(int hardLevel) |
int |
getSoftLevelsSize() |
long |
getSoftScore(int softLevel) |
void |
penalize(org.kie.api.runtime.rule.RuleContext kcontext)
Penalize a match by the
ConstraintWeight negated. |
void |
penalize(org.kie.api.runtime.rule.RuleContext kcontext,
long weightMultiplier)
Penalize a match by the
ConstraintWeight negated and multiplied with the weightMultiplier for all score levels. |
void |
penalize(org.kie.api.runtime.rule.RuleContext kcontext,
long[] hardWeightsMultiplier,
long[] softWeightsMultiplier)
Penalize a match by the
ConstraintWeight negated and multiplied with the specific weightMultiplier per score level. |
void |
reward(org.kie.api.runtime.rule.RuleContext kcontext)
Reward a match by the
ConstraintWeight. |
void |
reward(org.kie.api.runtime.rule.RuleContext kcontext,
long weightMultiplier)
Reward a match by the
ConstraintWeight multiplied with the weightMultiplier for all score levels. |
void |
reward(org.kie.api.runtime.rule.RuleContext kcontext,
long[] hardWeightsMultiplier,
long[] softWeightsMultiplier)
Reward a match by the
ConstraintWeight multiplied with the specific weightMultiplier per score level. |
extractJustificationList, getConstraintMatchTotals, getIndictmentMap, isConstraintMatchEnabled, registerConstraintMatchprotected final Map<org.kie.api.definition.rule.Rule,BiConsumer<org.kie.api.runtime.rule.RuleContext,Long>> matchExecutorByNumberMap
protected final Map<org.kie.api.definition.rule.Rule,BiConsumer<org.kie.api.runtime.rule.RuleContext,BendableLongScore>> matchExecutorByScoreMap
matchExecutorByNumberMappublic BendableLongScoreHolder(boolean constraintMatchEnabled,
int hardLevelsSize,
int softLevelsSize)
public int getHardLevelsSize()
public long getHardScore(int hardLevel)
public int getSoftLevelsSize()
public long getSoftScore(int softLevel)
public void configureConstraintWeight(org.kie.api.definition.rule.Rule rule,
BendableLongScore constraintWeight)
ScoreHolderConstraintWeight from the ConstraintConfiguration during initialization.configureConstraintWeight in interface ScoreHolder<BendableLongScore>configureConstraintWeight in class AbstractScoreHolder<BendableLongScore>rule - never nullconstraintWeight - never null, with Score.getInitScore() equal to 0.public void penalize(org.kie.api.runtime.rule.RuleContext kcontext)
ConstraintWeight negated.kcontext - never null, the magic variable in DRLpublic void penalize(org.kie.api.runtime.rule.RuleContext kcontext,
long weightMultiplier)
ConstraintWeight negated and multiplied with the weightMultiplier for all score levels.kcontext - never null, the magic variable in DRLweightMultiplier - at least 0public void penalize(org.kie.api.runtime.rule.RuleContext kcontext,
long[] hardWeightsMultiplier,
long[] softWeightsMultiplier)
ConstraintWeight negated and multiplied with the specific weightMultiplier per score level.
Slower than penalize(RuleContext, long).kcontext - never null, the magic variable in DRLhardWeightsMultiplier - elements at least 0softWeightsMultiplier - elements at least 0public void reward(org.kie.api.runtime.rule.RuleContext kcontext)
ConstraintWeight.kcontext - never null, the magic variable in DRLpublic void reward(org.kie.api.runtime.rule.RuleContext kcontext,
long weightMultiplier)
ConstraintWeight multiplied with the weightMultiplier for all score levels.kcontext - never null, the magic variable in DRLweightMultiplier - at least 0public void reward(org.kie.api.runtime.rule.RuleContext kcontext,
long[] hardWeightsMultiplier,
long[] softWeightsMultiplier)
ConstraintWeight multiplied with the specific weightMultiplier per score level.
Slower than reward(RuleContext, long).kcontext - never null, the magic variable in DRLhardWeightsMultiplier - elements at least 0softWeightsMultiplier - elements at least 0public void addHardConstraintMatch(org.kie.api.runtime.rule.RuleContext kcontext,
int hardLevel,
long weight)
kcontext - never null, the magic variable in DRLhardLevel - 0 <= hardLevel < getHardLevelsSize().
The scoreLevel is hardLevel for hard levels and softLevel + hardLevelSize for soft levels.weight - higher is better, negative for a penalty, positive for a rewardpublic void addSoftConstraintMatch(org.kie.api.runtime.rule.RuleContext kcontext,
int softLevel,
long weight)
kcontext - never null, the magic variable in DRLsoftLevel - 0 <= softLevel < getSoftLevelsSize().
The scoreLevel is hardLevel for hard levels and softLevel + hardLevelSize for soft levels.weight - higher is better, negative for a penalty, positive for a rewardpublic void addMultiConstraintMatch(org.kie.api.runtime.rule.RuleContext kcontext,
long[] hardWeights,
long[] softWeights)
kcontext - never null, the magic variable in DRLhardWeights - never null, array of length getHardLevelsSize()softWeights - never null, array of length getSoftLevelsSize()public BendableLongScore extractScore(int initScore)
ScoreHolderScore, calculated by the KieSession for DroolsScoreDirector.
Should not be called directly, use ScoreDirector.calculateScore() instead.
initScore - <= 0, managed by OptaPlanner, needed as a parameter in the Score's creation
method, see Score.getInitScore()Score of the working PlanningSolutionCopyright © 2006–2018 JBoss by Red Hat. All rights reserved.