Skip to content

Instantly share code, notes, and snippets.

@TomCools
Created November 27, 2024 14:57
Show Gist options
  • Select an option

  • Save TomCools/4c6551647c936ffa424ad5cf2f04eecf to your computer and use it in GitHub Desktop.

Select an option

Save TomCools/4c6551647c936ffa424ad5cf2f04eecf to your computer and use it in GitHub Desktop.
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