自定义阶段未添加到phaseConfigList

时间:2017-10-05 00:48:47

标签: xml optaplanner

我正在尝试制作自定义构建启发式阶段。阶段配置扩展了AbstractPhaseConfig,XStream无法弄清楚它应该被添加到phaseConfigList中。它试图将类分配给它自己的类变量。 LocalSearchPhaseConfig非常有效。

XML

        con.Open();
        int parsedValue;
        if (!int.TryParse(txtCCL.Text||txtA.text||txtB.text, out parsedValue))
        {
            MessageBox.Show("This is a number only field");
            return;
        }
        else
        {
        }

我的班级

<solver>
    <customConstructionHeuristic></customConstructionHeuristic>
    <localSearch></localSearch>
</solver>

}

Optaplanner的本地搜索阶段课程

@XStreamAlias("customConstructionHeuristic")
public class CustomConstructionHeuristicPhaseConfig extends PhaseConfig<CustomConstructionHeuristicPhaseConfig> {
    @Override
    public ConstructionHeuristicPhase buildPhase(int phaseIndex, HeuristicConfigPolicy solverConfigPolicy, BestSolutionRecaller 
            bestSolutionRecaller, Termination solverTermination) {
        return null;
}

1 个答案:

答案 0 :(得分:0)

如果您的业务重点是:

为什么不使用自定义阶段

  <customPhase>
    <customPhaseCommandClass>org.optaplanner.examples.machinereassignment.solver.solution.initializer.ToOriginalMachineSolutionInitializer</customPhaseCommandClass>
  </customPhase>
  <localSearch/>

升级到新版本时,这不会让您遇到麻烦,可能会延长AbstractPhaseConfig

如果你以学术为重点:

是的,破解它。这很好。考虑稍后再贡献:)调用此方法,以便XStream识别您的CustomConstructionHeuristicPhaseConfig类:

XStreamXmlSolverFactory.addXStreamAnnotations(CustomConstructionHeuristicPhaseConfig.class);