0

I am trying to implement a partition search for my problem. I managed to define and implement the SolutionPartitioner interface and the splitWorkingSolution method. From what I understand, the partitioned search phase has to be followed by a local search phase. What I'd like to achieve is doing so within my Java code without relying to the xml configuration file.

Right now I managed to implement my simple local search this way:

SolverJob<TimeTable, Long> solverJob = solverManager.solve( new Random().nextLong(), problem );
TimeTable solution;
solution = solverJob.getFinalBestSolution();

Where problem is a TimeTable containing my starting data. In order to solve my problem by partitioning, should I call the solver job on each of my TimeTable's partitions? And if so, how do I combine the partial solutions? How do I run the final local search?

1 Answers1

0

The arguably better (and much less time consuming) way is to build the equivalent solver config with the programmatic API.

SolverConfig solverConfig = new SolverConfig()
    with...()
    ...;
SolverFactory<...> solverFactory = SolverFactory.create(solverConfig);
Solver<...> solver = solverFactory.buildSolver();

You should explore the SolverConfig fluent API. When you do, you will find out that it does allow you to replicate the entire solver config XML structure from your code. In fact, it is the other way around - the XML gets serialized into an instance of the SolverConfig class.

Lukáš Petrovický
  • 3,945
  • 1
  • 11
  • 20
  • One thing we don't support yet is manipulating the SolverConfig by Java API yet in a Quarkus or Spring Boot app. Both platforms have a standard way of doing that already, for example for Hibernate's EntityManagerConfiguration IIRC through a consumer interface that takes the Quarkus/spring generated solver config (including entity classes already set etc) and adjusts it. – Geoffrey De Smet Nov 08 '21 at 06:29