From 2aea38e5723c2303ad1a92d6e7e1af0b62d84840 Mon Sep 17 00:00:00 2001 From: oblonski Date: Tue, 9 Feb 2016 10:19:35 +0100 Subject: [PATCH] remove deprecated code --- .../toolbox/AlgorithmEventsRecorder.java | 6 -- .../analysis/toolbox/GraphStreamViewer.java | 5 -- .../jsprit/analysis/toolbox/Plotter.java | 19 +++-- .../jsprit/core/algorithm/SearchStrategy.java | 5 -- .../core/algorithm/SearchStrategyManager.java | 12 --- .../acceptor/AcceptNewRemoveFirst.java | 21 +---- .../GreedyAcceptance_minVehFirst.java | 70 ---------------- .../core/algorithm/io/InsertionFactory.java | 5 -- .../io/VehicleRoutingAlgorithms.java | 5 -- .../recreate/BestInsertionBuilder.java | 11 --- .../recreate/BestInsertionConcurrent.java | 10 +-- .../algorithm/recreate/InsertionBuilder.java | 12 --- .../algorithm/ruin/AbstractRuinStrategy.java | 13 --- .../core/algorithm/ruin/RuinClusters.java | 8 -- .../core/algorithm/ruin/RuinRadial.java | 5 +- .../ruin/RuinRadialMultipleCenters.java | 11 +-- .../core/algorithm/ruin/RuinRandom.java | 8 -- .../core/algorithm/ruin/RuinStrategy.java | 6 -- .../jsprit/core/algorithm/ruin/RuinWorst.java | 8 -- .../core/algorithm/state/StateManager.java | 4 - .../core/analysis/SolutionAnalyser.java | 43 +++------- .../core/problem/VehicleRoutingProblem.java | 18 +---- .../jsprit/core/problem/io/VrpXMLReader.java | 22 ----- .../problem/solution/route/VehicleRoute.java | 41 ---------- .../route/activity/BreakActivity.java | 5 -- .../route/activity/DeliverService.java | 7 +- .../route/activity/DeliverShipment.java | 10 +-- .../problem/solution/route/activity/End.java | 29 ------- .../route/activity/PickupService.java | 7 +- .../route/activity/PickupShipment.java | 10 +-- .../route/activity/ServiceActivity.java | 12 +-- .../solution/route/activity/Start.java | 26 +----- .../route/activity/TourActivities.java | 11 --- .../solution/route/activity/TourActivity.java | 9 --- .../jsprit/core/util/CalculationUtils.java | 1 + .../jsprit/core/util/GreatCircleCosts.java | 35 +------- .../VehicleRoutingAlgorithmTest.java | 10 +-- .../algorithm/io/TestAlgorithmReader.java | 5 -- .../core/analysis/SolutionAnalyserTest.java | 8 +- .../problem/VehicleRoutingProblemTest.java | 11 ++- .../route/VehicleRouteBuilderTest.java | 26 +----- .../solution/route/activity/EndTest.java | 6 -- .../solution/route/activity/StartTest.java | 7 -- .../route/activity/TestTourActivities.java | 27 +++---- .../test/resources/infiniteWriterV2Test.xml | 81 +++++++------------ .../jsprit/examples/BreakExample.java | 1 + .../examples/BuildAlgorithmFromScratch.java | 3 +- .../examples/PickupAndDeliveryExample.java | 3 +- .../examples/VRPWithBackhaulsExample2.java | 3 +- .../jsprit/instance/reader/CordeauReader.java | 6 -- 50 files changed, 109 insertions(+), 618 deletions(-) delete mode 100644 jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/acceptor/GreedyAcceptance_minVehFirst.java diff --git a/jsprit-analysis/src/main/java/com/graphhopper/jsprit/analysis/toolbox/AlgorithmEventsRecorder.java b/jsprit-analysis/src/main/java/com/graphhopper/jsprit/analysis/toolbox/AlgorithmEventsRecorder.java index b80cc4bf..af55cd2a 100644 --- a/jsprit-analysis/src/main/java/com/graphhopper/jsprit/analysis/toolbox/AlgorithmEventsRecorder.java +++ b/jsprit-analysis/src/main/java/com/graphhopper/jsprit/analysis/toolbox/AlgorithmEventsRecorder.java @@ -102,12 +102,6 @@ public class AlgorithmEventsRecorder implements RuinListener, IterationStartsLis initialiseGraph(vrp); } - @Deprecated - public AlgorithmEventsRecorder(VehicleRoutingProblem vrp, String dgsFileLocation, boolean renderShipments) { - this.renderShipments = renderShipments; - new AlgorithmEventsRecorder(vrp, dgsFileLocation); - } - public void setRecordingRange(int startIteration, int endIteration) { this.start_recording_at = startIteration; this.end_recording_at = endIteration; diff --git a/jsprit-analysis/src/main/java/com/graphhopper/jsprit/analysis/toolbox/GraphStreamViewer.java b/jsprit-analysis/src/main/java/com/graphhopper/jsprit/analysis/toolbox/GraphStreamViewer.java index 38a0794a..8e9350d0 100644 --- a/jsprit-analysis/src/main/java/com/graphhopper/jsprit/analysis/toolbox/GraphStreamViewer.java +++ b/jsprit-analysis/src/main/java/com/graphhopper/jsprit/analysis/toolbox/GraphStreamViewer.java @@ -289,11 +289,6 @@ public class GraphStreamViewer { return this; } - @Deprecated - public GraphStreamViewer setEnableAutoLayout(boolean enableAutoLayout) { - return this; - } - public GraphStreamViewer setRenderShipments(boolean renderShipments) { this.renderShipments = renderShipments; return this; diff --git a/jsprit-analysis/src/main/java/com/graphhopper/jsprit/analysis/toolbox/Plotter.java b/jsprit-analysis/src/main/java/com/graphhopper/jsprit/analysis/toolbox/Plotter.java index c89c89f5..fae7a385 100644 --- a/jsprit-analysis/src/main/java/com/graphhopper/jsprit/analysis/toolbox/Plotter.java +++ b/jsprit-analysis/src/main/java/com/graphhopper/jsprit/analysis/toolbox/Plotter.java @@ -16,6 +16,7 @@ ******************************************************************************/ package com.graphhopper.jsprit.analysis.toolbox; +import com.graphhopper.jsprit.core.problem.Location; import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem; import com.graphhopper.jsprit.core.problem.job.*; import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution; @@ -23,7 +24,6 @@ import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute; import com.graphhopper.jsprit.core.problem.solution.route.activity.TourActivity; import com.graphhopper.jsprit.core.problem.vehicle.Vehicle; import com.graphhopper.jsprit.core.util.Coordinate; -import com.graphhopper.jsprit.core.util.Locations; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jfree.chart.*; @@ -459,22 +459,22 @@ public class Plotter { } private XYSeriesCollection makeSolutionSeries(VehicleRoutingProblem vrp, Collection routes) throws NoLocationFoundException { - Locations locations = retrieveLocations(vrp); + Map coords = makeMap(vrp.getAllLocations()); XYSeriesCollection coll = new XYSeriesCollection(); int counter = 1; for (VehicleRoute route : routes) { if (route.isEmpty()) continue; XYSeries series = new XYSeries(counter, false, true); - Coordinate startCoord = getCoordinate(locations.getCoord(route.getStart().getLocation().getId())); + Coordinate startCoord = getCoordinate(coords.get(route.getStart().getLocation().getId())); series.add(startCoord.getX() * scalingFactor, startCoord.getY() * scalingFactor); for (TourActivity act : route.getTourActivities().getActivities()) { - Coordinate coord = getCoordinate(locations.getCoord(act.getLocation().getId())); + Coordinate coord = getCoordinate(coords.get(act.getLocation().getId())); series.add(coord.getX() * scalingFactor, coord.getY() * scalingFactor); } - Coordinate endCoord = getCoordinate(locations.getCoord(route.getEnd().getLocation().getId())); + Coordinate endCoord = getCoordinate(coords.get(route.getEnd().getLocation().getId())); series.add(endCoord.getX() * scalingFactor, endCoord.getY() * scalingFactor); coll.addSeries(series); @@ -483,6 +483,12 @@ public class Plotter { return coll; } + private Map makeMap(Collection allLocations) { + Map coords = new HashMap(); + for(Location l : allLocations) coords.put(l.getId(),l.getCoordinate()); + return coords; + } + private XYSeriesCollection makeShipmentSeries(Collection jobs) throws NoLocationFoundException { XYSeriesCollection coll = new XYSeriesCollection(); if (!plotShipments) return coll; @@ -619,8 +625,5 @@ public class Plotter { activitiesByDataItem.put(item, activity); } - private Locations retrieveLocations(VehicleRoutingProblem vrp) throws NoLocationFoundException { - return vrp.getLocations(); - } } diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/SearchStrategy.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/SearchStrategy.java index 7ad77525..6dc94dfb 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/SearchStrategy.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/SearchStrategy.java @@ -55,11 +55,6 @@ public class SearchStrategy { return accepted; } - @Deprecated - public String getStrategyName() { - return strategyId; - } - public String getStrategyId() { return strategyId; } diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/SearchStrategyManager.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/SearchStrategyManager.java index 7f3dc85d..f02bb8cb 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/SearchStrategyManager.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/SearchStrategyManager.java @@ -51,18 +51,6 @@ public class SearchStrategyManager { return Collections.unmodifiableList(strategies); } - /** - * Returns the probabilities. - * [schroeder (2014.11.21): Now they are actually no propabilities anymore but weights. The resulting probabilities - * are calculated here with the sum of weights] - * - * @return list of probabilities - */ - @Deprecated - public List getProbabilities() { - return Collections.unmodifiableList(weights); - } - public List getWeights() { return Collections.unmodifiableList(weights); } diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/acceptor/AcceptNewRemoveFirst.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/acceptor/AcceptNewRemoveFirst.java index cae16527..5dd5f6c6 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/acceptor/AcceptNewRemoveFirst.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/acceptor/AcceptNewRemoveFirst.java @@ -1,19 +1,3 @@ -/******************************************************************************* - * Copyright (C) 2014 Stefan Schroeder - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3.0 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - ******************************************************************************/ package com.graphhopper.jsprit.core.algorithm.acceptor; import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution; @@ -21,9 +5,8 @@ import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolutio import java.util.Collection; /** - * @deprecated use GreedyAcceptance instead + * Created by schroeder on 09/02/16. */ -@Deprecated public class AcceptNewRemoveFirst implements SolutionAcceptor { private final int solutionMemory; @@ -51,6 +34,4 @@ public class AcceptNewRemoveFirst implements SolutionAcceptor { public String toString() { return "[name=acceptNewRemoveFirst]"; } - - } diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/acceptor/GreedyAcceptance_minVehFirst.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/acceptor/GreedyAcceptance_minVehFirst.java deleted file mode 100644 index ca94cf95..00000000 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/acceptor/GreedyAcceptance_minVehFirst.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2014 Stefan Schroeder - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3.0 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - ******************************************************************************/ -package com.graphhopper.jsprit.core.algorithm.acceptor; - -import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution; - -import java.util.Collection; - - -@Deprecated -public class GreedyAcceptance_minVehFirst implements SolutionAcceptor { - - private final int solutionMemory; - - public GreedyAcceptance_minVehFirst(int solutionMemory) { - this.solutionMemory = solutionMemory; - } - - /** - * Accepts every solution if solution memory allows. If memory occupied, than accepts new solution only if better than the worst in memory. - * Consequently, the worst solution is removed from solutions, and the new solution added. - *

- *

Note that this modifies Collection solutions. - */ - @Override - public boolean acceptSolution(Collection solutions, VehicleRoutingProblemSolution newSolution) { - boolean solutionAccepted = false; - if (solutions.size() < solutionMemory) { - solutions.add(newSolution); - solutionAccepted = true; - } else { - VehicleRoutingProblemSolution worstSolution = null; - for (VehicleRoutingProblemSolution s : solutions) { - if (worstSolution == null) worstSolution = s; - else if (s.getRoutes().size() > worstSolution.getRoutes().size()) worstSolution = s; - } - if (newSolution.getRoutes().size() < worstSolution.getRoutes().size()) { - solutions.remove(worstSolution); - solutions.add(newSolution); - solutionAccepted = true; - } else if (newSolution.getRoutes().size() == worstSolution.getRoutes().size() && newSolution.getCost() < worstSolution.getCost()) { - solutions.remove(worstSolution); - solutions.add(newSolution); - solutionAccepted = true; - } - } - return solutionAccepted; - } - - @Override - public String toString() { - return "[name=greedyAcceptance_minVehFirst]"; - } - - -} diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/io/InsertionFactory.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/io/InsertionFactory.java index a12461e5..a9c522f0 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/io/InsertionFactory.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/io/InsertionFactory.java @@ -91,11 +91,6 @@ class InsertionFactory { "if latter, you can also omit the tag. this has to be changed in algorithm-config-xml-file"); } } - String timeSliceString = config.getString("experimental[@timeSlice]"); - String neighbors = config.getString("experimental[@neighboringSlices]"); - if (timeSliceString != null && neighbors != null) { - iBuilder.experimentalTimeScheduler(Double.parseDouble(timeSliceString), Integer.parseInt(neighbors)); - } String allowVehicleSwitch = config.getString("allowVehicleSwitch"); if (allowVehicleSwitch != null) { iBuilder.setAllowVehicleSwitch(Boolean.parseBoolean(allowVehicleSwitch)); diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/io/VehicleRoutingAlgorithms.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/io/VehicleRoutingAlgorithms.java index a26830bc..17dabce5 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/io/VehicleRoutingAlgorithms.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/io/VehicleRoutingAlgorithms.java @@ -795,11 +795,6 @@ public class VehicleRoutingAlgorithms { typedMap.put(acceptorKey, acceptor); return acceptor; } - if (acceptorName.equals("greedyAcceptance_minVehFirst")) { - GreedyAcceptance_minVehFirst acceptor = new GreedyAcceptance_minVehFirst(solutionMemory); - typedMap.put(acceptorKey, acceptor); - return acceptor; - } if (acceptorName.equals("schrimpfAcceptance")) { String nuWarmupIterations = strategyConfig.getString("acceptor.warmup"); double alpha = strategyConfig.getDouble("acceptor.alpha"); diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/recreate/BestInsertionBuilder.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/recreate/BestInsertionBuilder.java index 5998194b..ad7018ee 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/recreate/BestInsertionBuilder.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/recreate/BestInsertionBuilder.java @@ -163,17 +163,6 @@ public class BestInsertionBuilder { return bestInsertion; } - /** - * @param timeSlice the time slice - * @param nNeighbors number of neighbors - * @deprecated this is experimental and can disappear. - */ - @Deprecated - public void experimentalTimeScheduler(double timeSlice, int nNeighbors) { - this.timeSlice = timeSlice; - this.nNeighbors = nNeighbors; - timeScheduling = true; - } public void setAllowVehicleSwitch(boolean allowVehicleSwitch) { this.allowVehicleSwitch = allowVehicleSwitch; diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/recreate/BestInsertionConcurrent.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/recreate/BestInsertionConcurrent.java index 5780b1a3..f9c298d8 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/recreate/BestInsertionConcurrent.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/recreate/BestInsertionConcurrent.java @@ -26,7 +26,10 @@ import com.graphhopper.jsprit.core.problem.vehicle.Vehicle; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; import java.util.concurrent.*; @@ -79,11 +82,6 @@ public final class BestInsertionConcurrent extends AbstractInsertionStrategy { private ExecutorCompletionService completionService; - @Deprecated - public void setRandom(Random random) { - super.random = random; - } - public BestInsertionConcurrent(JobInsertionCostsCalculator jobInsertionCalculator, ExecutorService executorService, int nuOfBatches, VehicleRoutingProblem vehicleRoutingProblem) { super(vehicleRoutingProblem); this.insertionsListeners = new InsertionListeners(); diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/recreate/InsertionBuilder.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/recreate/InsertionBuilder.java index b6573f61..33830776 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/recreate/InsertionBuilder.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/recreate/InsertionBuilder.java @@ -204,18 +204,6 @@ public class InsertionBuilder { return insertion; } - /** - * @param timeSlice the time slice - * @param nNeighbors number of neighbors - * @deprecated this is experimental and can disappear. - */ - @Deprecated - public void experimentalTimeScheduler(double timeSlice, int nNeighbors) { - this.timeSlice = timeSlice; - this.nNeighbors = nNeighbors; - timeScheduling = true; - } - public InsertionBuilder setAllowVehicleSwitch(boolean allowVehicleSwitch) { this.allowVehicleSwitch = allowVehicleSwitch; return this; diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/AbstractRuinStrategy.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/AbstractRuinStrategy.java index 1637fa4f..65f72967 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/AbstractRuinStrategy.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/AbstractRuinStrategy.java @@ -70,19 +70,6 @@ public abstract class AbstractRuinStrategy implements RuinStrategy { public abstract Collection ruinRoutes(Collection vehicleRoutes); - - @Override - @Deprecated - public Collection ruin(Collection vehicleRoutes, Job targetJob, int nOfJobs2BeRemoved) { - ruinListeners.ruinStarts(vehicleRoutes); - Collection unassigned = ruinRoutes(vehicleRoutes, targetJob, nOfJobs2BeRemoved); - ruinListeners.ruinEnds(vehicleRoutes, unassigned); - return unassigned; - } - - @Deprecated - public abstract Collection ruinRoutes(Collection vehicleRoutes, Job targetJob, int nOfJobs2BeRemoved); - @Override public void addListener(RuinListener ruinListener) { ruinListeners.addListener(ruinListener); diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinClusters.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinClusters.java index 22121970..eba277f7 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinClusters.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinClusters.java @@ -106,14 +106,6 @@ public final class RuinClusters extends AbstractRuinStrategy implements Iteratio return unassignedJobs; } - /** - * Removes nOfJobs2BeRemoved from vehicleRoutes, including targetJob. - */ - @Override - public Collection ruinRoutes(Collection vehicleRoutes, Job targetJob, int nOfJobs2BeRemoved) { - throw new IllegalStateException("not supported"); - } - private void ruin(Collection vehicleRoutes, int nOfJobs2BeRemoved, List unassignedJobs) { if (vrp.getJobs().values().size() == 0) return; Map mappedRoutes = map(vehicleRoutes); diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinRadial.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinRadial.java index a2843f4c..cf87c739 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinRadial.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinRadial.java @@ -129,10 +129,8 @@ public final class RuinRadial extends AbstractRuinStrategy { /** * Removes targetJob and its neighborhood and returns the removed jobs. * - * @deprecated will be private */ - @Deprecated - public Collection ruinRoutes(Collection vehicleRoutes, Job targetJob, int nOfJobs2BeRemoved) { + private Collection ruinRoutes(Collection vehicleRoutes, Job targetJob, int nOfJobs2BeRemoved) { List unassignedJobs = new ArrayList(); int nNeighbors = nOfJobs2BeRemoved - 1; removeJob(targetJob, vehicleRoutes); @@ -147,4 +145,5 @@ public final class RuinRadial extends AbstractRuinStrategy { return unassignedJobs; } + } diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinRadialMultipleCenters.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinRadialMultipleCenters.java index 2ee891fc..ae654f43 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinRadialMultipleCenters.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinRadialMultipleCenters.java @@ -33,6 +33,7 @@ import java.util.*; * * @author stefan */ +@Deprecated public final class RuinRadialMultipleCenters extends AbstractRuinStrategy { private Logger logger = LogManager.getLogger(RuinRadialMultipleCenters.class); @@ -96,16 +97,6 @@ public final class RuinRadialMultipleCenters extends AbstractRuinStrategy { return ruined; } - /** - * Removes targetJob and its neighborhood and returns the removed jobs. - * - * @deprecated will be private - */ - @Deprecated - public Collection ruinRoutes(Collection vehicleRoutes, Job targetJob, int nOfJobs2BeRemoved) { - return ruinRoutes_(vehicleRoutes, targetJob, nOfJobs2BeRemoved, null); - } - private Collection ruinRoutes_(Collection vehicleRoutes, Job targetJob, int nOfJobs2BeRemoved, Set available) { List unassignedJobs = new ArrayList(); int nNeighbors = nOfJobs2BeRemoved - 1; diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinRandom.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinRandom.java index 36dcf1a7..c6763078 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinRandom.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinRandom.java @@ -75,14 +75,6 @@ public final class RuinRandom extends AbstractRuinStrategy { return unassignedJobs; } - /** - * Removes nOfJobs2BeRemoved from vehicleRoutes, including targetJob. - */ - @Override - public Collection ruinRoutes(Collection vehicleRoutes, Job targetJob, int nOfJobs2BeRemoved) { - throw new IllegalStateException("not supported"); - } - private void ruin(Collection vehicleRoutes, int nOfJobs2BeRemoved, List unassignedJobs) { ArrayList availableJobs = new ArrayList(vrp.getJobs().values()); Collections.shuffle(availableJobs, random); diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinStrategy.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinStrategy.java index b4174d2f..ec9efac0 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinStrategy.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinStrategy.java @@ -38,12 +38,6 @@ public interface RuinStrategy { */ public Collection ruin(Collection vehicleRoutes); - /** - * Removes targetJob as well as its neighbors with a size of (nOfJobs2BeRemoved-1). - */ - @Deprecated - public Collection ruin(Collection vehicleRoutes, Job targetJob, int nOfJobs2BeRemoved); - /** * Adds a ruin-listener. * diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinWorst.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinWorst.java index e80f9b6f..82ab585e 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinWorst.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/ruin/RuinWorst.java @@ -79,14 +79,6 @@ public final class RuinWorst extends AbstractRuinStrategy { return unassignedJobs; } - /** - * Removes nOfJobs2BeRemoved from vehicleRoutes, including targetJob. - */ - @Override - public Collection ruinRoutes(Collection vehicleRoutes, Job targetJob, int nOfJobs2BeRemoved) { - throw new UnsupportedOperationException("ruinRoutes not supported"); - } - private void ruin(Collection vehicleRoutes, int nOfJobs2BeRemoved, List unassignedJobs) { LinkedList availableJobs = new LinkedList(vrp.getJobs().values()); int toRemove = nOfJobs2BeRemoved; diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/state/StateManager.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/state/StateManager.java index 1748673b..3e9530bf 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/state/StateManager.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/algorithm/state/StateManager.java @@ -634,8 +634,4 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart addActivityVisitor(new UpdateSkills(this)); } - @Deprecated - public void addCoreUpdater() { - - } } diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/analysis/SolutionAnalyser.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/analysis/SolutionAnalyser.java index a3c6f024..3be14ece 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/analysis/SolutionAnalyser.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/analysis/SolutionAnalyser.java @@ -20,7 +20,6 @@ package com.graphhopper.jsprit.core.analysis; import com.graphhopper.jsprit.core.algorithm.VariablePlusFixedSolutionCostCalculatorFactory; import com.graphhopper.jsprit.core.algorithm.state.*; import com.graphhopper.jsprit.core.problem.Capacity; -import com.graphhopper.jsprit.core.problem.Location; import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem; import com.graphhopper.jsprit.core.problem.cost.TransportDistance; import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingActivityCosts; @@ -54,15 +53,6 @@ public class SolutionAnalyser { private final static String LOAD_DELIVERED = "load-delivered"; - /** - * @deprecated use TransportDistance instead - */ - @Deprecated - public static interface DistanceCalculator { - - public double getDistance(Location from, Location to); - - } private static class LoadAndActivityCounter implements StateUpdater, ActivityVisitor { @@ -304,7 +294,7 @@ public class SolutionAnalyser { private static class LastTransportUpdater implements StateUpdater, ActivityVisitor { private final StateManager stateManager; private final VehicleRoutingTransportCosts transportCost; - private final DistanceCalculator distanceCalculator; + private final TransportDistance distanceCalculator; private final StateId last_transport_distance_id; private final StateId last_transport_time_id; private final StateId last_transport_cost_id; @@ -313,7 +303,7 @@ public class SolutionAnalyser { private VehicleRoute route; - private LastTransportUpdater(StateManager stateManager, VehicleRoutingTransportCosts transportCost, DistanceCalculator distanceCalculator, StateId last_distance_id, StateId last_time_id, StateId last_cost_id) { + private LastTransportUpdater(StateManager stateManager, VehicleRoutingTransportCosts transportCost, TransportDistance distanceCalculator, StateId last_distance_id, StateId last_time_id, StateId last_cost_id) { this.stateManager = stateManager; this.transportCost = transportCost; this.distanceCalculator = distanceCalculator; @@ -368,13 +358,13 @@ public class SolutionAnalyser { private double sum_distance = 0.; - private DistanceCalculator distanceCalculator; + private TransportDistance distanceCalculator; private TourActivity prevAct; private VehicleRoute route; - private DistanceUpdater(StateId distance_id, StateManager stateManager, DistanceCalculator distanceCalculator) { + private DistanceUpdater(StateId distance_id, StateManager stateManager, TransportDistance distanceCalculator) { this.distance_id = distance_id; this.stateManager = stateManager; this.distanceCalculator = distanceCalculator; @@ -451,7 +441,7 @@ public class SolutionAnalyser { private StateManager stateManager; - private DistanceCalculator distanceCalculator; + private TransportDistance distanceCalculator; private StateId waiting_time_id; @@ -510,10 +500,9 @@ public class SolutionAnalyser { * @param vrp * @param solution * @param distanceCalculator - * @deprecated use SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, final TransportDistance distanceCalculator) instead + * */ - @Deprecated - public SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, DistanceCalculator distanceCalculator) { + public SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, TransportDistance distanceCalculator) { this.vrp = vrp; this.solution = solution; this.distanceCalculator = distanceCalculator; @@ -522,21 +511,7 @@ public class SolutionAnalyser { refreshStates(); } - public SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, final TransportDistance distanceCalculator) { - this.vrp = vrp; - this.solution = solution; - this.distanceCalculator = new DistanceCalculator() { - @Override - public double getDistance(Location from, Location to) { - return distanceCalculator.getDistance(from, to); - } - }; - initialise(); - this.solutionCostCalculator = new VariablePlusFixedSolutionCostCalculatorFactory(stateManager).createCalculator(); - refreshStates(); - } - - public SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, SolutionCostCalculator solutionCostCalculator, DistanceCalculator distanceCalculator) { + public SolutionAnalyser(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, SolutionCostCalculator solutionCostCalculator, TransportDistance distanceCalculator) { this.vrp = vrp; this.solution = solution; this.distanceCalculator = distanceCalculator; @@ -684,7 +659,7 @@ public class SolutionAnalyser { } private void verifyThatRouteContainsAct(TourActivity activity, VehicleRoute route) { - if (!route.getTourActivities().hasActivity(activity)) { + if (!route.getActivities().contains(activity)) { throw new IllegalArgumentException("specified route does not contain specified activity " + activity); } } diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/VehicleRoutingProblem.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/VehicleRoutingProblem.java index 26786188..1f6a0b30 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/VehicleRoutingProblem.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/VehicleRoutingProblem.java @@ -203,9 +203,8 @@ public class VehicleRoutingProblem { * @param job job to be added * @return this builder * @throws IllegalStateException if job is neither a shipment nor a service, or jobId has already been added. - * @deprecated use addJob(AbstractJob job) instead + * */ - @Deprecated public Builder addJob(Job job) { if (!(job instanceof AbstractJob)) throw new IllegalArgumentException("job must be of type AbstractJob"); return addJob((AbstractJob) job); @@ -348,9 +347,7 @@ public class VehicleRoutingProblem { * * @param vehicle vehicle to be added * @return this builder - * @deprecated use addVehicle(AbstractVehicle vehicle) instead - */ - @Deprecated + * */ public Builder addVehicle(Vehicle vehicle) { if (!(vehicle instanceof AbstractVehicle)) throw new IllegalStateException("vehicle must be an AbstractVehicle"); @@ -445,7 +442,6 @@ public class VehicleRoutingProblem { * @param jobs which is a collection of jobs that subclasses Job * @return this builder */ - @SuppressWarnings("deprecation") public Builder addAllJobs(Collection jobs) { for (Job j : jobs) { addJob(j); @@ -453,6 +449,7 @@ public class VehicleRoutingProblem { return this; } + /** * Adds a collection of vehicles. * @@ -663,15 +660,6 @@ public class VehicleRoutingProblem { return activityCosts; } - /** - * @return returns all location, i.e. from vehicles and jobs. - */ - @Deprecated - public Locations getLocations() { - return locations; - } - - public Collection getAllLocations(){ return allLocations; } diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/io/VrpXMLReader.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/io/VrpXMLReader.java index 2a0a9f33..6c81bd16 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/io/VrpXMLReader.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/io/VrpXMLReader.java @@ -25,7 +25,6 @@ import com.graphhopper.jsprit.core.problem.job.*; import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution; import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute; import com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow; -import com.graphhopper.jsprit.core.problem.solution.route.activity.TourActivityFactory; import com.graphhopper.jsprit.core.problem.vehicle.Vehicle; import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl; import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl.Builder; @@ -70,12 +69,6 @@ public class VrpXMLReader { } } - @Deprecated - interface JobConfigReader { - - void readConfig(XMLConfiguration vrpProblem); - } - private static Logger logger = LogManager.getLogger(VrpXMLReader.class); private VehicleRoutingProblem.Builder vrpBuilder; @@ -94,21 +87,7 @@ public class VrpXMLReader { private ServiceBuilderFactory serviceBuilderFactory = new DefaultServiceBuilderFactory(); - private Collection jobConfigReaders = new ArrayList(); - @Deprecated - public void addJobConfigReader(JobConfigReader reader) { - jobConfigReaders.add(reader); - } - - @Deprecated - public void setTourActivityFactory(TourActivityFactory tourActivityFactory) { - } - - @Deprecated - public void setServiceBuilderFactory(ServiceBuilderFactory serviceBuilderFactory) { - this.serviceBuilderFactory = serviceBuilderFactory; - } /** * @param schemaValidation the schemaValidation to set @@ -287,7 +266,6 @@ public class VrpXMLReader { VehicleRoute.Builder routeBuilder = VehicleRoute.Builder.newInstance(vehicle, driver); routeBuilder.setDepartureTime(departureTime); - routeBuilder.setRouteEndArrivalTime(Double.parseDouble(end)); List actConfigs = routeConfig.configurationsAt("act"); for (HierarchicalConfiguration actConfig : actConfigs) { String type = actConfig.getString("[@type]"); 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 85a56c3c..d8971c22 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 @@ -139,32 +139,6 @@ public class VehicleRoute { }; - /** - * Sets the serviceActivityFactory to create serviceActivities. - *

- *

By default {@link DefaultTourActivityFactory} is used. - * - * @param serviceActivityFactory the factory to create serviceActivities - */ - @Deprecated - public Builder setServiceActivityFactory(TourActivityFactory serviceActivityFactory) { - this.serviceActivityFactory = serviceActivityFactory; - return this; - } - - /** - * Sets the shipmentActivityFactory to create shipmentActivities. - *

- *

By default {@link DefaultShipmentActivityFactory} is used. - * - * @param shipmentActivityFactory the factory to create shipmentActivities - */ - @Deprecated - public Builder setShipmentActivityFactory(TourShipmentActivityFactory shipmentActivityFactory) { - this.shipmentActivityFactory = shipmentActivityFactory; - return this; - } - public Builder setJobActivityFactory(JobActivityFactory jobActivityFactory) { this.jobActivityFactory = jobActivityFactory; return this; @@ -195,21 +169,6 @@ public class VehicleRoute { return this; } - /** - * Sets the end-time of the route, i.e. which is the time the vehicle has to be at its end-location at latest. - * - * @param endTime endTime of route - * @return this builder - * @throws IllegalArgumentException if endTime > vehicle.getLatestArrival() - */ - @Deprecated - public Builder setRouteEndArrivalTime(double endTime) { - if (endTime > vehicle.getLatestArrival()) - throw new IllegalArgumentException("endTime > vehicle.getLatestArrival(). this must not be."); - end.setArrTime(endTime); - return this; - } - /** * Adds a service to this route. Activity is initialized with .getTimeWindow(). If you want to explicitly set another time window * use .addService(Service service, TimeWindow timeWindow) diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/BreakActivity.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/BreakActivity.java index 725f96b1..21fc238a 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/BreakActivity.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/BreakActivity.java @@ -135,11 +135,6 @@ public class BreakActivity extends AbstractActivity implements TourActivity.JobA return aBreak.getServiceDuration(); } - @Override - public String getLocationId() { - return aBreak.getLocation().getId(); - } - @Override public Location getLocation() { return location; diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/DeliverService.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/DeliverService.java index 3fa4c317..a2524568 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/DeliverService.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/DeliverService.java @@ -56,11 +56,6 @@ public final class DeliverService extends AbstractActivity implements DeliveryAc return delivery.getType(); } - @Override - public String getLocationId() { - return delivery.getLocation().getId(); - } - @Override public Location getLocation() { return delivery.getLocation(); @@ -123,7 +118,7 @@ public final class DeliverService extends AbstractActivity implements DeliveryAc } public String toString() { - return "[type=" + getName() + "][locationId=" + getLocationId() + return "[type=" + getName() + "][locationId=" + getLocation().getId() + "][size=" + getSize().toString() + "][twStart=" + Activities.round(getTheoreticalEarliestOperationStartTime()) + "][twEnd=" + Activities.round(getTheoreticalLatestOperationStartTime()) + "]"; diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/DeliverShipment.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/DeliverShipment.java index 700686b0..9eb5bb4d 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/DeliverShipment.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/DeliverShipment.java @@ -42,8 +42,7 @@ public final class DeliverShipment extends AbstractActivity implements DeliveryA this.capacity = Capacity.invert(shipment.getSize()); } - @Deprecated - public DeliverShipment(DeliverShipment deliveryShipmentActivity) { + private DeliverShipment(DeliverShipment deliveryShipmentActivity) { this.shipment = (Shipment) deliveryShipmentActivity.getJob(); this.arrTime = deliveryShipmentActivity.getArrTime(); this.endTime = deliveryShipmentActivity.getEndTime(); @@ -73,11 +72,6 @@ public final class DeliverShipment extends AbstractActivity implements DeliveryA return "deliverShipment"; } - @Override - public String getLocationId() { - return shipment.getDeliveryLocation().getId(); - } - @Override public Location getLocation() { return shipment.getDeliveryLocation(); @@ -124,7 +118,7 @@ public final class DeliverShipment extends AbstractActivity implements DeliveryA } public String toString() { - return "[type=" + getName() + "][locationId=" + getLocationId() + return "[type=" + getName() + "][locationId=" + getLocation().getId() + "][size=" + getSize().toString() + "][twStart=" + Activities.round(getTheoreticalEarliestOperationStartTime()) + "][twEnd=" + Activities.round(getTheoreticalLatestOperationStartTime()) + "]"; diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/End.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/End.java index 77fea323..a9b6f0ff 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/End.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/End.java @@ -19,15 +19,10 @@ package com.graphhopper.jsprit.core.problem.solution.route.activity; import com.graphhopper.jsprit.core.problem.AbstractActivity; import com.graphhopper.jsprit.core.problem.Capacity; import com.graphhopper.jsprit.core.problem.Location; -import com.graphhopper.jsprit.core.util.Coordinate; public final class End extends AbstractActivity implements TourActivity { - @Deprecated - public static int creation = 0; - public static End newInstance(String locationId, double earliestArrival, double latestArrival) { - creation++; return new End(locationId, earliestArrival, latestArrival); } @@ -37,17 +32,6 @@ public final class End extends AbstractActivity implements TourActivity { private final static Capacity capacity = Capacity.Builder.newInstance().build(); - private Coordinate coordinate; - - @Deprecated - Coordinate getCoordinate() { - return coordinate; - } - - @Deprecated - void setCoordinate(Coordinate coordinate) { - this.coordinate = coordinate; - } private double endTime = -1; @@ -112,23 +96,10 @@ public final class End extends AbstractActivity implements TourActivity { this.endTime = endTime; } - @Deprecated - public void setLocationId(String locationId) { - if (locationId == null) return; - this.location = Location.Builder.newInstance().setId(locationId).build(); - } - public void setLocation(Location location) { this.location = location; } - @Deprecated - @Override - public String getLocationId() { - if (location == null) return null; - return location.getId(); - } - @Override public Location getLocation() { return location; diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/PickupService.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/PickupService.java index 209461a8..8512db7e 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/PickupService.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/PickupService.java @@ -57,11 +57,6 @@ public final class PickupService extends AbstractActivity implements PickupActiv return pickup.getType(); } - @Override - public String getLocationId() { - return pickup.getLocation().getId(); - } - @Override public Location getLocation() { return pickup.getLocation(); @@ -123,7 +118,7 @@ public final class PickupService extends AbstractActivity implements PickupActiv } public String toString() { - return "[type=" + getName() + "][locationId=" + getLocationId() + return "[type=" + getName() + "][locationId=" + getLocation().getId() + "][size=" + getSize().toString() + "][twStart=" + Activities.round(getTheoreticalEarliestOperationStartTime()) + "][twEnd=" + Activities.round(getTheoreticalLatestOperationStartTime()) + "]"; diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/PickupShipment.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/PickupShipment.java index 000f6090..e9abfbae 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/PickupShipment.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/PickupShipment.java @@ -39,8 +39,7 @@ public final class PickupShipment extends AbstractActivity implements PickupActi this.shipment = shipment; } - @Deprecated - public PickupShipment(PickupShipment pickupShipmentActivity) { + private PickupShipment(PickupShipment pickupShipmentActivity) { this.shipment = (Shipment) pickupShipmentActivity.getJob(); this.arrTime = pickupShipmentActivity.getArrTime(); this.endTime = pickupShipmentActivity.getEndTime(); @@ -69,11 +68,6 @@ public final class PickupShipment extends AbstractActivity implements PickupActi return "pickupShipment"; } - @Override - public String getLocationId() { - return shipment.getPickupLocation().getId(); - } - @Override public Location getLocation() { return shipment.getPickupLocation(); @@ -120,7 +114,7 @@ public final class PickupShipment extends AbstractActivity implements PickupActi } public String toString() { - return "[type=" + getName() + "][locationId=" + getLocationId() + return "[type=" + getName() + "][locationId=" + getLocation().getId() + "][size=" + getSize().toString() + "][twStart=" + Activities.round(getTheoreticalEarliestOperationStartTime()) + "][twEnd=" + Activities.round(getTheoreticalLatestOperationStartTime()) + "]"; diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/ServiceActivity.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/ServiceActivity.java index 38241dbe..6fb86afa 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/ServiceActivity.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/ServiceActivity.java @@ -23,9 +23,6 @@ import com.graphhopper.jsprit.core.problem.job.Service; public class ServiceActivity extends AbstractActivity implements TourActivity.JobActivity { - @Deprecated - public static int counter = 0; - public double arrTime; public double endTime; @@ -74,12 +71,10 @@ public class ServiceActivity extends AbstractActivity implements TourActivity.Jo private final Service service; protected ServiceActivity(Service service) { - counter++; this.service = service; } protected ServiceActivity(ServiceActivity serviceActivity) { - counter++; this.service = serviceActivity.getJob(); this.arrTime = serviceActivity.getArrTime(); this.endTime = serviceActivity.getEndTime(); @@ -143,11 +138,6 @@ public class ServiceActivity extends AbstractActivity implements TourActivity.Jo return service.getServiceDuration(); } - @Override - public String getLocationId() { - return service.getLocation().getId(); - } - @Override public Location getLocation() { return service.getLocation(); @@ -162,7 +152,7 @@ public class ServiceActivity extends AbstractActivity implements TourActivity.Jo @Override public String toString() { - return "[type=" + getName() + "][locationId=" + getLocationId() + return "[type=" + getName() + "][locationId=" + getLocation().getId() + "][size=" + getSize().toString() + "][twStart=" + Activities.round(getTheoreticalEarliestOperationStartTime()) + "][twEnd=" + Activities.round(getTheoreticalLatestOperationStartTime()) + "]"; diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/Start.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/Start.java index d0ac8d87..8a606326 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/Start.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/Start.java @@ -22,15 +22,12 @@ import com.graphhopper.jsprit.core.problem.Location; public final class Start extends AbstractActivity implements TourActivity { - public final static String ACTIVITY_NAME = "start"; - @Deprecated - public static int creation; - + public final static String ACTIVITY_NAME = "start"; + private final static Capacity capacity = Capacity.Builder.newInstance().build(); public static Start newInstance(String locationId, double theoreticalStart, double theoreticalEnd) { - creation++; return new Start(locationId, theoreticalStart, theoreticalEnd); } @@ -50,8 +47,7 @@ public final class Start extends AbstractActivity implements TourActivity { private Location location; - @Deprecated - public Start(String locationId, double theoreticalStart, double theoreticalEnd) { + private Start(String locationId, double theoreticalStart, double theoreticalEnd) { super(); if (locationId != null) this.location = Location.Builder.newInstance().setId(locationId).build(); this.theoretical_earliestOperationStartTime = theoreticalStart; @@ -81,12 +77,6 @@ public final class Start extends AbstractActivity implements TourActivity { return theoretical_earliestOperationStartTime; } - @Deprecated - public void setLocationId(String locationId) { - if (locationId == null) return; - this.location = Location.Builder.newInstance().setId(locationId).build(); - } - public void setLocation(Location location) { this.location = location; } @@ -97,23 +87,15 @@ public final class Start extends AbstractActivity implements TourActivity { return theoretical_latestOperationStartTime; } - @Deprecated + public void setTheoreticalEarliestOperationStartTime(double time) { this.theoretical_earliestOperationStartTime = time; } - @Deprecated public void setTheoreticalLatestOperationStartTime(double time) { this.theoretical_latestOperationStartTime = time; } - @Deprecated - @Override - public String getLocationId() { - if (location == null) return null; - return location.getId(); - } - @Override public Location getLocation() { return location; diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/TourActivities.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/TourActivities.java index 1984db81..530e6ea0 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/TourActivities.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/TourActivities.java @@ -146,17 +146,6 @@ public class TourActivities { return activityRemoved; } - /** - * Returns true if this contains specified activity. - * - * @param activity to be looked up - * @return true if this contains specified activity, false otherwise - */ - @Deprecated - public boolean hasActivity(TourActivity activity) { - return tourActivities.contains(activity); - } - /** * Removes activity from this activity sequence. Removes its corresponding job as well, if there are no other activities * related to this job. diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/TourActivity.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/TourActivity.java index b17f0fbd..0166899d 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/TourActivity.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/solution/route/activity/TourActivity.java @@ -59,15 +59,6 @@ public interface TourActivity extends HasIndex { */ public abstract String getName(); - /** - * Returns the activity's locationId. - * - * @return locationId - * @deprecated use location - */ - @Deprecated - public abstract String getLocationId(); - /** * Returns location. * diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/util/CalculationUtils.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/util/CalculationUtils.java index 3e80b9bf..d55f9a7e 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/util/CalculationUtils.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/util/CalculationUtils.java @@ -31,6 +31,7 @@ public class CalculationUtils { * @param act * @return */ + @Deprecated public static double getActivityEndTime(double actArrTime, TourActivity act){ return Math.max(actArrTime, act.getTheoreticalEarliestOperationStartTime()) + act.getOperationTime(); } diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/util/GreatCircleCosts.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/util/GreatCircleCosts.java index bbcd5357..216e3fbd 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/util/GreatCircleCosts.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/util/GreatCircleCosts.java @@ -49,25 +49,10 @@ public class GreatCircleCosts extends AbstractForwardVehicleRoutingTransportCost this.detour = detour; } - private Locations locations; - private DistanceUnit distanceUnit = DistanceUnit.Kilometer; - @Deprecated - public GreatCircleCosts(Locations locations) { + public GreatCircleCosts() { super(); - this.locations = locations; - } - - public GreatCircleCosts() { - super(); - } - - @Deprecated - public GreatCircleCosts(Locations locations, DistanceUnit distanceUnit) { - super(); - this.locations = locations; - this.distanceUnit = distanceUnit; } public GreatCircleCosts(DistanceUnit distanceUnit) { @@ -96,12 +81,9 @@ public class GreatCircleCosts extends AbstractForwardVehicleRoutingTransportCost private double calculateDistance(Location fromLocation, Location toLocation) { Coordinate from = null; Coordinate to = null; - if (fromLocation.getCoordinate() != null & toLocation.getCoordinate() != null) { + if (fromLocation.getCoordinate() != null && toLocation.getCoordinate() != null) { from = fromLocation.getCoordinate(); to = toLocation.getCoordinate(); - } else if (locations != null) { - from = locations.getCoord(fromLocation.getId()); - to = locations.getCoord(toLocation.getId()); } if (from == null || to == null) throw new NullPointerException("either from or to location is null"); return GreatCircleDistanceCalculator.calculateDistance(from, to, distanceUnit) * detour; @@ -112,19 +94,6 @@ public class GreatCircleCosts extends AbstractForwardVehicleRoutingTransportCost return calculateDistance(from, to) / speed; } - /** - * @param fromId - * @param toId - * @return - * @deprecated use getDistance(Location from, Location to) instead - */ - @Deprecated - public double getDistance(String fromId, String toId) { - Coordinate fromCoordinate = locations.getCoord(fromId); - Coordinate toCoordinate = locations.getCoord(toId); - return GreatCircleDistanceCalculator.calculateDistance(fromCoordinate, toCoordinate, distanceUnit) * detour; - } - @Override public double getDistance(Location from, Location to) { return calculateDistance(from, to); diff --git a/jsprit-core/src/test/java/com/graphhopper/jsprit/core/algorithm/VehicleRoutingAlgorithmTest.java b/jsprit-core/src/test/java/com/graphhopper/jsprit/core/algorithm/VehicleRoutingAlgorithmTest.java index 5208a7b4..d89fa1e5 100644 --- a/jsprit-core/src/test/java/com/graphhopper/jsprit/core/algorithm/VehicleRoutingAlgorithmTest.java +++ b/jsprit-core/src/test/java/com/graphhopper/jsprit/core/algorithm/VehicleRoutingAlgorithmTest.java @@ -68,7 +68,7 @@ public class VehicleRoutingAlgorithmTest { VehicleRoutingAlgorithm algorithm = new VehicleRoutingAlgorithm(mock(VehicleRoutingProblem.class), stratManager); when(stratManager.getRandomStrategy()).thenReturn(mock(SearchStrategy.class)); - when(stratManager.getProbabilities()).thenReturn(Arrays.asList(1.0)); + when(stratManager.getWeights()).thenReturn(Arrays.asList(1.0)); algorithm.setMaxIterations(1000); CountIterations counter = new CountIterations(); algorithm.addListener(counter); @@ -82,7 +82,7 @@ public class VehicleRoutingAlgorithmTest { VehicleRoutingAlgorithm algorithm = new VehicleRoutingAlgorithm(mock(VehicleRoutingProblem.class), stratManager); when(stratManager.getRandomStrategy()).thenReturn(mock(SearchStrategy.class)); - when(stratManager.getProbabilities()).thenReturn(Arrays.asList(1.0)); + when(stratManager.getWeights()).thenReturn(Arrays.asList(1.0)); algorithm.setMaxIterations(1000); CountIterations counter = new CountIterations(); algorithm.addListener(counter); @@ -96,7 +96,7 @@ public class VehicleRoutingAlgorithmTest { VehicleRoutingAlgorithm algorithm = new VehicleRoutingAlgorithm(mock(VehicleRoutingProblem.class), stratManager); when(stratManager.getRandomStrategy()).thenReturn(mock(SearchStrategy.class)); - when(stratManager.getProbabilities()).thenReturn(Arrays.asList(1.0)); + when(stratManager.getWeights()).thenReturn(Arrays.asList(1.0)); algorithm.setMaxIterations(1000); PrematureAlgorithmTermination termination = new PrematureAlgorithmTermination() { @@ -121,7 +121,7 @@ public class VehicleRoutingAlgorithmTest { SearchStrategyManager stratManager = mock(SearchStrategyManager.class); VehicleRoutingAlgorithm algorithm = new VehicleRoutingAlgorithm(mock(VehicleRoutingProblem.class), stratManager); when(stratManager.getRandomStrategy()).thenReturn(mock(SearchStrategy.class)); - when(stratManager.getProbabilities()).thenReturn(Arrays.asList(1.0)); + when(stratManager.getWeights()).thenReturn(Arrays.asList(1.0)); algorithm.setMaxIterations(1000); PrematureAlgorithmTermination termination = new PrematureAlgorithmTermination() { @@ -147,7 +147,7 @@ public class VehicleRoutingAlgorithmTest { SearchStrategyManager stratManager = mock(SearchStrategyManager.class); VehicleRoutingAlgorithm algorithm = new VehicleRoutingAlgorithm(mock(VehicleRoutingProblem.class), stratManager); when(stratManager.getRandomStrategy()).thenReturn(mock(SearchStrategy.class)); - when(stratManager.getProbabilities()).thenReturn(Arrays.asList(1.0)); + when(stratManager.getWeights()).thenReturn(Arrays.asList(1.0)); algorithm.setMaxIterations(1000); PrematureAlgorithmTermination termination = new PrematureAlgorithmTermination() { diff --git a/jsprit-core/src/test/java/com/graphhopper/jsprit/core/algorithm/io/TestAlgorithmReader.java b/jsprit-core/src/test/java/com/graphhopper/jsprit/core/algorithm/io/TestAlgorithmReader.java index 1c333bfe..dfabbb62 100644 --- a/jsprit-core/src/test/java/com/graphhopper/jsprit/core/algorithm/io/TestAlgorithmReader.java +++ b/jsprit-core/src/test/java/com/graphhopper/jsprit/core/algorithm/io/TestAlgorithmReader.java @@ -193,11 +193,6 @@ public class TestAlgorithmReader { return null; } - @Override - public Collection ruin(Collection vehicleRoutes, - Job targetJob, int nOfJobs2BeRemoved) { - return null; - } @Override public void addListener(RuinListener ruinListener) { diff --git a/jsprit-core/src/test/java/com/graphhopper/jsprit/core/analysis/SolutionAnalyserTest.java b/jsprit-core/src/test/java/com/graphhopper/jsprit/core/analysis/SolutionAnalyserTest.java index 21703538..33416811 100644 --- a/jsprit-core/src/test/java/com/graphhopper/jsprit/core/analysis/SolutionAnalyserTest.java +++ b/jsprit-core/src/test/java/com/graphhopper/jsprit/core/analysis/SolutionAnalyserTest.java @@ -2212,7 +2212,7 @@ public class SolutionAnalyserTest { SolutionPrinter.print(vrp, solution, SolutionPrinter.Print.VERBOSE); TourActivity deliverShipment = route.getActivities().get(2); route.getTourActivities().removeActivity(deliverShipment); - assertFalse(route.getTourActivities().hasActivity(deliverShipment)); + assertFalse(route.getActivities().contains(deliverShipment)); SolutionPrinter.print(vrp, solution, SolutionPrinter.Print.VERBOSE); SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, new TransportDistance() { @@ -2233,7 +2233,7 @@ public class SolutionAnalyserTest { SolutionPrinter.print(vrp, solution, SolutionPrinter.Print.VERBOSE); TourActivity pickupShipment = route.getActivities().get(1); route.getTourActivities().removeActivity(pickupShipment); - assertFalse(route.getTourActivities().hasActivity(pickupShipment)); + assertFalse(route.getActivities().contains(pickupShipment)); SolutionPrinter.print(vrp, solution, SolutionPrinter.Print.VERBOSE); SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, new TransportDistance() { @@ -2254,7 +2254,7 @@ public class SolutionAnalyserTest { SolutionPrinter.print(vrp, solution, SolutionPrinter.Print.VERBOSE); TourActivity pickupShipment = route.getActivities().get(1); route.getTourActivities().removeActivity(pickupShipment); - assertFalse(route.getTourActivities().hasActivity(pickupShipment)); + assertFalse(route.getActivities().contains(pickupShipment)); SolutionPrinter.print(vrp, solution, SolutionPrinter.Print.VERBOSE); SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, new TransportDistance() { @@ -2275,7 +2275,7 @@ public class SolutionAnalyserTest { SolutionPrinter.print(vrp, solution, SolutionPrinter.Print.VERBOSE); TourActivity pickupShipment = route.getActivities().get(1); route.getTourActivities().removeActivity(pickupShipment); - assertFalse(route.getTourActivities().hasActivity(pickupShipment)); + assertFalse(route.getActivities().contains(pickupShipment)); SolutionPrinter.print(vrp, solution, SolutionPrinter.Print.VERBOSE); SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, new TransportDistance() { diff --git a/jsprit-core/src/test/java/com/graphhopper/jsprit/core/problem/VehicleRoutingProblemTest.java b/jsprit-core/src/test/java/com/graphhopper/jsprit/core/problem/VehicleRoutingProblemTest.java index be8eb6a0..b88cfefc 100644 --- a/jsprit-core/src/test/java/com/graphhopper/jsprit/core/problem/VehicleRoutingProblemTest.java +++ b/jsprit-core/src/test/java/com/graphhopper/jsprit/core/problem/VehicleRoutingProblemTest.java @@ -40,6 +40,7 @@ import java.util.Arrays; import java.util.Collection; import static org.junit.Assert.*; +import static org.junit.matchers.JUnitMatchers.hasItem; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -408,15 +409,17 @@ public class VehicleRoutingProblemTest { @Test public void whenAddingInitialRoute_locationOfVehicleMustBeMemorized() { + Location start = TestUtils.loc("start", Coordinate.newInstance(0, 1)); + Location end = Location.newInstance("end"); VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v") - .setStartLocation(TestUtils.loc("start", Coordinate.newInstance(0, 1))) - .setEndLocation(Location.newInstance("end")).build(); + .setStartLocation(start) + .setEndLocation(end).build(); VehicleRoute route = VehicleRoute.Builder.newInstance(vehicle, DriverImpl.noDriver()).build(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); vrpBuilder.addInitialVehicleRoute(route); VehicleRoutingProblem vrp = vrpBuilder.build(); - assertEquals(0., vrp.getLocations().getCoord("start").getX(), 0.01); - assertEquals(1., vrp.getLocations().getCoord("start").getY(), 0.01); + assertThat(vrp.getAllLocations(),hasItem(start)); + assertThat(vrp.getAllLocations(),hasItem(end)); } @Test diff --git a/jsprit-core/src/test/java/com/graphhopper/jsprit/core/problem/solution/route/VehicleRouteBuilderTest.java b/jsprit-core/src/test/java/com/graphhopper/jsprit/core/problem/solution/route/VehicleRouteBuilderTest.java index 372e32cb..9aec7547 100644 --- a/jsprit-core/src/test/java/com/graphhopper/jsprit/core/problem/solution/route/VehicleRouteBuilderTest.java +++ b/jsprit-core/src/test/java/com/graphhopper/jsprit/core/problem/solution/route/VehicleRouteBuilderTest.java @@ -178,29 +178,5 @@ public class VehicleRouteBuilderTest { } - @Test - public void whenSettingEndTime() { - Shipment s = mock(Shipment.class); - Shipment s2 = mock(Shipment.class); - Capacity capacity = Capacity.Builder.newInstance().build(); - when(s.getSize()).thenReturn(capacity); - when(s2.getSize()).thenReturn(capacity); - when(s2.getDeliveryLocation()).thenReturn(Location.Builder.newInstance().setId("delLoc").build()); - when(s2.getPickupTimeWindow()).thenReturn(TimeWindow.newInstance(0.,10.)); - when(s2.getDeliveryTimeWindow()).thenReturn(TimeWindow.newInstance(0.,10.)); - when(s.getPickupTimeWindow()).thenReturn(TimeWindow.newInstance(0., 10.)); - when(s.getDeliveryTimeWindow()).thenReturn(TimeWindow.newInstance(0.,10.)); - Vehicle vehicle = mock(Vehicle.class); - when(vehicle.isReturnToDepot()).thenReturn(false); - when(vehicle.getStartLocation()).thenReturn(Location.Builder.newInstance().setId("vehLoc").build()); - when(vehicle.getLatestArrival()).thenReturn(200.0); - VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(vehicle, mock(Driver.class)); - builder.addPickup(s); - builder.addPickup(s2); - builder.addDelivery(s); - builder.addDelivery(s2); - builder.setRouteEndArrivalTime(100.0); - VehicleRoute route = builder.build(); - assertEquals(100.0, route.getEnd().getArrTime(), 0.01); - } + } diff --git a/jsprit-core/src/test/java/com/graphhopper/jsprit/core/problem/solution/route/activity/EndTest.java b/jsprit-core/src/test/java/com/graphhopper/jsprit/core/problem/solution/route/activity/EndTest.java index 26021cb1..b0de85e9 100644 --- a/jsprit-core/src/test/java/com/graphhopper/jsprit/core/problem/solution/route/activity/EndTest.java +++ b/jsprit-core/src/test/java/com/graphhopper/jsprit/core/problem/solution/route/activity/EndTest.java @@ -48,12 +48,6 @@ public class EndTest { assertEquals(4., end.getEndTime(), 0.01); } - @Test - public void whenSettingLocationId_itShouldBeSetCorrectly() { - End end = End.newInstance("loc", 1., 2.); - end.setLocationId("newLoc"); - assertEquals("newLoc", end.getLocation().getId()); - } @Test public void whenSettingEarliestStart_itShouldBeSetCorrectly() { diff --git a/jsprit-core/src/test/java/com/graphhopper/jsprit/core/problem/solution/route/activity/StartTest.java b/jsprit-core/src/test/java/com/graphhopper/jsprit/core/problem/solution/route/activity/StartTest.java index 23eecb2f..4d3acad1 100644 --- a/jsprit-core/src/test/java/com/graphhopper/jsprit/core/problem/solution/route/activity/StartTest.java +++ b/jsprit-core/src/test/java/com/graphhopper/jsprit/core/problem/solution/route/activity/StartTest.java @@ -48,13 +48,6 @@ public class StartTest { assertEquals(4., start.getEndTime(), 0.01); } - @Test - public void whenSettingLocationId_itShouldBeSetCorrectly() { - Start start = Start.newInstance("loc", 1., 2.); - start.setLocationId("newLoc"); - assertEquals("newLoc", start.getLocation().getId()); - } - @Test public void whenSettingEarliestStart_itShouldBeSetCorrectly() { Start start = Start.newInstance("loc", 1., 2.); diff --git a/jsprit-core/src/test/java/com/graphhopper/jsprit/core/problem/solution/route/activity/TestTourActivities.java b/jsprit-core/src/test/java/com/graphhopper/jsprit/core/problem/solution/route/activity/TestTourActivities.java index 447eb2a0..f46dd17d 100644 --- a/jsprit-core/src/test/java/com/graphhopper/jsprit/core/problem/solution/route/activity/TestTourActivities.java +++ b/jsprit-core/src/test/java/com/graphhopper/jsprit/core/problem/solution/route/activity/TestTourActivities.java @@ -121,12 +121,12 @@ public class TestTourActivities { public void removingActivityShouldWork() { tour.addActivity(act); assertTrue(tour.servesJob(service)); - assertTrue(tour.hasActivity(act)); + assertTrue(tour.getActivities().contains(act)); tour.removeActivity(act); assertTrue(tour.isEmpty()); - assertFalse(tour.hasActivity(act)); + assertFalse(tour.getActivities().contains(act)); assertFalse(tour.servesJob(service)); assertEquals(0, tour.jobSize()); } @@ -136,12 +136,11 @@ public class TestTourActivities { tour.addActivity(act); assertTrue(tour.servesJob(service)); - assertTrue(tour.hasActivity(act)); TourActivities acts = TourActivities.copyOf(tour); assertTrue(acts.servesJob(service)); - assertTrue(acts.hasActivity(act)); + assertTrue(acts.getActivities().contains(act)); } @Test @@ -158,15 +157,15 @@ public class TestTourActivities { assertEquals(1, tour.jobSize()); assertEquals(2, tour.getActivities().size()); assertTrue(tour.getActivities().contains(pickupShipment)); - assertTrue(tour.hasActivity(pickupShipment)); - assertTrue(tour.hasActivity(deliverShipment)); + assertTrue(tour.getActivities().contains(pickupShipment)); + assertTrue(tour.getActivities().contains(deliverShipment)); tour.removeActivity(pickupShipment); assertEquals(1, tour.jobSize()); assertEquals(1, tour.getActivities().size()); - assertTrue(tour.hasActivity(deliverShipment)); - assertFalse(tour.hasActivity(pickupShipment)); + assertTrue(tour.getActivities().contains(deliverShipment)); + assertFalse(tour.getActivities().contains(pickupShipment)); assertFalse(tour.getActivities().contains(pickupShipment)); } @@ -185,8 +184,8 @@ public class TestTourActivities { assertEquals(1, tour.jobSize()); assertEquals(2, tour.getActivities().size()); assertTrue(tour.getActivities().contains(pickupShipment)); - assertTrue(tour.hasActivity(pickupShipment)); - assertTrue(tour.hasActivity(deliverShipment)); + assertTrue(tour.getActivities().contains(pickupShipment)); + assertTrue(tour.getActivities().contains(deliverShipment)); TourActivities copiedTour = TourActivities.copyOf(tour); @@ -206,8 +205,8 @@ public class TestTourActivities { assertEquals(1, tour.jobSize()); assertEquals(2, tour.getActivities().size()); assertTrue(tour.getActivities().contains(pickupShipment)); - assertTrue(tour.hasActivity(pickupShipment)); - assertTrue(tour.hasActivity(deliverShipment)); + assertTrue(tour.getActivities().contains(pickupShipment)); + assertTrue(tour.getActivities().contains(deliverShipment)); TourActivities copiedTour = TourActivities.copyOf(tour); @@ -227,8 +226,8 @@ public class TestTourActivities { assertEquals(1, tour.jobSize()); assertEquals(2, tour.getActivities().size()); assertTrue(tour.getActivities().contains(pickupShipment)); - assertTrue(tour.hasActivity(pickupShipment)); - assertTrue(tour.hasActivity(deliverShipment)); + assertTrue(tour.getActivities().contains(pickupShipment)); + assertTrue(tour.getActivities().contains(deliverShipment)); TourActivities copiedTour = TourActivities.copyOf(tour); diff --git a/jsprit-core/src/test/resources/infiniteWriterV2Test.xml b/jsprit-core/src/test/resources/infiniteWriterV2Test.xml index 2d9058ab..07c5406a 100644 --- a/jsprit-core/src/test/resources/infiniteWriterV2Test.xml +++ b/jsprit-core/src/test/resources/infiniteWriterV2Test.xml @@ -2,9 +2,24 @@ - INFINITE + FINITE + + v2 + vehType2 + + loc + + + loc + + + 0.0 + 1.7976931348623157E308 + + true + v1 vehType @@ -33,58 +48,16 @@ + + vehType2 + + 200 + + + 0.0 + 1.0 + + + - - - - loc - - - 1 - - 2.0 - - - 0.0 - 1.7976931348623157E308 - - - - - - loc2 - - - 1 - - 4.0 - - - 0.0 - 1.7976931348623157E308 - - - - - - - 10.0 - - - noDriver - v1 - 0.0 - - 1 - 0.0 - 0.0 - - 0.0 - - - - - - - diff --git a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/BreakExample.java b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/BreakExample.java index 6449f810..87dfffdb 100644 --- a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/BreakExample.java +++ b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/BreakExample.java @@ -60,6 +60,7 @@ public class BreakExample { vehicleBuilder.setType(vehicleType); VehicleImpl vehicle = vehicleBuilder.build(); + VehicleImpl v2 = VehicleImpl.Builder.newInstance("v2").setStartLocation(Location.newInstance(0, 10)).setType(vehicleType) .setBreak((Break) Break.Builder.newInstance("mySecondBreak").setTimeWindow(TimeWindow.newInstance(5, 10)).setServiceTime(10).build()).build(); /* diff --git a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/BuildAlgorithmFromScratch.java b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/BuildAlgorithmFromScratch.java index a2f290f2..10ec6ae1 100644 --- a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/BuildAlgorithmFromScratch.java +++ b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/BuildAlgorithmFromScratch.java @@ -37,6 +37,7 @@ import com.graphhopper.jsprit.core.analysis.SolutionAnalyser; import com.graphhopper.jsprit.core.problem.Location; import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem; import com.graphhopper.jsprit.core.problem.constraint.ConstraintManager; +import com.graphhopper.jsprit.core.problem.cost.TransportDistance; import com.graphhopper.jsprit.core.problem.job.Job; import com.graphhopper.jsprit.core.problem.solution.SolutionCostCalculator; import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution; @@ -203,7 +204,7 @@ public class BuildAlgorithmFromScratch { @Override public double getCosts(VehicleRoutingProblemSolution solution) { - SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, new SolutionAnalyser.DistanceCalculator() { + SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, new TransportDistance() { @Override public double getDistance(Location from, Location to) { return vrp.getTransportCosts().getTransportCost(from, to, 0., null, null); diff --git a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/PickupAndDeliveryExample.java b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/PickupAndDeliveryExample.java index 73ff5485..a1fcbfa9 100644 --- a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/PickupAndDeliveryExample.java +++ b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/PickupAndDeliveryExample.java @@ -25,6 +25,7 @@ import com.graphhopper.jsprit.core.algorithm.selector.SelectBest; import com.graphhopper.jsprit.core.analysis.SolutionAnalyser; import com.graphhopper.jsprit.core.problem.Location; import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem; +import com.graphhopper.jsprit.core.problem.cost.TransportDistance; import com.graphhopper.jsprit.core.problem.io.VrpXMLReader; import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution; import com.graphhopper.jsprit.core.reporting.SolutionPrinter; @@ -97,7 +98,7 @@ public class PickupAndDeliveryExample { plotter.plot("output/pd_solomon_r101_solution.png", "pd_r101"); //some stats - SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, new SolutionAnalyser.DistanceCalculator() { + SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, new TransportDistance() { @Override public double getDistance(Location from, Location to) { diff --git a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/VRPWithBackhaulsExample2.java b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/VRPWithBackhaulsExample2.java index c2adf04b..28bf71d4 100644 --- a/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/VRPWithBackhaulsExample2.java +++ b/jsprit-examples/src/main/java/com/graphhopper/jsprit/examples/VRPWithBackhaulsExample2.java @@ -28,6 +28,7 @@ import com.graphhopper.jsprit.core.problem.Location; import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem; import com.graphhopper.jsprit.core.problem.constraint.ConstraintManager; import com.graphhopper.jsprit.core.problem.constraint.ServiceDeliveriesFirstConstraint; +import com.graphhopper.jsprit.core.problem.cost.TransportDistance; import com.graphhopper.jsprit.core.problem.io.VrpXMLReader; import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution; import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute; @@ -122,7 +123,7 @@ public class VRPWithBackhaulsExample2 { // plotter.setLabel(Plotter.Label.SIZE); plotter.plot("output/vrpwbh_christophides_vrpnc1_solution.png", "vrpwbh_vrpnc1"); - SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, new SolutionAnalyser.DistanceCalculator() { + SolutionAnalyser analyser = new SolutionAnalyser(vrp, solution, new TransportDistance() { @Override public double getDistance(Location from, Location to) { diff --git a/jsprit-instances/src/main/java/com/graphhopper/jsprit/instance/reader/CordeauReader.java b/jsprit-instances/src/main/java/com/graphhopper/jsprit/instance/reader/CordeauReader.java index 2beb2b7a..919f948a 100644 --- a/jsprit-instances/src/main/java/com/graphhopper/jsprit/instance/reader/CordeauReader.java +++ b/jsprit-instances/src/main/java/com/graphhopper/jsprit/instance/reader/CordeauReader.java @@ -60,12 +60,6 @@ public class CordeauReader { this.vrpBuilder = vrpBuilder; } - @Deprecated - public CordeauReader(VehicleRoutingProblem.Builder vrpBuilder, boolean penaltyVehicles) { - super(); - this.vrpBuilder = vrpBuilder; - } - public void read(String fileName) { vrpBuilder.setFleetSize(FleetSize.FINITE); BufferedReader reader = getReader(fileName);