LocalSearchSolverPhaseConfig

LocalSearchSolverPhaseConfig

我可以设置minimumAcceptedSelection编辑SampleDroolsConfig.xml

        ...
        <acceptor>
            <solutionTabuSize>1000</solutionTabuSize>
            <planningEntityTabuSize>7</planningEntityTabuSize>
        </acceptor>
        <forager>
            <minimalAcceptedSelection>200</minimalAcceptedSelection>
        </forager>
    </localSearch>
</solver>


是否可以在运行时设置此参数?

最佳答案

是:

XmlSolverFactory solverFactory = new XmlSolverFactory(SOLVER_CONFIG);
LocalSearchSolverPhaseConfig localSearchSolverPhaseConfig = (LocalSearchSolverPhaseConfig) solverFactory.getSolverConfig().getSolverPhaseConfigList().get(1);
localSearchSolverPhaseConfig.getForagerConfig().setMinimalAcceptedSelection(200);


有关通过Java(而不是XML)进行配置的信息,请参见Drools Planner手册部分。

10-06 12:51