我试图在示例中实现像NurseRostering之类的东西,所以我做了所有相同的事情,除了“/ / drools& move' (也有人可以解释他们到底做了什么吗?)。
所以,我的问题是,我实现了Comparators:EmployeeStrengthComparator和JobDifficultyComparator,它们就像NurseRostering示例中的EmployeeStrengthComparator和ShiftAssignmentDifficultyComparator。
所以我设置了我的规则,我的解决方案,并开始解决,但我得到了这个错误:
Exception in thread "main" java.lang.ClassCastException: org.demo.DemoApp.domain.JobAssignment cannot be cast to org.demo.DemoApp.domain.Employee
at org.demo.DemoApp.domain.solver.EmployeeStrengthComparator.compare(EmployeeStrengthComparator.java:12)
at java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
at java.util.TimSort.sort(TimSort.java:220)
at java.util.Arrays.sort(Arrays.java:1512)
at java.util.ArrayList.sort(ArrayList.java:1454)
at java.util.Collections.sort(Collections.java:175)
at org.optaplanner.core.impl.heuristic.selector.common.decorator.ComparatorSelectionSorter.sort(ComparatorSelectionSorter.java:45)
at org.optaplanner.core.impl.heuristic.selector.value.decorator.SortingValueSelector.constructCache(SortingValueSelector.java:43)
at org.optaplanner.core.impl.heuristic.selector.common.SelectionCacheLifecycleBridge.phaseStarted(SelectionCacheLifecycleBridge.java:49)
at org.optaplanner.core.impl.phase.event.PhaseLifecycleSupport.firePhaseStarted(PhaseLifecycleSupport.java:39)
我希望有人知道我哪里出错的原因,可以提供更多信息\来源当然,但我想原因很明显,因为我对这个框架很新,可能会错过配置可能是。
UPD: 所以它就像:
@PlanningEntityCollectionProperty
@ValueRangeProvider(id = "employeeRange")
public List<JobAssignment> getJobAssignments() {
return jobAssignments;
}
答案 0 :(得分:0)
哦,好吧......我不小心将属性ValueRangeProvider
添加到计划实体JobAssignment,当它应该放在Employee上时,现在没关系
<强> UPD:强>
它应该是这样的:
@ValueRangeProvider(id = "employeeRange")
public List<Employee> getEmployees() {
return employees;
}
@PlanningEntityCollectionProperty
public List<VisitAssignment> getVisitAssignments() {
return visitAssignments;
}