OptaPlanner 计划实体,即使没有可用的移动
OptaPlanner plans entities even though there are no moves available
我正在尝试使用 MoveSelectionFilter 从计划中排除一些计划实体实例。
然而,根据调试输出,即使我拒绝 所有 步,这些实例仍然在构建启发式阶段得到初始计划。我正在使用 WEAKEST_FIT 启发式方法,两个自定义 MoveListFactories(目前根本不生成任何移动)并且没有默认 MoveListFactory。
如何防止 OptaPlanner 规划这些实体?我查看了护士排班示例,如果您提前日期但无法重现该行为,它完全符合我的要求。
编辑:确实应用了过滤器。我检查了 MoveLists 的大小,它们都是空的。
我的过滤器看起来像这样:
public boolean accept(PatientAdmissionSchedule patientAdmissionSchedule, BedDesignation bedDesignation) {
return false;
}
并像这样应用:
if (filter.accept(patientAdmissionSchedule, bedDesignation)) {
for (Bed bed : bedList) {
moveList.add(new BedChangeMove(bedDesignation, bed));
}
}
和
for (ListIterator<BedDesignation> it = bedDesignationList.listIterator(); it.hasNext();) {
BedDesignation bedDesignation = it.next();
if (!filter.accept(patientAdmissionSchedule, bedDesignation)) {
it.remove();
}
}
在调试中,我有以下几行
2017-03-14 19:40:59,305 [SwingWorker-pool-4-thread-1] DEBUG CH step (31), time spent (173), score (0hard/0medium/0soft), selected move count (7), picked move (Patient6(Night(7),null) {null -> 15(0)}).
2017-03-14 19:40:59,306 [SwingWorker-pool-4-thread-1] INFO Construction Heuristic phase (0) ended: step total (32), time spent (174), best score (0hard/0medium/0soft).
2017-03-14 19:40:59,313 [SwingWorker-pool-4-thread-1] WARN No doable selected move at step index (0), time spent (181). Terminating phase early.
我认为这进一步表明 select.
没有任何变化
计划实体与患者入院计划示例中的实体基本相同:
@PlanningEntity(difficultyWeightFactoryClass = BedDesignationDifficultyWeightFactory.class)
@XStreamAlias("BedDesignation")
public class BedDesignation extends AbstractPersistable {
private Admission admission;
private Bed bed;
private Night night;
@PlanningVariable(nullable = true, valueRangeProviderRefs = {"bedRange"},
strengthComparatorClass = BedStrengthComparator.class)
public Bed getBed() {
return bed;
}
我也试过只使用一个 MoveListFactory,returns 一个空的 MoveList。但是还是有这样的动作
2017-03-14 19:40:59,305 [SwingWorker-pool-4-thread-1] DEBUG CH step (31), time spent (173), score (0hard/0medium/0soft), selected move count (7), picked move (Patient6(Night(7),null) {null -> 15(0)})
在构建启发式阶段被选中。
您在 @PlanningEntity
中缺少 movableEntitySelectionFilter
属性
@PlanningEntity(movableEntitySelectionFilter = MovableLectureSelectionFilter.class, ...)
public class Lecture ...
我正在尝试使用 MoveSelectionFilter 从计划中排除一些计划实体实例。
然而,根据调试输出,即使我拒绝 所有 步,这些实例仍然在构建启发式阶段得到初始计划。我正在使用 WEAKEST_FIT 启发式方法,两个自定义 MoveListFactories(目前根本不生成任何移动)并且没有默认 MoveListFactory。
如何防止 OptaPlanner 规划这些实体?我查看了护士排班示例,如果您提前日期但无法重现该行为,它完全符合我的要求。
编辑:确实应用了过滤器。我检查了 MoveLists 的大小,它们都是空的。
我的过滤器看起来像这样:
public boolean accept(PatientAdmissionSchedule patientAdmissionSchedule, BedDesignation bedDesignation) {
return false;
}
并像这样应用:
if (filter.accept(patientAdmissionSchedule, bedDesignation)) {
for (Bed bed : bedList) {
moveList.add(new BedChangeMove(bedDesignation, bed));
}
}
和
for (ListIterator<BedDesignation> it = bedDesignationList.listIterator(); it.hasNext();) {
BedDesignation bedDesignation = it.next();
if (!filter.accept(patientAdmissionSchedule, bedDesignation)) {
it.remove();
}
}
在调试中,我有以下几行
2017-03-14 19:40:59,305 [SwingWorker-pool-4-thread-1] DEBUG CH step (31), time spent (173), score (0hard/0medium/0soft), selected move count (7), picked move (Patient6(Night(7),null) {null -> 15(0)}).
2017-03-14 19:40:59,306 [SwingWorker-pool-4-thread-1] INFO Construction Heuristic phase (0) ended: step total (32), time spent (174), best score (0hard/0medium/0soft).
2017-03-14 19:40:59,313 [SwingWorker-pool-4-thread-1] WARN No doable selected move at step index (0), time spent (181). Terminating phase early.
我认为这进一步表明 select.
没有任何变化计划实体与患者入院计划示例中的实体基本相同:
@PlanningEntity(difficultyWeightFactoryClass = BedDesignationDifficultyWeightFactory.class)
@XStreamAlias("BedDesignation")
public class BedDesignation extends AbstractPersistable {
private Admission admission;
private Bed bed;
private Night night;
@PlanningVariable(nullable = true, valueRangeProviderRefs = {"bedRange"},
strengthComparatorClass = BedStrengthComparator.class)
public Bed getBed() {
return bed;
}
我也试过只使用一个 MoveListFactory,returns 一个空的 MoveList。但是还是有这样的动作
2017-03-14 19:40:59,305 [SwingWorker-pool-4-thread-1] DEBUG CH step (31), time spent (173), score (0hard/0medium/0soft), selected move count (7), picked move (Patient6(Night(7),null) {null -> 15(0)})
在构建启发式阶段被选中。
您在 @PlanningEntity
movableEntitySelectionFilter
属性
@PlanningEntity(movableEntitySelectionFilter = MovableLectureSelectionFilter.class, ...)
public class Lecture ...