Members

Using Two Constraint Files In a Single Service of OptaPlanner

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 solverManager;

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

@Autowired private ScoreManager 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 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

https://erpsolutions.oodles.io/developer-blogs/Using-Two-Constraint...

#erp #erpsystem #optaplanner

Views: 2

Comment

You need to be a member of On Feet Nation to add comments!

Join On Feet Nation

© 2024   Created by PH the vintage.   Powered by

Badges  |  Report an Issue  |  Terms of Service