From 39751c8c5aeb3ac5fae4dad7ce4683a030a38e51 Mon Sep 17 00:00:00 2001 From: oblonski Date: Wed, 19 Apr 2017 14:10:10 +0200 Subject: [PATCH] add location info for scheduling breaks with route builder --- .../problem/solution/route/VehicleRoute.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/VehicleRoute.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/VehicleRoute.java index c04d1ee1..7dd0c17d 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/VehicleRoute.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/VehicleRoute.java @@ -19,6 +19,7 @@ package com.graphhopper.jsprit.core.problem.solution.route; import com.graphhopper.jsprit.core.problem.AbstractActivity; import com.graphhopper.jsprit.core.problem.JobActivityFactory; +import com.graphhopper.jsprit.core.problem.Location; import com.graphhopper.jsprit.core.problem.driver.Driver; import com.graphhopper.jsprit.core.problem.driver.DriverImpl; import com.graphhopper.jsprit.core.problem.job.*; @@ -196,16 +197,33 @@ public class VehicleRoute { return this; } + @Deprecated public Builder addBreak(Break currentbreak) { if (currentbreak == null) throw new IllegalArgumentException("break must not be null"); return addBreak(currentbreak, currentbreak.getTimeWindow()); } + @Deprecated public Builder addBreak(Break currentbreak, TimeWindow timeWindow) { if (currentbreak == null) throw new IllegalArgumentException("break must not be null"); return addService(currentbreak,timeWindow); } + public Builder addBreak(Break currentbreak, TimeWindow timeWindow, Location location) { + if (currentbreak == null) throw new IllegalArgumentException("break must not be null"); + return addBreakInternally(currentbreak, timeWindow, location); + } + + private Builder addBreakInternally(Break currentBreak, TimeWindow timeWindow, Location breakLocation) { + List acts = jobActivityFactory.createActivities(currentBreak); + BreakActivity act = (BreakActivity) acts.get(0); + act.setTheoreticalEarliestOperationStartTime(timeWindow.getStart()); + act.setTheoreticalLatestOperationStartTime(timeWindow.getEnd()); + act.setLocation(breakLocation); + tourActivities.addActivity(act); + return this; + } + /** * Adds a pickup to this route. *