optaplanner 找不到带注释的规划变量

optaplanner can't find annotated planning varible

我想在求解器求解我的入院方案时删除或添加一些 ProblemFacts。

在 optaplanner 的文档中,我可以添加大约 solver.addProblemFactChange 一些 ProblemFacs,但它在我的 PAS 示例中不起作用。

这是我的 PatientAdmissionScheduleGenerator 代码片段

public void addBedDesignation(final BedDesignation bedDesignation){
    this.solver.addProblemFactChange(scoreDirector -> {
        PatientAdmissionScheduleSolution patientAdmissionScheduleSolution = scoreDirector.getWorkingSolution();
        patientAdmissionScheduleSolution.getBedDesignationList().add(bedDesignation);
    });
}

public void deleteBedDesignation(final BedDesignation bedDesignation){
    // Neues Problem dem Solver zuführen
    this.solver.addProblemFactChange(scoreDirector -> {

        // Erstelle eine neue PAS-Solution auf Basis der gerade läuft
        PatientAdmissionScheduleSolution patientAdmissionScheduleSolution  = scoreDirector.getWorkingSolution();

        // Erstelle eine neue Bettzuweisung auf Basis der
        BedDesignation workingBedDesignation = scoreDirector.lookUpWorkingObject(bedDesignation);

       for(BedDesignation designation : patientAdmissionScheduleSolution.getBedDesignationList()){
           if(designation.equals(bedDesignation)){
               scoreDirector.beforeVariableChanged(designation, "Bed");
               designation = null;
               scoreDirector.afterVariableChanged(designation,"Bed");
           }
       }

       ArrayList<BedDesignation> bedDesignationArrayList = new ArrayList<>(patientAdmissionScheduleSolution.getBedDesignationList());
       patientAdmissionScheduleSolution.setBedDesignationList(bedDesignationArrayList);
       scoreDirector.beforeProblemFactRemoved(workingBedDesignation);
       bedDesignationArrayList.remove(workingBedDesignation);
       scoreDirector.afterProblemFactRemoved(workingBedDesignation);
       scoreDirector.triggerVariableListeners();
    });
}

这是我更改后的 Object BedDesignation 的片段

@PlanningVariable(nullable = true, valueRangeProviderRefs = {"bedRange"}, strengthComparatorClass = BedStrengthComparator.class)
    public Bed getBed() {
        return bed;
    }

这是我想删除 BedDesignation 对象时的错误消息

Exception in thread "main" java.lang.IllegalArgumentException: The variableName (Bed) for entityClass (class pas.entity.domain.BedDesignation) exists as a property (getter/setter) on that class, but not as an annotated as a planning variable.

检查您的规划实体的 getter 是否有注释 PlanningVariable(或影子变量注释)。

我已将 bed 注释为 PlanningVariable。怎么了?

错误信息归咎于错误的原因。 I created a jira.

使用 "bed" 代替 "Bed"。