Skip to content
Advertisement

Optaplanner and Quarkus solver config update

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 !

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement