From 933e2ca120f2b9fbb2e02318ce33fe90b192add1 Mon Sep 17 00:00:00 2001 From: oblonski Date: Wed, 19 Apr 2017 14:04:19 +0200 Subject: [PATCH] add location info for scheduling breaks with route builder --- .../problem/solution/route/VehicleRoute.java | 20 +++++++++++++++++++ 1 file changed, 20 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..a04a58b2 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.*; @@ -186,6 +187,16 @@ public class VehicleRoute { return addService(service,service.getTimeWindow()); } + 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; + } + public Builder addService(Service service, TimeWindow timeWindow) { if (service == null) throw new IllegalArgumentException("service must not be null"); List acts = jobActivityFactory.createActivities(service); @@ -196,16 +207,25 @@ 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 breakLocation) { + if (currentBreak == null) throw new IllegalArgumentException("break must not be null"); + return addBreakInternally(currentBreak, timeWindow, breakLocation); + } + + + /** * Adds a pickup to this route. *