@ConstraintWeight("periodSpread") public HardSoftScore getPeriodSpreadPenaltyAsScore() { return HardSoftScore.ofSoft(periodSpreadPenalty); }
@ConstraintWeight("twoExamsInADay") public HardSoftScore getTwoInADayPenaltyAsScore() { return HardSoftScore.ofSoft(twoInADayPenalty); }
@ConstraintWeight("frontLoad") public HardSoftScore getFrontLoadPenaltyAsScore() { return HardSoftScore.ofSoft(frontLoadPenalty); }
@ConstraintWeight("twoExamsInARow") public HardSoftScore getTwoInARowPenaltyAsScore() { return HardSoftScore.ofSoft(twoInARowPenalty); }
@ConstraintWeight("mixedDurations") public HardSoftScore getMixedDurationPenaltyAsScore() { return HardSoftScore.ofSoft(mixedDurationPenalty); }
@Test public void of() { assertEquals(HardSoftScore.of(-147, 0), HardSoftScore.ofHard(-147)); assertEquals(HardSoftScore.of(0, -258), HardSoftScore.ofSoft(-258)); }
public void rewardPenalize(boolean constraintMatchEnabled) { HardSoftScoreHolder scoreHolder = new HardSoftScoreHolder(constraintMatchEnabled); Rule hard1 = mockRule("hard1"); scoreHolder.configureConstraintWeight(hard1, HardSoftScore.ofHard(10)); Rule hard2 = mockRule("hard2"); scoreHolder.configureConstraintWeight(hard2, HardSoftScore.ofHard(100)); Rule soft1 = mockRule("soft1"); scoreHolder.configureConstraintWeight(soft1, HardSoftScore.ofSoft(10)); Rule soft2 = mockRule("soft2"); scoreHolder.configureConstraintWeight(soft2, HardSoftScore.ofSoft(100)); scoreHolder.penalize(mockRuleContext(hard1)); assertEquals(HardSoftScore.of(-10, 0), scoreHolder.extractScore(0)); scoreHolder.penalize(mockRuleContext(hard2), 2); assertEquals(HardSoftScore.of(-210, 0), scoreHolder.extractScore(0)); scoreHolder.reward(mockRuleContext(soft1)); assertEquals(HardSoftScore.of(-210, 10), scoreHolder.extractScore(0)); scoreHolder.reward(mockRuleContext(soft2), 3); assertEquals(HardSoftScore.of(-210, 310), scoreHolder.extractScore(0)); }
@ConstraintWeight("mixedDurations") public HardSoftScore getMixedDurationPenaltyAsScore() { return HardSoftScore.ofSoft(mixedDurationPenalty); }
@ConstraintWeight("periodSpread") public HardSoftScore getPeriodSpreadPenaltyAsScore() { return HardSoftScore.ofSoft(periodSpreadPenalty); }
@ConstraintWeight("twoExamsInARow") public HardSoftScore getTwoInARowPenaltyAsScore() { return HardSoftScore.ofSoft(twoInARowPenalty); }
@ConstraintWeight("twoExamsInADay") public HardSoftScore getTwoInADayPenaltyAsScore() { return HardSoftScore.ofSoft(twoInADayPenalty); }
@ConstraintWeight("frontLoad") public HardSoftScore getFrontLoadPenaltyAsScore() { return HardSoftScore.ofSoft(frontLoadPenalty); }