OptaPlanner计划实体,即使没有可用的移动

时间:2017-03-14 18:30:50

标签: java optaplanner

我正在尝试使用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.

我认为进一步证明没有动作可供选择。

计划实体与患者入院计划示例中的计划实体基本相同:

@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;
}

我也尝试过只使用一个返回空MoveList的MoveListFactory。但是仍有某些动作像这样

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)})

在构造启发阶段被选中。

1 个答案:

答案 0 :(得分:1)

您错过了 <xsl:for-each select="form/fieldset/group/section/field/options/item"> <option value="{@score}"> <xsl:value-of select="." /> </option> </xsl:for-each>

中的movableEntitySelectionFilter属性
@PlanningEntity