Drools Planner在运行时设置了minimalAcceptedSelection

时间:2012-07-30 14:11:58

标签: java drools drools-planner optaplanner

我可以设置minimalAcceptedSelection编辑SampleDroolsConfig.xml

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

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

1 个答案:

答案 0 :(得分:1)

是:

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

请参阅Drools Planner手册部分,了解有关按Java(而非XML)配置的信息。