Using Two Constraint Files In a Single Service of OptaPlanner

ERP Solutions oodles
1 min readApr 21, 2023

--

In this blog post, we shall see how we can use two constraint files in OptaPlanner 8 or OptaPlanner 9 beta version.

In OptaPlanner 8 version, we do not need to configure the XML file when we use the single constraint file. We can use the following steps to use auto config :-

1:- first you need to inject the following code in your service section to find the solution of your code.

@Autowired private SolverManager<PlanningSolutionClassName, UUID> solverManager;

2: then you need to inject the following code in your service section to find the score of your solution.

@Autowired private ScoreManager<OptForeCastingSolution, HardSoftScore> scoreManager;

2:- After these, two injections, you need to add the following code to solve the problem and find the score.

UUID problemId = UUID.randomUUID();

// Submit the problem to start solving

SolverJob<SolutionClassName , UUID> solverJob = solverManager.solve( problemId, SolutionClassName ); SolutionClassName solutionClassName; try { // Wait until the solving ends solution = solverJob.getFinalBestSolution(); } catch (InterruptedException | ExecutionException e) { throw new IllegalStateException(“Solving failed.”, e); }

For more, visit this link

#erp #optaplanner #optaplannerapplication #optaplannersoftware

--

--

ERP Solutions oodles
ERP Solutions oodles

Written by ERP Solutions oodles

We are a leading ERP development company in India offers a wide range of ERP software development services to help you grow your business exponentially.

No responses yet