Score calculation
地址: https://docs.optaplanner.org/7.45.0.Final/optaplanner-docs/html_single/index.html#scoreCalculation
5.1.1 评分术语
在OptaPlanner中定义约束非常灵活:
- 分数符号(正或负):最大化或最小化一个约束类型
- 得分权重:优先级一致时,例如将成本/利润放在约束类型上,用于维持公平性
- 分数级别(硬、软…):对一组约束类型进行优先级排序
- 帕累托评分法(很少使用)
5.1.3. Score constraint signum (positive or negative)
最大化或最小化一个约束类型,如下图:
5.1.4. Score constraint weight
得分权重适用于优先级一致的情况下,进行取舍或者组合取舍,为了达到维持总体收益或者公平性
5.1.5. Score constraint level (hard, soft, …)
- 硬约束不能够打破,一旦打破,会出错
- 软约束会尽量降低
5.1.6. Pareto scoring (AKA multi-objective optimization scoring)
看图,多物体优化分数:
5.1.7. Combining score techniques
5.1.8. Score interface
A score is represented by the Score interface, which naturally extends Comparable:
public interface Score<...> extends Comparable<...> {
...
}
上述所有评分技术可以无缝结合:
Score类图如下:
(不建议使用浮点数, 使用BigDecimal or scaled long来替换)
5.2.5. Implementing a custom score
支持自定义评分规则
5.5. Constraint configuration: adjust constraint weights dynamically
原文: 自己造个UI界面,可视化的方式去调整系数,****~~
5.6. Explaining the score: which constraints are broken?
使用:
@Autowired
private ScoreManager<TimeTable> scoreManager;
---
System.out.println(scoreManager.explainScore(solution));
显示示例如下:
Explanation of score (-1hard/-806soft):
Constraint match totals:
-1hard: constraint (Speaker required room tag) has 1 matches:
-1hard: justifications ([S51])
-340soft: constraint (Theme track conflict) has 32 matches:
-20soft: justifications ([S68, S66])
-20soft: justifications ([S61, S44])
...