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
// Prepare a custom icon, since default one is not "Christmas" enough. | |
const treeIcon = L.icon({iconUrl: 'tree-marker.png', iconSize: [20, 20]}) | |
const map = L.map('map', {doubleClickZoom: false}).setView([66.5039, 25.7294], 4); | |
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { | |
attribution: '© <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors', | |
}).addTo(map); | |
// Create a layer group, | |
const linesGroup = L.layerGroup().addTo(map); |
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
@Path("santa") | |
public class SantaResource { | |
// Fields and constructor excluded | |
@POST | |
@Path("plan") | |
@Consumes(MediaType.APPLICATION_JSON) | |
@Produces(MediaType.APPLICATION_JSON) | |
public SantaPlan solve(List<Visit> visits) { |
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; | |
} | |
/** |
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
@PlanningSolution | |
public class SantaPlan { | |
@PlanningEntityProperty | |
private Santa santa; | |
@ProblemFactCollectionProperty | |
@ValueRangeProvider | |
private List<Visit> visits; | |
@PlanningScore |
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 SantaConstraintProvider implements ConstraintProvider { | |
// NOTE: Normally you'd want to calculate a Distance Matrix before starting the solver. | |
DrivingTimeCalculator drivingTimeCalculator = DrivingTimeCalculator.getInstance(); | |
public static final String MINIMIZE_TRAVEL_TIME = "minimizeTravelTime"; | |
@Override | |
public Constraint[] defineConstraints(ConstraintFactory factory) { | |
return new Constraint[]{ | |
minimizeTravelTime(factory) |
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
@PlanningEntity | |
public class Santa { | |
private Location homeLocation; | |
@PlanningListVariable | |
private List<Visit> visits; | |
// excluded constructor getter/setter | |
} |