英文:
Optaplanner and Quarkus solver config update
问题
我正在使用 Quarkus 和 OptaPlanner 进行一个项目,我正在尝试访问和修改求解器的配置,以添加启发式算法、更改搜索算法等等。
我正在使用 solverJob 和 solverManager,但是 Quarkus 似乎将求解器的配置隐藏起来了。我基本上在按照 Quarkus 教程的步骤进行操作(https://quarkus.io/guides/optaplanner)。
public PlannerSolution solve() {
UUID problemId = UUID.randomUUID();
SolverJob<PlannerSolution, UUID> solverJob;
solverJob = solverManager.solve(problemId, problem);
PlannerSolution solution;
try {
// 等待求解结束
System.out.println("等待中................");
solution = solverJob.getFinalBestSolution();
System.out.println("完成");
} catch (InterruptedException | ExecutionException e) {
throw new IllegalStateException("求解失败。", e);
}
return solution;
}
我还在使用 constraintProvider API。
是否有办法让我访问并修改 Quarkus 自动创建的这个配置?我尝试过使用 solverFactory 和 XML 配置文件的基本方式,但是 Quarkus 对此似乐见其成。
提前谢谢!
英文:
I'm working on a project with quarkus and optaplanner, and I'm trying to access and modify the configuration of the solver, to add heuristics, change search algorithm etc.
I'm using a solverJob and a solverManager, and quarkus seems to be hiding from me the configuration of the solver. I'm basically following the steps of the Quarkus tutorial (https://quarkus.io/guides/optaplanner).
public PlannerSolution solve() {
UUID problemId = UUID.randomUUID();
SolverJob<PlannerSolution, UUID> solverJob;
solverJob = solverManager.solve(problemId, problem);
PlannerSolution solution;
try {
// Wait until the solving ends
System.out.println("Waiting................");
solution = solverJob.getFinalBestSolution();
System.out.println("Done");
} catch (InterruptedException | ExecutionException e) {
throw new IllegalStateException("Solving failed.", e);
}
return solution;
}
I'm also using the constraintProvider API.
Is there a way for me to access and modify this config made automatically by quarkus ? I've tried the basic way with a solverFactory and xml conf file, but quarkus isn't happy about that at all.
Thank you in advance !
答案1
得分: 4
更改默认的求解器配置,请在项目的类路径上创建XML配置文件。optaplanner-quarkus扩展默认尝试读取solverConfig.xml
。在项目中,它应该位于:
.../src/main/resources/solverConfig.xml
配置文件的默认位置可以通过application.properties
中的属性quarkus.optaplanner.solver-config-xml
进行覆盖。
英文:
To change the default solver configuration, create the XML configuration file on the project's classpath. The optaplanner-quarkus extension tries to read the solverConfig.xml
by default. In the project, it should be located in:
.../src/main/resources/solverConfig.xml
The default location of the configuration file can be overridden by the property quarkus.optaplanner.solver-config-xml
in the application.properties
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论