Created
November 27, 2024 14:57
-
-
Save TomCools/4c6551647c936ffa424ad5cf2f04eecf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class SantaResource { | |
| private final SolverFactory<SantaPlan> solverFactory; | |
| // CDI Injected solverFactory | |
| public SantaResource(SolverFactory<SantaPlan> solverFactory) { | |
| this.solverFactory = solverFactory; | |
| } | |
| /** | |
| * Uses a solver to optimally sort a list of visits | |
| * @param visits the locations santa needs to visit | |
| * @return an optimized plan | |
| */ | |
| public SantaPlan solve(List<Visit> visits) { | |
| // This is the location of Santa's village in Rovaniemi, Finland | |
| Santa santa = new Santa(new Location(66.5039, 25.7294)); | |
| SantaPlan santaPlan = new SantaPlan(santa, visits); | |
| Solver<SantaPlan> solver = solverFactory.buildSolver(); | |
| return solver.solve(santaPlan); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment