Optaplanner 和 Quarkus 求解器配置更新 [英] Optaplanner and Quarkus solver config update
问题描述
我正在使用 quarkus 和 optaplanner 开展一个项目,我正在尝试访问和修改求解器的配置、添加启发式、更改搜索算法等.
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.
我使用的是solverJob 和solverManager,而quarkus 似乎对我隐藏了求解器的配置.我基本上遵循 Quarkus 教程的步骤(https://quarkus.io/guides/optaplanner).
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;
}
我也在使用constraintProvider API.有没有办法让我访问和修改由 quarkus 自动制作的这个配置?我已经尝试过使用 solverFactory 和 xml conf 文件的基本方法,但 quarkus 对此一点也不满意.
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.
先谢谢你!
推荐答案
要更改默认求解器配置,请在项目的类路径上创建 XML 配置文件.optaplanner-quarkus 扩展默认尝试读取 solverConfig.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
配置文件的默认位置可以被application.properties
中的属性quarkus.optaplanner.solver-config-xml
覆盖.
The default location of the configuration file can be overridden by the property quarkus.optaplanner.solver-config-xml
in the application.properties
.
这篇关于Optaplanner 和 Quarkus 求解器配置更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!