计划变量不可为空。当我在变量监听器中为我的阴影值打印出计划实体时,仍然在计划过程中NULL值仍然分配给计划变量??
规划实体:
// Planning variables: changes during planning, between score calculations.
@PlanningVariable(valueRangeProviderRefs = {"numberRange"})
private Integer number;
@ValueRangeProvider(id = "numberRange")
private List<Integer> numberRange;
@CustomShadowVariable(variableListenerClass = BoxUpdatingVariableListener.class,
sources = {@PlanningVariableReference(variableName = "number")})
private Integer shaodowNumber;
变量监听器:
protected void updateShadowNumber(ScoreDirector scoreDirector, Box sourceBox) {
System.out.println("number:"+sourceBox.getNumber());
}
部分结果:
02:24:46.832 [main ] INFO Solving started: time spent (74), best score (-3init/-90), environment mode (FULL_ASSERT), random (JDK with seed 0).
number:1
number:null
number:2
number:null
number:3
number:null
number:4
number:null
number:5
number:null
number:6
number:null
number:7
number:null
number:7
number:7
number:null
number:null
02:24:46.883 [main ] DEBUG CH step (0), time spent (125), score (-2init/-43), selected move count (7), picked move (Box-1 {null -> 7}).
number:1
number:null
number:2
number:null
number:3
number:null
number:4
number:null
number:5
number:null
number:6
number:null
number:6
number:7
number:6
number:null
这通常是不运行施工阶段的结果
比如这样
<constructionHeuristic>
<constructionHeuristicType>STRONGEST_FIT_DECREASING</constructionHeuristicType>
</constructionHeuristic>