Print.CONCISE and Print.VERBOSE are available.
- *
- * @author stefan schroeder
- *
- */
- public enum Print {
-
- CONCISE,VERBOSE
- }
-
- /**
- * Prints costs and #vehicles to stdout (System.out.println).
- *
- * @param solution
- */
- public static void print(VehicleRoutingProblemSolution solution){
- System.out.println("[costs="+solution.getCost() + "]");
- System.out.println("[#vehicles="+solution.getRoutes().size() + "]");
-
- }
-
- /**
- * Prints the details of the solution according to a print-level, i.e. Print.CONCISE or PRINT.VERBOSE.
- *
- *
CONCISE prints total-costs and #vehicles.
- *
VERBOSE prints the route-details additionally. If the DefaultVehicleRouteCostCalculator (which is the standard-calculator)
- * is used in VehicleRoute, then route-costs are differentiated further between transport, activity, vehicle, driver and other-costs.
- *
- * @param solution
- * @param level
- *
- * @deprecated is not going to work anymore
- */
- @Deprecated
- public static void print(VehicleRoutingProblemSolution solution, Print level){
- if(level.equals(Print.CONCISE)){
- print(solution);
- }
- else{
- print(solution);
- System.out.println("routes");
- int routeCount = 1;
- for(VehicleRoute route : solution.getRoutes()){
- System.out.println("[route="+routeCount+"][departureTime="+route.getStart().getEndTime()+"[total=" + route.getCost() + "]");
- if(route.getVehicleRouteCostCalculator() instanceof DefaultVehicleRouteCostCalculator){
- DefaultVehicleRouteCostCalculator defaultCalc = (DefaultVehicleRouteCostCalculator) route.getVehicleRouteCostCalculator();
- System.out.println("[transport=" + defaultCalc.getTpCosts() + "][activity=" + defaultCalc.getActCosts() +
- "][vehicle=" + defaultCalc.getVehicleCosts() + "][driver=" + defaultCalc.getDriverCosts() + "][other=" + defaultCalc.getOther() + "]");
- }
- routeCount++;
- }
- }
-
-
- }
-
-}
diff --git a/jsprit-analysis/src/main/java/analysis/AlgorithmSearchProgressChartListener.java b/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/AlgorithmSearchProgressChartListener.java
similarity index 92%
rename from jsprit-analysis/src/main/java/analysis/AlgorithmSearchProgressChartListener.java
rename to jsprit-analysis/src/main/java/jsprit/analysis/toolbox/AlgorithmSearchProgressChartListener.java
index af7962d2..0a2a1d6e 100644
--- a/jsprit-analysis/src/main/java/analysis/AlgorithmSearchProgressChartListener.java
+++ b/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/AlgorithmSearchProgressChartListener.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package analysis;
+package jsprit.analysis.toolbox;
import java.io.File;
import java.io.IOException;
@@ -22,24 +22,24 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import jsprit.core.algorithm.VehicleRoutingAlgorithm;
+import jsprit.core.algorithm.listener.AlgorithmEndsListener;
+import jsprit.core.algorithm.listener.AlgorithmStartsListener;
+import jsprit.core.algorithm.listener.IterationEndsListener;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+
import org.apache.log4j.Logger;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
-import org.jfree.chart.axis.NumberTickUnit;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.Range;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
-import basics.VehicleRoutingAlgorithm;
-import basics.VehicleRoutingProblem;
-import basics.VehicleRoutingProblemSolution;
-import basics.algo.AlgorithmEndsListener;
-import basics.algo.AlgorithmStartsListener;
-import basics.algo.IterationEndsListener;
/**
@@ -77,6 +77,9 @@ public class AlgorithmSearchProgressChartListener implements IterationEndsListen
public AlgorithmSearchProgressChartListener(String pngFileName) {
super();
this.filename = pngFileName;
+ if(!this.filename.endsWith("png")){
+ this.filename += ".png";
+ }
}
diff --git a/jsprit-analysis/src/main/java/analysis/ConcurrentBenchmarker.java b/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/ConcurrentBenchmarker.java
similarity index 92%
rename from jsprit-analysis/src/main/java/analysis/ConcurrentBenchmarker.java
rename to jsprit-analysis/src/main/java/jsprit/analysis/toolbox/ConcurrentBenchmarker.java
index 8642074c..25a71439 100644
--- a/jsprit-analysis/src/main/java/analysis/ConcurrentBenchmarker.java
+++ b/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/ConcurrentBenchmarker.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package analysis;
+package jsprit.analysis.toolbox;
import java.util.ArrayList;
import java.util.Collection;
@@ -25,20 +25,21 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
+import jsprit.analysis.util.BenchmarkWriter;
+import jsprit.core.algorithm.VehicleRoutingAlgorithm;
+import jsprit.core.algorithm.VehicleRoutingAlgorithmFactory;
+import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
+import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners.Priority;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+import jsprit.core.util.BenchmarkInstance;
+import jsprit.core.util.BenchmarkResult;
+import jsprit.core.util.Solutions;
+
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
-import util.BenchmarkInstance;
-import util.BenchmarkResult;
-import util.BenchmarkWriter;
-import util.Solutions;
-import algorithms.VehicleRoutingAlgorithms;
-import basics.VehicleRoutingAlgorithm;
-import basics.VehicleRoutingProblem;
-import basics.VehicleRoutingProblemSolution;
-import basics.algo.VehicleRoutingAlgorithmFactory;
-import basics.algo.VehicleRoutingAlgorithmListeners.Priority;
public class ConcurrentBenchmarker {
diff --git a/jsprit-analysis/src/main/java/analysis/Plotter.java b/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/Plotter.java
similarity index 95%
rename from jsprit-analysis/src/main/java/analysis/Plotter.java
rename to jsprit-analysis/src/main/java/jsprit/analysis/toolbox/Plotter.java
index ff259b45..4e494bd1 100644
--- a/jsprit-analysis/src/main/java/analysis/Plotter.java
+++ b/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/Plotter.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package analysis;
+package jsprit.analysis.toolbox;
import java.awt.BasicStroke;
import java.awt.Color;
@@ -25,6 +25,19 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.job.Delivery;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.job.Pickup;
+import jsprit.core.problem.job.Service;
+import jsprit.core.problem.job.Shipment;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.solution.route.activity.TourActivity;
+import jsprit.core.problem.vehicle.Vehicle;
+import jsprit.core.util.Coordinate;
+import jsprit.core.util.Locations;
+
import org.apache.log4j.Logger;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
@@ -43,18 +56,6 @@ import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.ui.RectangleEdge;
-import util.Coordinate;
-import util.Locations;
-import basics.Delivery;
-import basics.Job;
-import basics.Pickup;
-import basics.Service;
-import basics.Shipment;
-import basics.VehicleRoutingProblem;
-import basics.VehicleRoutingProblemSolution;
-import basics.route.TourActivity;
-import basics.route.Vehicle;
-import basics.route.VehicleRoute;
public class Plotter {
@@ -80,8 +81,6 @@ public class Plotter {
private VehicleRoutingProblem vrp;
- private VehicleRoutingProblemSolution solution;
-
private boolean plotSolutionAsWell = false;
private boolean plotShipments = true;
@@ -116,11 +115,13 @@ public class Plotter {
}
public void plot(String pngFileName, String plotTitle){
+ String filename = pngFileName;
+ if(!pngFileName.endsWith(".png")) filename += ".png";
if(plotSolutionAsWell){
- plotSolutionAsPNG(vrp, routes, pngFileName, plotTitle);
+ plotSolutionAsPNG(vrp, routes, filename, plotTitle);
}
else{
- plotVrpAsPNG(vrp, pngFileName, plotTitle);
+ plotVrpAsPNG(vrp, filename, plotTitle);
}
}
diff --git a/jsprit-analysis/src/main/java/analysis/SolutionPlotter.java b/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/SolutionPlotter.java
similarity index 92%
rename from jsprit-analysis/src/main/java/analysis/SolutionPlotter.java
rename to jsprit-analysis/src/main/java/jsprit/analysis/toolbox/SolutionPlotter.java
index a66e84c2..141c8c22 100644
--- a/jsprit-analysis/src/main/java/analysis/SolutionPlotter.java
+++ b/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/SolutionPlotter.java
@@ -14,11 +14,9 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package analysis;
+package jsprit.analysis.toolbox;
-import java.awt.BasicStroke;
import java.awt.Color;
-import java.awt.geom.Ellipse2D;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
@@ -27,31 +25,29 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.job.Delivery;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.job.Pickup;
+import jsprit.core.problem.job.Service;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.solution.route.activity.TourActivity;
+import jsprit.core.problem.vehicle.Vehicle;
+import jsprit.core.util.Coordinate;
+import jsprit.core.util.Locations;
+
import org.apache.log4j.Logger;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
-import org.jfree.chart.annotations.XYShapeAnnotation;
import org.jfree.chart.axis.NumberAxis;
-import org.jfree.chart.labels.XYItemLabelGenerator;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.data.xy.XYDataItem;
-import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
-import util.Coordinate;
-import util.Locations;
-import basics.Delivery;
-import basics.Job;
-import basics.Pickup;
-import basics.Service;
-import basics.VehicleRoutingProblem;
-import basics.VehicleRoutingProblemSolution;
-import basics.route.TourActivity;
-import basics.route.Vehicle;
-import basics.route.VehicleRoute;
/**
@@ -82,7 +78,9 @@ public class SolutionPlotter {
* @see VehicleRoutingProblem, VehicleRoutingProblemSolution
*/
public static void plotVrpAsPNG(VehicleRoutingProblem vrp, String pngFile, String title){
- log.info("plot routes to " + pngFile);
+ String filename = pngFile;
+ if(!pngFile.endsWith(".png")) filename += ".png";
+ log.info("plot routes to " + filename);
XYSeriesCollection problem;
Map labels = new HashMap();
try {
@@ -93,7 +91,7 @@ public class SolutionPlotter {
}
XYPlot plot = createPlot(problem, labels);
JFreeChart chart = new JFreeChart(title, plot);
- save(chart,pngFile);
+ save(chart,filename);
}
/**
@@ -106,7 +104,9 @@ public class SolutionPlotter {
* @see VehicleRoute
*/
public static void plotRoutesAsPNG(Collection routes, Locations locations, String pngFile, String title) {
- log.info("plot routes to " + pngFile);
+ String filename = pngFile;
+ if(!pngFile.endsWith(".png")) filename += ".png";
+ log.info("plot routes to " + filename);
XYSeriesCollection problem;
Map labels = new HashMap();
try {
@@ -118,7 +118,7 @@ public class SolutionPlotter {
XYSeriesCollection solutionColl = makeSolutionSeries(routes,locations);
XYPlot plot = createPlot(problem, solutionColl, labels);
JFreeChart chart = new JFreeChart(title, plot);
- save(chart,pngFile);
+ save(chart,filename);
}
/**
@@ -133,7 +133,9 @@ public class SolutionPlotter {
* @see VehicleRoutingProblem, VehicleRoutingProblemSolution
*/
public static void plotSolutionAsPNG(VehicleRoutingProblem vrp, VehicleRoutingProblemSolution solution, String pngFile, String title){
- log.info("plot solution to " + pngFile);
+ String filename = pngFile;
+ if(!pngFile.endsWith(".png")) filename += ".png";
+ log.info("plot solution to " + filename);
XYSeriesCollection problem;
XYSeriesCollection solutionColl;
Map labels = new HashMap();
@@ -146,7 +148,7 @@ public class SolutionPlotter {
}
XYPlot plot = createPlot(problem, solutionColl, labels);
JFreeChart chart = new JFreeChart(title, plot);
- save(chart,pngFile);
+ save(chart,filename);
}
diff --git a/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/SolutionPrinter.java b/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/SolutionPrinter.java
new file mode 100644
index 00000000..01b5f750
--- /dev/null
+++ b/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/SolutionPrinter.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (C) 2013 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 jsprit.analysis.toolbox;
+
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+
+/**
+ * Printer to print the details of a vehicle-routing-problem solution.
+ *
+ * @author stefan schroeder
+ *
+ */
+public class SolutionPrinter {
+
+ /**
+ * Enum to indicate verbose-level.
+ *
+ *
Print.CONCISE and Print.VERBOSE are available.
+ *
+ * @author stefan schroeder
+ *
+ */
+ public enum Print {
+
+ CONCISE,VERBOSE
+ }
+
+ /**
+ * Prints costs and #vehicles to stdout (System.out.println).
+ *
+ * @param solution
+ */
+ public static void print(VehicleRoutingProblemSolution solution){
+ System.out.println("[costs="+solution.getCost() + "]");
+ System.out.println("[#vehicles="+solution.getRoutes().size() + "]");
+
+ }
+
+// /**
+// * Prints the details of the solution according to a print-level, i.e. Print.CONCISE or PRINT.VERBOSE.
+// *
+// *
CONCISE prints total-costs and #vehicles.
+// *
VERBOSE prints the route-details additionally. If the DefaultVehicleRouteCostCalculator (which is the standard-calculator)
+// * is used in VehicleRoute, then route-costs are differentiated further between transport, activity, vehicle, driver and other-costs.
+// *
+// * @param solution
+// * @param level
+// *
+// * @deprecated is not going to work anymore
+// */
+// @Deprecated
+// public static void print(VehicleRoutingProblemSolution solution, Print level){
+// if(level.equals(Print.CONCISE)){
+// print(solution);
+// }
+// else{
+// print(solution);
+// System.out.println("routes");
+// int routeCount = 1;
+// for(VehicleRoute route : solution.getRoutes()){
+// System.out.println("[route="+routeCount+"][departureTime="+route.getStart().getEndTime()+"[total=" + route.getCost() + "]");
+// if(route.getVehicleRouteCostCalculator() instanceof DefaultVehicleRouteCostCalculator){
+// DefaultVehicleRouteCostCalculator defaultCalc = (DefaultVehicleRouteCostCalculator) route.getVehicleRouteCostCalculator();
+// System.out.println("[transport=" + defaultCalc.getTpCosts() + "][activity=" + defaultCalc.getActCosts() +
+// "][vehicle=" + defaultCalc.getVehicleCosts() + "][driver=" + defaultCalc.getDriverCosts() + "][other=" + defaultCalc.getOther() + "]");
+// }
+// routeCount++;
+// }
+// }
+//
+//
+// }
+
+}
diff --git a/jsprit-analysis/src/main/java/analysis/StopWatch.java b/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/StopWatch.java
similarity index 86%
rename from jsprit-analysis/src/main/java/analysis/StopWatch.java
rename to jsprit-analysis/src/main/java/jsprit/analysis/toolbox/StopWatch.java
index 86f6314c..837d6581 100644
--- a/jsprit-analysis/src/main/java/analysis/StopWatch.java
+++ b/jsprit-analysis/src/main/java/jsprit/analysis/toolbox/StopWatch.java
@@ -14,17 +14,18 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package analysis;
+package jsprit.analysis.toolbox;
import java.util.Collection;
+import jsprit.core.algorithm.VehicleRoutingAlgorithm;
+import jsprit.core.algorithm.listener.AlgorithmEndsListener;
+import jsprit.core.algorithm.listener.AlgorithmStartsListener;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+
import org.apache.log4j.Logger;
-import basics.VehicleRoutingAlgorithm;
-import basics.VehicleRoutingProblem;
-import basics.VehicleRoutingProblemSolution;
-import basics.algo.AlgorithmEndsListener;
-import basics.algo.AlgorithmStartsListener;
public class StopWatch implements AlgorithmStartsListener, AlgorithmEndsListener{
diff --git a/jsprit-analysis/src/main/java/util/BenchmarkWriter.java b/jsprit-analysis/src/main/java/jsprit/analysis/util/BenchmarkWriter.java
similarity index 93%
rename from jsprit-analysis/src/main/java/util/BenchmarkWriter.java
rename to jsprit-analysis/src/main/java/jsprit/analysis/util/BenchmarkWriter.java
index a6e55c40..a4b2be2b 100644
--- a/jsprit-analysis/src/main/java/util/BenchmarkWriter.java
+++ b/jsprit-analysis/src/main/java/jsprit/analysis/util/BenchmarkWriter.java
@@ -14,10 +14,12 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package util;
+package jsprit.analysis.util;
import java.util.Collection;
+import jsprit.core.util.BenchmarkResult;
+
public interface BenchmarkWriter {
public void write(Collection results);
}
diff --git a/jsprit-analysis/src/main/java/util/HtmlBenchmarkTableWriter.java b/jsprit-analysis/src/main/java/jsprit/analysis/util/HtmlBenchmarkTableWriter.java
similarity index 99%
rename from jsprit-analysis/src/main/java/util/HtmlBenchmarkTableWriter.java
rename to jsprit-analysis/src/main/java/jsprit/analysis/util/HtmlBenchmarkTableWriter.java
index df8fce20..52dae708 100644
--- a/jsprit-analysis/src/main/java/util/HtmlBenchmarkTableWriter.java
+++ b/jsprit-analysis/src/main/java/jsprit/analysis/util/HtmlBenchmarkTableWriter.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package util;
+package jsprit.analysis.util;
import java.io.BufferedWriter;
import java.io.File;
@@ -22,6 +22,8 @@ import java.io.FileWriter;
import java.io.IOException;
import java.util.Collection;
+import jsprit.core.util.BenchmarkResult;
+
import org.jfree.chart.renderer.xy.DeviationRenderer;
public class HtmlBenchmarkTableWriter implements BenchmarkWriter{
diff --git a/jsprit-core/src/main/java/algorithms/BestInsertionStrategyFactory.java b/jsprit-core/src/main/java/algorithms/BestInsertionStrategyFactory.java
deleted file mode 100644
index beb92f46..00000000
--- a/jsprit-core/src/main/java/algorithms/BestInsertionStrategyFactory.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package algorithms;
-
-import basics.VehicleRoutingProblem;
-
-public class BestInsertionStrategyFactory implements InsertionStrategyFactory{
-
- private JobInsertionCostsCalculator jobInsertionCalculator;
-
- public BestInsertionStrategyFactory(JobInsertionCostsCalculator jobInsertionCalculator) {
- super();
- this.jobInsertionCalculator = jobInsertionCalculator;
- }
-
- @Override
- public InsertionStrategy createStrategy(VehicleRoutingProblem vrp) {
- return new BestInsertion(jobInsertionCalculator);
- }
-
-}
diff --git a/jsprit-core/src/main/java/algorithms/ConcurrentVehicleRoutingAlgorithmWrapper.java b/jsprit-core/src/main/java/algorithms/ConcurrentVehicleRoutingAlgorithmWrapper.java
deleted file mode 100644
index 54b83de2..00000000
--- a/jsprit-core/src/main/java/algorithms/ConcurrentVehicleRoutingAlgorithmWrapper.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package algorithms;
-
-public class ConcurrentVehicleRoutingAlgorithmWrapper {
-
-
- private int nuOfThreads;
-
- public ConcurrentVehicleRoutingAlgorithmWrapper(int nuOfThreads) {
- super();
- this.nuOfThreads = nuOfThreads;
- }
-
-
-
-}
diff --git a/jsprit-core/src/main/java/algorithms/FindCheaperVehicle.java b/jsprit-core/src/main/java/algorithms/FindCheaperVehicle.java
deleted file mode 100644
index e78d7847..00000000
--- a/jsprit-core/src/main/java/algorithms/FindCheaperVehicle.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 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 algorithms;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import basics.Job;
-import basics.algo.InsertionStartsListener;
-import basics.route.VehicleRoute;
-
-class FindCheaperVehicle implements InsertionStartsListener{
-
- FindCheaperVehicleAlgo findCheaperVehicle;
-
- public FindCheaperVehicle(FindCheaperVehicleAlgo findCheaperVehicle) {
- super();
- this.findCheaperVehicle = findCheaperVehicle;
- }
-
- @Override
- public void informInsertionStarts(Collection vehicleRoutes, Collection unassignedJobs) {
- List newRoutes = new ArrayList();
- for(VehicleRoute route : vehicleRoutes){
- if(route.isEmpty()) continue;
- VehicleRoute cheaperRoute = findCheaperVehicle.runAndGetVehicleRoute(route);
- newRoutes.add(cheaperRoute);
- }
- vehicleRoutes.clear();
- vehicleRoutes.addAll(newRoutes);
- }
-
- @Override
- public String toString() {
- return "[name=findCheaperVehicle]";
- }
-
-}
diff --git a/jsprit-core/src/main/java/algorithms/FindCheaperVehicleAlgo.java b/jsprit-core/src/main/java/algorithms/FindCheaperVehicleAlgo.java
deleted file mode 100644
index abbfb90a..00000000
--- a/jsprit-core/src/main/java/algorithms/FindCheaperVehicleAlgo.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 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 algorithms;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import basics.route.TourActivities;
-import basics.route.TourActivity;
-import basics.route.Vehicle;
-import basics.route.VehicleFleetManager;
-import basics.route.VehicleImpl.NoVehicle;
-import basics.route.VehicleRoute;
-
-
-
-final class FindCheaperVehicleAlgo {
-
- private static Logger log = Logger.getLogger(FindCheaperVehicleAlgo.class);
-
- private VehicleFleetManager fleetManager;
-
- private VehicleRouteUpdater tourStateCalculator;
-
- private AuxilliaryCostCalculator auxilliaryCostCalculator;
-
- private double weightFixCosts = 1.0;
-
- private StateGetter states;
-
- public void setWeightFixCosts(double weightFixCosts) {
- this.weightFixCosts = weightFixCosts;
- }
-
- public void setStates(StateGetter states) {
- this.states = states;
- }
-
- public FindCheaperVehicleAlgo(VehicleFleetManager fleetManager, VehicleRouteUpdater tourStateCalculator, AuxilliaryCostCalculator auxilliaryCostCalculator) {
- super();
- this.fleetManager = fleetManager;
- this.tourStateCalculator = tourStateCalculator;
- this.auxilliaryCostCalculator = auxilliaryCostCalculator;
- }
-
-
- public VehicleRoute runAndGetVehicleRoute(VehicleRoute vehicleRoute) {
- if(vehicleRoute.getVehicle() instanceof NoVehicle){
- return vehicleRoute;
- }
- if(vehicleRoute.getTourActivities() == null || vehicleRoute.getVehicle() == null){
- return vehicleRoute;
- }
-// Collection availableVehicleTypes = fleetManager.getAvailableVehicleTypes(new TypeKey(vehicleRoute.getVehicle().getType(),vehicleRoute.getVehicle().getLocationId()));
- double bestSaving = 0.0;
- Vehicle bestVehicle = null;
- List path = new ArrayList();
- path.add(vehicleRoute.getStart());
- path.addAll(vehicleRoute.getTourActivities().getActivities());
- path.add(vehicleRoute.getEnd());
-
- for(Vehicle vehicle : fleetManager.getAvailableVehicles(vehicleRoute.getVehicle().getType().getTypeId(), vehicleRoute.getVehicle().getLocationId())){
-// Vehicle vehicle = fleetManager.getEmptyVehicle(vehicleType);
- if(vehicle.getType().getTypeId().equals(vehicleRoute.getVehicle().getType().getTypeId())){
- continue;
- }
- if(states.getRouteState(vehicleRoute,StateFactory.LOAD).toDouble() <= vehicle.getCapacity()){
- double fixCostSaving = vehicleRoute.getVehicle().getType().getVehicleCostParams().fix - vehicle.getType().getVehicleCostParams().fix;
- double departureTime = vehicleRoute.getStart().getEndTime();
- double newCost = auxilliaryCostCalculator.costOfPath(path, departureTime, vehicleRoute.getDriver(), vehicle);
- double varCostSaving = states.getRouteState(vehicleRoute, StateFactory.COSTS).toDouble() - newCost;
- double totalCostSaving = varCostSaving + weightFixCosts*fixCostSaving;
- if(totalCostSaving > bestSaving){
- bestSaving = totalCostSaving;
- bestVehicle = vehicle;
- }
- }
- }
- if(bestVehicle != null){
- try{
- fleetManager.unlock(vehicleRoute.getVehicle());
- fleetManager.lock(bestVehicle);
- }
- catch(IllegalStateException e){
- throw new IllegalStateException(e);
- }
- TourActivities newTour = TourActivities.copyOf(vehicleRoute.getTourActivities());
- tourStateCalculator.iterate(vehicleRoute);
- return VehicleRoute.newInstance(newTour,vehicleRoute.getDriver(),bestVehicle);
- }
- return vehicleRoute;
- }
-
-}
diff --git a/jsprit-core/src/main/java/algorithms/Gendreau.java b/jsprit-core/src/main/java/algorithms/Gendreau.java
deleted file mode 100644
index 39de8fd1..00000000
--- a/jsprit-core/src/main/java/algorithms/Gendreau.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 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 algorithms;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Random;
-import java.util.Set;
-
-import org.apache.log4j.Logger;
-
-import util.RandomNumberGeneration;
-import basics.Job;
-import basics.VehicleRoutingProblem;
-import basics.VehicleRoutingProblemSolution;
-import basics.algo.InsertionListener;
-import basics.algo.RuinListener;
-import basics.algo.SearchStrategyModule;
-import basics.algo.SearchStrategyModuleListener;
-import basics.route.TourActivity;
-import basics.route.TourActivity.JobActivity;
-import basics.route.VehicleFleetManager;
-import basics.route.VehicleRoute;
-
-public final class Gendreau implements SearchStrategyModule{
-
- private final static Logger log = Logger.getLogger(Gendreau.class);
-
- private final static String NAME = "gendreauPostOpt";
-
- private final RuinStrategy ruin;
-
- private final VehicleRoutingProblem vrp;
-
- private final InsertionStrategy insertionStrategy;
-
- private VehicleFleetManager fleetManager;
-
- private Random random = RandomNumberGeneration.getRandom();
-
- private int nOfIterations = 10;
-
- private double shareOfJobsToRuin = 0.15;
-
- public void setShareOfJobsToRuin(double shareOfJobsToRuin) {
- this.shareOfJobsToRuin = shareOfJobsToRuin;
- }
-
- public Gendreau(VehicleRoutingProblem vrp, RuinStrategy ruin, InsertionStrategy insertionStrategy, VehicleFleetManager vehicleFleetManager) {
- super();
- InsertionListeners insertionListeners = new InsertionListeners();
- insertionListeners.addAllListeners(insertionStrategy.getListeners());
- new Inserter(insertionListeners);
- this.ruin = ruin;
- this.vrp = vrp;
- this.insertionStrategy = insertionStrategy;
- this.fleetManager = vehicleFleetManager;
- }
-
- @Override
- public String toString() {
- return "[name=gendreau][iterations="+nOfIterations+"][share2ruin="+shareOfJobsToRuin+"]";
- }
-
- public void setRandom(Random random) {
- this.random = random;
- }
-
-
- public void setNuOfIterations(int nOfIterations) {
- this.nOfIterations = nOfIterations;
- }
-
-// public void setFleetManager(VehicleFleetManager vehicleFleetManager) {
-// this.fleetManager = vehicleFleetManager;
-//
-// }
-
- @Override
- public VehicleRoutingProblemSolution runAndGetSolution(VehicleRoutingProblemSolution vrpSolution) {
-// log.info("run gendreau postopt");
- VehicleRoutingProblemSolution bestSolution = vrpSolution;
- int itersWithoutImprovement = 0;
-
- for(int i=0;i copiedRoutes = copyRoutes(bestSolution.getRoutes());
- iniFleet(copiedRoutes);
-
- VehicleRoute route2split = pickRouteThatHasAtLeastTwoJobs(copiedRoutes);
- if(route2split == null) continue;
- List jobsInRoute = getJobs(route2split);
- Set unassignedJobs = new HashSet();
- unassignedJobs.addAll(jobsInRoute);
- copiedRoutes.remove(route2split);
-
- Collections.shuffle(jobsInRoute,random);
- Job targetJob = jobsInRoute.get(0);
- int nOfJobs2BeRemovedAdditionally = (int) (shareOfJobsToRuin*(double)vrp.getJobs().size());
- Collection unassignedJobsList = ruin.ruin(copiedRoutes, targetJob, nOfJobs2BeRemovedAdditionally);
- unassignedJobs.addAll(unassignedJobsList);
-
- VehicleRoute emptyRoute1 = VehicleRoute.emptyRoute();
- copiedRoutes.add(emptyRoute1);
- insertionStrategy.insertJobs(Arrays.asList(emptyRoute1), Arrays.asList(targetJob));
-
- unassignedJobs.remove(targetJob);
-
- VehicleRoute emptyRoute2 = VehicleRoute.emptyRoute();
- copiedRoutes.add(emptyRoute2);
- Job job2 = jobsInRoute.get(1);
- insertionStrategy.insertJobs(Arrays.asList(emptyRoute2), Arrays.asList(job2));
-
- unassignedJobs.remove(job2);
-
- insertionStrategy.insertJobs(copiedRoutes, unassignedJobs);
- double cost = getCost(copiedRoutes);
-
- if(cost < bestSolution.getCost()){
-// log.info("BING - new: " + cost + " old: " + bestSolution.getCost());
- bestSolution = new VehicleRoutingProblemSolution(copiedRoutes, cost);
- itersWithoutImprovement=0;
- }
- else{
- itersWithoutImprovement++;
- if(itersWithoutImprovement > 200){
-// log.info("BREAK i="+i);
- break;
- }
- }
- }
- return bestSolution;
- }
-
- private List copyRoutes(Collection routes) {
- List routeList = new ArrayList();
- for(VehicleRoute r : routes){
- routeList.add(VehicleRoute.copyOf(r));
- }
- return routeList;
- }
-
- private void iniFleet(Collection routes) {
- fleetManager.unlockAll();
- for(VehicleRoute route : routes){
- if(!route.isEmpty()){
- fleetManager.lock(route.getVehicle());
- }
- }
- }
-
- private double getCost(Collection routes) {
- double c = 0.0;
- for(VehicleRoute r : routes){
- c+=r.getCost();
- }
- return c;
- }
-
- private List getJobs(VehicleRoute route2split) {
- Set jobs = new HashSet();
- for(TourActivity act : route2split.getTourActivities().getActivities()){
- if(act instanceof JobActivity){
- jobs.add(((JobActivity) act).getJob());
- }
- }
- return new ArrayList(jobs);
- }
-
- private VehicleRoute pickRouteThatHasAtLeastTwoJobs(Collection routeList) {
- List routes = new ArrayList();
- for(VehicleRoute r : routeList){
- if(getJobs(r).size() > 1){
- routes.add(r);
- }
- }
- if(routes.isEmpty()) return null;
- Collections.shuffle(routes,random);
- return routes.get(0);
- }
-
- @Override
- public String getName() {
- return NAME;
- }
-
- @Override
- public void addModuleListener(SearchStrategyModuleListener moduleListener) {
- if(moduleListener instanceof InsertionListener){
- InsertionListener iListener = (InsertionListener) moduleListener;
- if(!insertionStrategy.getListeners().contains(iListener)){
- insertionStrategy.addListener(iListener);
- }
- }
- if(moduleListener instanceof RuinListener){
- RuinListener rListener = (RuinListener) moduleListener;
- if(!ruin.getListeners().contains(rListener)){
- ruin.addListener(rListener);
- }
- }
-
- }
-}
diff --git a/jsprit-core/src/main/java/algorithms/HardActivityStateLevelConstraint.java b/jsprit-core/src/main/java/algorithms/HardActivityStateLevelConstraint.java
deleted file mode 100644
index ed0147cf..00000000
--- a/jsprit-core/src/main/java/algorithms/HardActivityStateLevelConstraint.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package algorithms;
-
-import basics.route.TourActivity;
-
-public interface HardActivityStateLevelConstraint {
-
- static enum ConstraintsStatus {
-
- NOT_FULFILLED_BREAK, NOT_FULFILLED, FULFILLED;
-
- }
-
- public ConstraintsStatus fulfilled(InsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime);
-
-}
\ No newline at end of file
diff --git a/jsprit-core/src/main/java/algorithms/HardRouteStateLevelConstraint.java b/jsprit-core/src/main/java/algorithms/HardRouteStateLevelConstraint.java
deleted file mode 100644
index 0f414f1d..00000000
--- a/jsprit-core/src/main/java/algorithms/HardRouteStateLevelConstraint.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package algorithms;
-
-
-public interface HardRouteStateLevelConstraint {
-
- public boolean fulfilled(InsertionContext insertionContext);
-
-}
\ No newline at end of file
diff --git a/jsprit-core/src/main/java/algorithms/JobDistanceBeeline.java b/jsprit-core/src/main/java/algorithms/JobDistanceBeeline.java
deleted file mode 100644
index f4287639..00000000
--- a/jsprit-core/src/main/java/algorithms/JobDistanceBeeline.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 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 algorithms;
-
-import util.CrowFlyCosts;
-import util.Locations;
-import basics.Job;
-import basics.Service;
-
-
-
-class JobDistanceBeeline implements JobDistance {
-
- private Locations locations;
-
- public JobDistanceBeeline(Locations locations) {
- super();
- this.locations = locations;
- }
-
- @Override
- public double getDistance(Job i, Job j) {
- double avgCost = 0.0;
- if (i instanceof Service && j instanceof Service) {
- if (i.equals(j)) {
- avgCost = 0.0;
- } else {
- Service s_i = (Service) i;
- Service s_j = (Service) j;
- avgCost = calcDist(s_i.getLocationId(), s_j.getLocationId());
- }
- } else {
- throw new UnsupportedOperationException(
- "currently, this class just works with shipments and services.");
- }
- return avgCost;
- }
-
- private double calcDist(String from, String to) {
- return new CrowFlyCosts(locations).getTransportCost(from, to, 0.0,null, null);
- }
-
-}
diff --git a/jsprit-core/src/main/java/algorithms/ScoredJob.java b/jsprit-core/src/main/java/algorithms/ScoredJob.java
deleted file mode 100644
index d7519673..00000000
--- a/jsprit-core/src/main/java/algorithms/ScoredJob.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 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 algorithms;
-
-import basics.Job;
-import basics.route.VehicleRoute;
-
-
-
-class ScoredJob {
-
- private final Job job;
-
- private final double score;
-
- private final InsertionData insertionData;
-
- private final VehicleRoute route;
-
- public ScoredJob(final Job job, final double score, final InsertionData insertionData, final VehicleRoute route) {
- super();
- this.job = job;
- this.score = score;
- this.insertionData = insertionData;
- this.route = route;
- }
-
- public InsertionData getInsertionData() {
- return insertionData;
- }
-
- public VehicleRoute getRoute() {
- return route;
- }
-
- public Job getJob() {
- return job;
- }
-
- public double getScore() {
- return score;
- }
-
-
-}
diff --git a/jsprit-core/src/main/java/algorithms/ShipmentPickupsFirstConstraint.java b/jsprit-core/src/main/java/algorithms/ShipmentPickupsFirstConstraint.java
deleted file mode 100644
index 971f3e27..00000000
--- a/jsprit-core/src/main/java/algorithms/ShipmentPickupsFirstConstraint.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package algorithms;
-
-import basics.route.DeliverShipment;
-import basics.route.PickupShipment;
-import basics.route.TourActivity;
-
-public class ShipmentPickupsFirstConstraint implements HardActivityStateLevelConstraint {
-
- @Override
- public ConstraintsStatus fulfilled(InsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
- if(newAct instanceof DeliverShipment && nextAct instanceof PickupShipment){ return ConstraintsStatus.NOT_FULFILLED; }
- if(newAct instanceof PickupShipment && prevAct instanceof DeliverShipment){ return ConstraintsStatus.NOT_FULFILLED_BREAK; }
- return ConstraintsStatus.FULFILLED;
- }
-
-}
\ No newline at end of file
diff --git a/jsprit-core/src/main/java/algorithms/StateUpdater.java b/jsprit-core/src/main/java/algorithms/StateUpdater.java
deleted file mode 100644
index 9fd80a19..00000000
--- a/jsprit-core/src/main/java/algorithms/StateUpdater.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package algorithms;
-
-public interface StateUpdater {
-
-}
diff --git a/jsprit-core/src/main/java/algorithms/UpdateEarliestStartTime.java b/jsprit-core/src/main/java/algorithms/UpdateEarliestStartTime.java
deleted file mode 100644
index 8faa8f08..00000000
--- a/jsprit-core/src/main/java/algorithms/UpdateEarliestStartTime.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package algorithms;
-
-import util.ActivityTimeTracker;
-import algorithms.StateManager.StateImpl;
-import basics.costs.VehicleRoutingTransportCosts;
-import basics.route.ActivityVisitor;
-import basics.route.TourActivity;
-import basics.route.VehicleRoute;
-
-class UpdateEarliestStartTime implements ActivityVisitor,StateUpdater{
-
- private StateManager states;
-
- private ActivityTimeTracker timeTracker;
-
- public UpdateEarliestStartTime(StateManager states, VehicleRoutingTransportCosts transportCosts) {
- super();
- this.states = states;
- timeTracker = new ActivityTimeTracker(transportCosts);
- }
-
- @Override
- public void begin(VehicleRoute route) {
- timeTracker.begin(route);
- }
-
- @Override
- public void visit(TourActivity activity) {
- timeTracker.visit(activity);
- states.putActivityState(activity, StateFactory.EARLIEST_OPERATION_START_TIME, new StateImpl(Math.max(timeTracker.getActArrTime(), activity.getTheoreticalEarliestOperationStartTime())));
-
- }
-
- @Override
- public void finish() {}
-
-}
\ No newline at end of file
diff --git a/jsprit-core/src/main/java/algorithms/VehicleRouteUpdater.java b/jsprit-core/src/main/java/algorithms/VehicleRouteUpdater.java
deleted file mode 100644
index 869db6cf..00000000
--- a/jsprit-core/src/main/java/algorithms/VehicleRouteUpdater.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 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 algorithms;
-
-import basics.route.VehicleRoute;
-
-
-/**
- * Updater that updates a vehicleRoute, e.g. the total costs or the time-windows.
- *
- * @author stefan schroeder
- *
- */
-
-interface VehicleRouteUpdater {
-
- public void iterate(VehicleRoute vehicleRoute);
-
-}
diff --git a/jsprit-core/src/main/java/algorithms/VehicleRoutingAlgorithmFactoryImpl.java b/jsprit-core/src/main/java/algorithms/VehicleRoutingAlgorithmFactoryImpl.java
deleted file mode 100644
index 35e5a96f..00000000
--- a/jsprit-core/src/main/java/algorithms/VehicleRoutingAlgorithmFactoryImpl.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package algorithms;
-
-import basics.VehicleRoutingAlgorithm;
-import basics.VehicleRoutingProblem;
-import basics.algo.SearchStrategyManager;
-import basics.algo.VehicleRoutingAlgorithmFactory;
-import basics.route.VehicleFleetManager;
-
-public class VehicleRoutingAlgorithmFactoryImpl implements VehicleRoutingAlgorithmFactory{
-
- private SearchStrategyManager searchStrategyManager;
-
- private StateManager stateManager;
-
- private VehicleFleetManager fleetManager;
-
- public VehicleRoutingAlgorithmFactoryImpl(SearchStrategyManager searchStrategyManager,
- StateManager stateManager, VehicleFleetManager fleetManager) {
- super();
- this.searchStrategyManager = searchStrategyManager;
- this.stateManager = stateManager;
- this.fleetManager = fleetManager;
- }
-
- @Override
- public VehicleRoutingAlgorithm createAlgorithm(VehicleRoutingProblem vrp) {
- this.stateManager.addActivityVisitor(new UpdateVariableCosts(vrp.getActivityCosts(), vrp.getTransportCosts(), this.stateManager));
-//<<<<<<< HEAD
-// this.stateManager.addActivityVisitor(new UpdateMaxLoad(this.stateManager));
- this.stateManager.addActivityVisitor(new UpdateActivityTimes(vrp.getTransportCosts()));
-//=======
-//// this.stateManager.addActivityVisitor(new UpdateMaxLoad_(this.stateManager));
-//>>>>>>> refs/heads/pickupAndDelivery
- VehicleRoutingAlgorithm algorithm = new VehicleRoutingAlgorithm(vrp, searchStrategyManager);
- algorithm.getAlgorithmListeners().addListener(stateManager);
- algorithm.getSearchStrategyManager().addSearchStrategyModuleListener(stateManager);
- algorithm.getSearchStrategyManager().addSearchStrategyModuleListener(new RemoveEmptyVehicles(fleetManager));
- return algorithm;
- }
-
-}
diff --git a/jsprit-core/src/main/java/basics/algo/InsertionListeners.java b/jsprit-core/src/main/java/basics/algo/InsertionListeners.java
deleted file mode 100644
index 821f166d..00000000
--- a/jsprit-core/src/main/java/basics/algo/InsertionListeners.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package basics.algo;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import basics.Job;
-import basics.route.VehicleRoute;
-
-public class InsertionListeners {
-
- private Collection startListeners = new ArrayList();
-
- private Collection jobInsertedListeners = new ArrayList();
-
- private Collection endListeners = new ArrayList();
-
- public void addListener(InsertionListener insertionListener){
- if(insertionListener instanceof InsertionStartsListener) startListeners.add((InsertionStartsListener) insertionListener);
- if(insertionListener instanceof JobInsertedListener) jobInsertedListeners.add((JobInsertedListener) insertionListener);
- if(insertionListener instanceof InsertionEndsListener) endListeners.add((InsertionEndsListener) insertionListener);
-// else throw new IllegalStateException("cannot add this type of insertionListener");
- }
-
- public void removeListener(InsertionListener insertionListener){
- if(insertionListener instanceof InsertionStartsListener) startListeners.remove((InsertionStartsListener) insertionListener);
- if(insertionListener instanceof JobInsertedListener) jobInsertedListeners.remove((JobInsertedListener) insertionListener);
- if(insertionListener instanceof InsertionEndsListener) endListeners.remove((InsertionEndsListener) insertionListener);
-// else throw new IllegalStateException("cannot remove this type of insertionListener");
- }
-
- public void insertionStarts(Collection vehicleRoutes, Collection unassignedJobs){
- for(InsertionStartsListener l : startListeners) l.informInsertionStarts(vehicleRoutes, unassignedJobs);
- }
-
- public void jobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime){
- for(JobInsertedListener l : jobInsertedListeners) l.informJobInserted(job2insert, inRoute, additionalCosts, additionalTime);
- }
-
- public void insertionEnds(Collection vehicleRoutes){
- for(InsertionEndsListener l : endListeners){ l.informInsertionEnds(vehicleRoutes); }
- }
-}
diff --git a/jsprit-core/src/main/java/basics/costs/DefaultVehicleRoutingActivityCosts.java b/jsprit-core/src/main/java/basics/costs/DefaultVehicleRoutingActivityCosts.java
deleted file mode 100644
index f9a91b4b..00000000
--- a/jsprit-core/src/main/java/basics/costs/DefaultVehicleRoutingActivityCosts.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 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 basics.costs;
-
-import basics.route.Driver;
-import basics.route.TourActivity;
-import basics.route.Vehicle;
-
-
-/**
- * DefaultActivityCosts = 0.0, i.e. activities do not induce costs at all.
- *
- * @author schroeder
- *
- */
-public class DefaultVehicleRoutingActivityCosts implements VehicleRoutingActivityCosts{
-
- @Override
- public double getActivityCost(TourActivity tourAct, double arrivalTime, Driver driver, Vehicle vehicle) {
- return 0;
- }
-
- @Override
- public String toString() {
- return "[name=defaultActivityCosts]";
- }
-
-}
diff --git a/jsprit-core/src/main/java/basics/route/DefaultVehicleRouteCostCalculator.java b/jsprit-core/src/main/java/basics/route/DefaultVehicleRouteCostCalculator.java
deleted file mode 100644
index c388630c..00000000
--- a/jsprit-core/src/main/java/basics/route/DefaultVehicleRouteCostCalculator.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 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 basics.route;
-
-
-
-public class DefaultVehicleRouteCostCalculator implements VehicleRouteCostCalculator {
-
- private double tpCosts = 0.0;
- private double actCosts = 0.0;
- private double vehicleCosts = 0.0;
- private double driverCosts = 0.0;
- private double other = 0.0;
-
- public DefaultVehicleRouteCostCalculator(){}
-
- private DefaultVehicleRouteCostCalculator(DefaultVehicleRouteCostCalculator costCalc){
- this.tpCosts=costCalc.getTpCosts();
- this.actCosts = costCalc.getActCosts();
- this.driverCosts = costCalc.getDriverCosts();
- this.other = costCalc.getOther();
- this.vehicleCosts = costCalc.getVehicleCosts();
- }
-
- public void addTransportCost(double tpCost) {
- this.tpCosts+=tpCost;
- }
-
- public void addActivityCost(double actCost){
- this.actCosts+=actCost;
- }
-
- public void price(Vehicle vehicle){
- if(vehicle != null){
- VehicleType type = vehicle.getType();
- if(type != null){
- this.vehicleCosts = type.getVehicleCostParams().fix;
- }
- }
- }
-
- public void price(Driver driver){
-
- }
-
- @Override
- public void finish() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void reset() {
- tpCosts = 0.0;
- actCosts = 0.0;
- vehicleCosts = 0.0;
- driverCosts = 0.0;
- other = 0.0;
- }
-
- @Override
- public void addOtherCost(double cost) {
- this.other = cost;
-
- }
-
- @Override
- public double getCosts() {
- return tpCosts + actCosts + vehicleCosts + driverCosts + other;
- }
-
- /**
- * @return the tpCosts
- */
- public double getTpCosts() {
- return tpCosts;
- }
-
- /**
- * @return the actCosts
- */
- public double getActCosts() {
- return actCosts;
- }
-
- /**
- * @return the vehicleCosts
- */
- public double getVehicleCosts() {
- return vehicleCosts;
- }
-
- /**
- * @return the driverCosts
- */
- public double getDriverCosts() {
- return driverCosts;
- }
-
- /**
- * @return the other
- */
- public double getOther() {
- return other;
- }
-
- @Override
- public VehicleRouteCostCalculator duplicate() {
- return new DefaultVehicleRouteCostCalculator(this);
- }
-
-
-
-}
diff --git a/jsprit-core/src/main/java/basics/route/VehicleRoute.java b/jsprit-core/src/main/java/basics/route/VehicleRoute.java
deleted file mode 100644
index 865f3aa3..00000000
--- a/jsprit-core/src/main/java/basics/route/VehicleRoute.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 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 basics.route;
-
-import basics.route.VehicleImpl.NoVehicle;
-
-public class VehicleRoute {
-
- public static VehicleRoute copyOf(VehicleRoute route) {
- return new VehicleRoute(route);
- }
-
- public static VehicleRoute newInstance(TourActivities tour, Driver driver, Vehicle vehicle) {
- return new VehicleRoute(tour,driver,vehicle);
- }
-
- public static VehicleRoute emptyRoute() {
- return new VehicleRoute(TourActivities.emptyTour(), DriverImpl.noDriver(), VehicleImpl.noVehicle());
- }
-
- public static class Builder {
-
- public static Builder newInstance(Start start, End end){
- return new Builder(start,end);
- }
-
- private Start start;
-
- private End end;
-
- private Vehicle vehicle = VehicleImpl.noVehicle();
-
- private Driver driver = DriverImpl.noDriver();
-
- private TourActivities tour;
-
- private Builder(Start start, End end) {
- super();
- this.start = start;
- this.end = end;
- this.tour = TourActivities.emptyTour();
- }
-
- public Builder setVehicle(Vehicle vehicle){
- this.vehicle = vehicle;
- return this;
- }
-
- public Builder setDriver(Driver driver){
- this.driver = driver;
- return this;
- }
-
- public Builder addActivity(TourActivity act){
- if(act instanceof Start || act instanceof End){
- throw new IllegalStateException("tourActivity should be of type Delivery or Pickup, but is of type " + act.getName());
- }
- tour.addActivity(act);
- return this;
- }
-
- public VehicleRoute build(){
- return new VehicleRoute(this);
- }
- }
-
- private TourActivities tourActivities;
-
- private Vehicle vehicle;
-
- private Driver driver;
-
- private Start start;
-
- private End end;
-
- @Deprecated
- private VehicleRouteCostCalculator costCalculator = new DefaultVehicleRouteCostCalculator();
-
- @Deprecated
- public VehicleRouteCostCalculator getVehicleRouteCostCalculator(){
- return costCalculator;
- }
-
- private VehicleRoute(VehicleRoute route){
- this.start = Start.copyOf(route.getStart());
- this.end = End.copyOf(route.getEnd());
- this.tourActivities = TourActivities.copyOf(route.getTourActivities());
- this.vehicle = route.getVehicle();
- this.driver = route.getDriver();
- this.costCalculator = route.getVehicleRouteCostCalculator().duplicate();
- }
-
- private VehicleRoute(TourActivities tour, Driver driver, Vehicle vehicle) {
- super();
- verify(tour, driver, vehicle);
- this.tourActivities = tour;
- this.vehicle = vehicle;
- this.driver = driver;
- setStartAndEnd(vehicle, vehicle.getEarliestDeparture());
- }
-
- private VehicleRoute(Builder builder){
- this.tourActivities = builder.tour;
- this.vehicle = builder.vehicle;
- this.driver = builder.driver;
- this.start = builder.start;
- this.end = builder.end;
- }
-
- private void verify(TourActivities tour, Driver driver, Vehicle vehicle) {
- if(tour == null || driver == null || vehicle == null) throw new IllegalStateException("null is not allowed for tour, driver or vehicle. use emptyRoute. use Tour.emptyTour, DriverImpl.noDriver() and VehicleImpl.noVehicle() instead." +
- "\n\tor make it easier and use VehicleRoute.emptyRoute()");
- if(!tour.isEmpty() && vehicle instanceof NoVehicle){
- throw new IllegalStateException("if tour is not empty. there must be a vehicle for this tour, but there is no vehicle.");
- }
- }
-
- public TourActivities getTourActivities() {
- return tourActivities;
- }
-
-
- public Vehicle getVehicle() {
- return vehicle;
- }
-
- public Driver getDriver() {
- return driver;
- }
-
- public void setVehicle(Vehicle vehicle, double vehicleDepTime){
- this.vehicle = vehicle;
- setStartAndEnd(vehicle, vehicleDepTime);
- }
-
- public void setDepartureTime(double vehicleDepTime){
- if(start == null) throw new IllegalStateException("cannot set departureTime without having a vehicle on this route. use setVehicle(vehicle,departureTime) instead.");
- start.setEndTime(vehicleDepTime);
- }
-
- public double getDepartureTime(){
- if(start == null) throw new IllegalStateException("cannot get departureTime without having a vehicle on this route. use setVehicle(vehicle,departureTime) instead.");
- return start.getEndTime();
- }
-
- private void setStartAndEnd(Vehicle vehicle, double vehicleDepTime) {
- if(!(vehicle instanceof NoVehicle)){
- if(start == null && end == null){
- start = Start.newInstance(vehicle.getLocationId(), vehicle.getEarliestDeparture(), vehicle.getLatestArrival());
- end = End.newInstance(vehicle.getLocationId(), vehicle.getEarliestDeparture(), vehicle.getLatestArrival());
- }
- start.setEndTime(vehicleDepTime);
- start.setTheoreticalEarliestOperationStartTime(vehicle.getEarliestDeparture());
- start.setTheoreticalLatestOperationStartTime(vehicle.getLatestArrival());
- start.setLocationId(vehicle.getLocationId());
- end.setLocationId(vehicle.getLocationId());
- end.setTheoreticalEarliestOperationStartTime(vehicle.getEarliestDeparture());
- end.setTheoreticalLatestOperationStartTime(vehicle.getLatestArrival());
- }
-
- }
-
-
- public boolean isEmpty() {
- return tourActivities.isEmpty();
- }
-
- public Start getStart() {
- return start;
- }
-
- public End getEnd() {
- return end;
- }
-
- @Override
- public String toString() {
- return "[start="+start+"][end=" + end + "][departureTime=" + start.getEndTime() + "][vehicle=" + vehicle + "][driver=" + driver + "][nuOfActs="+tourActivities.getActivities().size()+"]";
- }
-
- @Deprecated
- public void setVehicleRouteCostCalculator(VehicleRouteCostCalculator costAccumulator){
- this.costCalculator = costAccumulator;
- }
-
- @Deprecated
- public double getCost() {
- if(tourActivities.isEmpty()){
- return 0.0;
- }
- return costCalculator.getCosts();
- }
-
-}
diff --git a/jsprit-core/src/main/java/basics/route/VehicleRouteBuilder.java b/jsprit-core/src/main/java/basics/route/VehicleRouteBuilder.java
deleted file mode 100644
index 9c2bb4f7..00000000
--- a/jsprit-core/src/main/java/basics/route/VehicleRouteBuilder.java
+++ /dev/null
@@ -1,151 +0,0 @@
-package basics.route;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import basics.Service;
-import basics.Shipment;
-
-/**
- * Builds a {@link VehicleRoute}.
- *
- * @author schroeder
- *
- */
-public class VehicleRouteBuilder {
-
- private Vehicle vehicle;
-
- private Driver driver;
-
- private Start start;
-
- private TourActivities tourActivities = new TourActivities();
-
- private TourActivityFactory serviceActivityFactory = new DefaultTourActivityFactory();
-
- private TourShipmentActivityFactory shipmentActivityFactory = new DefaultShipmentActivityFactory();
-
- private Set openShipments = new HashSet();
-
- public void setServiceActivityFactory(TourActivityFactory serviceActivityFactory) {
- this.serviceActivityFactory = serviceActivityFactory;
- }
-
- public void setShipmentActivityFactory(TourShipmentActivityFactory shipmentActivityFactory) {
- this.shipmentActivityFactory = shipmentActivityFactory;
- }
-
- /**
- * Constructs the route-builder.
- * @param vehicle
- * @param driver
- */
- public VehicleRouteBuilder(Vehicle vehicle, Driver driver) {
- super();
- this.vehicle = vehicle;
- this.driver = driver;
- start = Start.newInstance(vehicle.getLocationId(), vehicle.getEarliestDeparture(), vehicle.getLatestArrival());
- start.setEndTime(vehicle.getEarliestDeparture());
- End.newInstance(vehicle.getLocationId(), vehicle.getEarliestDeparture(), vehicle.getLatestArrival());
- }
-
- /**
- * Sets the departure-time of the route.
- *
- * @param departureTime
- * @return
- */
- public VehicleRouteBuilder setDepartureTime(double departureTime){
- start.setEndTime(departureTime);
- return this;
- }
-
- public VehicleRouteBuilder addService(Service service){
- addService(service,0.0,0.0);
- return this;
- }
-
- public VehicleRouteBuilder addService(Service service, double arrTime, double endTime){
- TourActivity act = serviceActivityFactory.createActivity(service);
- act.setArrTime(arrTime);
- act.setEndTime(endTime);
- tourActivities.addActivity(act);
- return this;
- }
-
- /**
- * Adds a the pickup of the specified shipment.
- *
- * @param shipment
- * @throws IllegalStateException if method has already been called with the specified shipment.
- * @return
- */
- public VehicleRouteBuilder addPickup(Shipment shipment){
- addPickup(shipment,0.0,0.0);
- return this;
- }
-
- /**
- * Adds a the pickup of the specified shipment at specified arrival and end-time.
- *
- * @param shipment
- * @throws IllegalStateException if method has already been called with the specified shipment.
- * @return
- */
- public VehicleRouteBuilder addPickup(Shipment shipment, double arrTime, double endTime){
- if(openShipments.contains(shipment)) throw new IllegalStateException("shipment has already been added. cannot add it twice.");
- TourActivity act = shipmentActivityFactory.createPickup(shipment);
- act.setArrTime(arrTime);
- act.setEndTime(endTime);
- tourActivities.addActivity(act);
- openShipments.add(shipment);
- return this;
- }
-
- /**
- * Adds a the delivery of the specified shipment.
- *
- * @param shipment
- * @throws IllegalStateException if specified shipment has not been picked up yet (i.e. method addPickup(shipment) has not been called yet).
- * @return
- */
- public VehicleRouteBuilder addDelivery(Shipment shipment){
- addDelivery(shipment,0.0,0.0);
- return this;
- }
-
- /**
- * Adds a the delivery of the specified shipment at a specified arrival and endTime.
- *
- * @param shipment
- * @throws IllegalStateException if specified shipment has not been picked up yet (i.e. method addPickup(shipment) has not been called yet).
- * @return
- */
- public VehicleRouteBuilder addDelivery(Shipment shipment, double arrTime, double endTime){
- if(openShipments.contains(shipment)){
- TourActivity act = shipmentActivityFactory.createDelivery(shipment);
- act.setArrTime(arrTime);
- act.setEndTime(endTime);
- tourActivities.addActivity(act);
- openShipments.remove(shipment);
- }
- else{ throw new IllegalStateException("cannot deliver shipment. shipment " + shipment + " needs to be picked up first."); }
- return this;
- }
-
- /**
- * Builds the route.
- *
- * @return {@link VehicleRoute}
- * @throws IllegalStateException if there are still shipments that have been picked up though but not delivery.
- */
- public VehicleRoute build(){
- if(!openShipments.isEmpty()){
- throw new IllegalStateException("there are still shipments that have not been delivered yet.");
- }
- VehicleRoute route = VehicleRoute.newInstance(tourActivities, driver, vehicle);
- return route;
- }
-
-}
diff --git a/jsprit-core/src/main/java/basics/route/VehicleRouteCostCalculator.java b/jsprit-core/src/main/java/basics/route/VehicleRouteCostCalculator.java
deleted file mode 100644
index 0f3c4941..00000000
--- a/jsprit-core/src/main/java/basics/route/VehicleRouteCostCalculator.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 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 basics.route;
-
-@Deprecated
-public interface VehicleRouteCostCalculator {
-
- public void addTransportCost(double cost);
-
- public void addActivityCost(double cost);
-
- public void addOtherCost(double cost);
-
- public void price(Vehicle vehicle);
-
- public void price(Driver driver);
-
- public double getCosts();
-
- public void finish();
-
- public void reset();
-
- public VehicleRouteCostCalculator duplicate();
-
-}
diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/FindCheaperVehicle.java b/jsprit-core/src/main/java/jsprit/core/algorithm/FindCheaperVehicle.java
new file mode 100644
index 00000000..155fa90e
--- /dev/null
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/FindCheaperVehicle.java
@@ -0,0 +1,54 @@
+///*******************************************************************************
+// * Copyright (C) 2013 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 jsprit.core.algorithm;
+//
+//import java.util.ArrayList;
+//import java.util.Collection;
+//import java.util.List;
+//
+//import jsprit.core.algorithm.recreate.listener.InsertionStartsListener;
+//import jsprit.core.problem.job.Job;
+//import jsprit.core.problem.solution.route.VehicleRoute;
+//
+//
+//class FindCheaperVehicle implements InsertionStartsListener{
+//
+// FindCheaperVehicleAlgo findCheaperVehicle;
+//
+// public FindCheaperVehicle(FindCheaperVehicleAlgo findCheaperVehicle) {
+// super();
+// this.findCheaperVehicle = findCheaperVehicle;
+// }
+//
+// @Override
+// public void informInsertionStarts(Collection vehicleRoutes, Collection unassignedJobs) {
+// List newRoutes = new ArrayList();
+// for(VehicleRoute route : vehicleRoutes){
+// if(route.isEmpty()) continue;
+// VehicleRoute cheaperRoute = findCheaperVehicle.runAndGetVehicleRoute(route);
+// newRoutes.add(cheaperRoute);
+// }
+// vehicleRoutes.clear();
+// vehicleRoutes.addAll(newRoutes);
+// }
+//
+// @Override
+// public String toString() {
+// return "[name=findCheaperVehicle]";
+// }
+//
+//}
diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/FindCheaperVehicleAlgo.java b/jsprit-core/src/main/java/jsprit/core/algorithm/FindCheaperVehicleAlgo.java
new file mode 100644
index 00000000..c40165bf
--- /dev/null
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/FindCheaperVehicleAlgo.java
@@ -0,0 +1,114 @@
+///*******************************************************************************
+// * Copyright (C) 2013 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 jsprit.core.algorithm;
+//
+//import java.util.ArrayList;
+//import java.util.List;
+//
+//import jsprit.core.algorithm.recreate.AuxilliaryCostCalculator;
+//import jsprit.core.algorithm.state.StateFactory;
+//import jsprit.core.algorithm.state.StateGetter;
+//import jsprit.core.problem.solution.route.VehicleRoute;
+//import jsprit.core.problem.solution.route.activity.TourActivities;
+//import jsprit.core.problem.solution.route.activity.TourActivity;
+//import jsprit.core.problem.vehicle.Vehicle;
+//import jsprit.core.problem.vehicle.VehicleFleetManager;
+//import jsprit.core.problem.vehicle.VehicleImpl.NoVehicle;
+//
+//import org.apache.log4j.Logger;
+//
+//
+//
+//
+//final class FindCheaperVehicleAlgo {
+//
+// private static Logger log = Logger.getLogger(FindCheaperVehicleAlgo.class);
+//
+// private VehicleFleetManager fleetManager;
+//
+// private VehicleRouteUpdater tourStateCalculator;
+//
+// private AuxilliaryCostCalculator auxilliaryCostCalculator;
+//
+// private double weightFixCosts = 1.0;
+//
+// private StateGetter states;
+//
+// public void setWeightFixCosts(double weightFixCosts) {
+// this.weightFixCosts = weightFixCosts;
+// }
+//
+// public void setStates(StateGetter states) {
+// this.states = states;
+// }
+//
+// public FindCheaperVehicleAlgo(VehicleFleetManager fleetManager, VehicleRouteUpdater tourStateCalculator, AuxilliaryCostCalculator auxilliaryCostCalculator) {
+// super();
+// this.fleetManager = fleetManager;
+// this.tourStateCalculator = tourStateCalculator;
+// this.auxilliaryCostCalculator = auxilliaryCostCalculator;
+// }
+//
+//
+// public VehicleRoute runAndGetVehicleRoute(VehicleRoute vehicleRoute) {
+// if(vehicleRoute.getVehicle() instanceof NoVehicle){
+// return vehicleRoute;
+// }
+// if(vehicleRoute.getTourActivities() == null || vehicleRoute.getVehicle() == null){
+// return vehicleRoute;
+// }
+//// Collection availableVehicleTypes = fleetManager.getAvailableVehicleTypes(new TypeKey(vehicleRoute.getVehicle().getType(),vehicleRoute.getVehicle().getLocationId()));
+// double bestSaving = 0.0;
+// Vehicle bestVehicle = null;
+// List path = new ArrayList();
+// path.add(vehicleRoute.getStart());
+// path.addAll(vehicleRoute.getTourActivities().getActivities());
+// path.add(vehicleRoute.getEnd());
+//
+// for(Vehicle vehicle : fleetManager.getAvailableVehicles(vehicleRoute.getVehicle().getType().getTypeId(), vehicleRoute.getVehicle().getLocationId())){
+//// Vehicle vehicle = fleetManager.getEmptyVehicle(vehicleType);
+// if(vehicle.getType().getTypeId().equals(vehicleRoute.getVehicle().getType().getTypeId())){
+// continue;
+// }
+// if(states.getRouteState(vehicleRoute,StateFactory.LOAD).toDouble() <= vehicle.getCapacity()){
+// double fixCostSaving = vehicleRoute.getVehicle().getType().getVehicleCostParams().fix - vehicle.getType().getVehicleCostParams().fix;
+// double departureTime = vehicleRoute.getStart().getEndTime();
+// double newCost = auxilliaryCostCalculator.costOfPath(path, departureTime, vehicleRoute.getDriver(), vehicle);
+// double varCostSaving = states.getRouteState(vehicleRoute, StateFactory.COSTS).toDouble() - newCost;
+// double totalCostSaving = varCostSaving + weightFixCosts*fixCostSaving;
+// if(totalCostSaving > bestSaving){
+// bestSaving = totalCostSaving;
+// bestVehicle = vehicle;
+// }
+// }
+// }
+// if(bestVehicle != null){
+// try{
+// fleetManager.unlock(vehicleRoute.getVehicle());
+// fleetManager.lock(bestVehicle);
+// }
+// catch(IllegalStateException e){
+// throw new IllegalStateException(e);
+// }
+// TourActivities newTour = TourActivities.copyOf(vehicleRoute.getTourActivities());
+// tourStateCalculator.iterate(vehicleRoute);
+// return VehicleRoute.newInstance(newTour,vehicleRoute.getDriver(),bestVehicle);
+// }
+// return vehicleRoute;
+// }
+//
+//}
diff --git a/jsprit-core/src/main/java/algorithms/InsertionInitialSolutionFactory.java b/jsprit-core/src/main/java/jsprit/core/algorithm/InsertionInitialSolutionFactory.java
similarity index 88%
rename from jsprit-core/src/main/java/algorithms/InsertionInitialSolutionFactory.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/InsertionInitialSolutionFactory.java
index 39e990ce..fe9d7cfb 100644
--- a/jsprit-core/src/main/java/algorithms/InsertionInitialSolutionFactory.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/InsertionInitialSolutionFactory.java
@@ -30,18 +30,21 @@
* *
* *********************************************************************** */
-package algorithms;
+package jsprit.core.algorithm;
import java.util.ArrayList;
import java.util.List;
+import jsprit.core.algorithm.recreate.InsertionStrategy;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.solution.InitialSolutionFactory;
+import jsprit.core.problem.solution.SolutionCostCalculator;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+import jsprit.core.problem.solution.route.VehicleRoute;
+
import org.apache.log4j.Logger;
-import basics.Job;
-import basics.VehicleRoutingProblem;
-import basics.VehicleRoutingProblemSolution;
-import basics.algo.SolutionCostCalculator;
-import basics.route.VehicleRoute;
diff --git a/jsprit-core/src/main/java/algorithms/NeighborhoodThresholdInitialiser.java b/jsprit-core/src/main/java/jsprit/core/algorithm/NeighborhoodThresholdInitialiser.java
similarity index 88%
rename from jsprit-core/src/main/java/algorithms/NeighborhoodThresholdInitialiser.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/NeighborhoodThresholdInitialiser.java
index a9abcdfe..cf9ac210 100644
--- a/jsprit-core/src/main/java/algorithms/NeighborhoodThresholdInitialiser.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/NeighborhoodThresholdInitialiser.java
@@ -14,26 +14,26 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm;
import java.util.Collection;
+import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
+import jsprit.core.algorithm.listener.AlgorithmStartsListener;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.solution.route.activity.TourActivity;
+import jsprit.core.util.CrowFlyCosts;
+import jsprit.core.util.EuclideanDistanceCalculator;
+import jsprit.core.util.Locations;
+import jsprit.core.util.NeighborhoodImpl;
+import jsprit.core.util.Solutions;
+
import org.apache.commons.math.stat.descriptive.moment.Mean;
import org.apache.commons.math.stat.descriptive.moment.StandardDeviation;
import org.apache.log4j.Logger;
-import util.CrowFlyCosts;
-import util.EuclideanDistanceCalculator;
-import util.Locations;
-import util.NeighborhoodImpl;
-import util.Solutions;
-import basics.VehicleRoutingAlgorithm;
-import basics.VehicleRoutingProblem;
-import basics.VehicleRoutingProblemSolution;
-import basics.algo.AlgorithmStartsListener;
-import basics.algo.VehicleRoutingAlgorithmFactory;
-import basics.route.TourActivity;
-import basics.route.VehicleRoute;
class NeighborhoodThresholdInitialiser implements AlgorithmStartsListener{
diff --git a/jsprit-core/src/main/java/algorithms/RemoveEmptyVehicles.java b/jsprit-core/src/main/java/jsprit/core/algorithm/RemoveEmptyVehicles.java
similarity index 86%
rename from jsprit-core/src/main/java/algorithms/RemoveEmptyVehicles.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/RemoveEmptyVehicles.java
index 587020bd..7f393dad 100644
--- a/jsprit-core/src/main/java/algorithms/RemoveEmptyVehicles.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/RemoveEmptyVehicles.java
@@ -14,22 +14,19 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import org.apache.log4j.Logger;
+import jsprit.core.algorithm.recreate.listener.InsertionEndsListener;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.vehicle.VehicleFleetManager;
-import basics.algo.InsertionEndsListener;
-import basics.route.VehicleFleetManager;
-import basics.route.VehicleRoute;
public class RemoveEmptyVehicles implements InsertionEndsListener{
- private static Logger log = Logger.getLogger(RemoveEmptyVehicles.class);
-
private VehicleFleetManager fleetManager;
public RemoveEmptyVehicles(VehicleFleetManager fleetManager) {
diff --git a/jsprit-core/src/main/java/algorithms/ResetAndIniFleetManager.java b/jsprit-core/src/main/java/jsprit/core/algorithm/ResetAndIniFleetManager.java
similarity index 72%
rename from jsprit-core/src/main/java/algorithms/ResetAndIniFleetManager.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/ResetAndIniFleetManager.java
index 81c68738..cffed4e1 100644
--- a/jsprit-core/src/main/java/algorithms/ResetAndIniFleetManager.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/ResetAndIniFleetManager.java
@@ -14,25 +14,22 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm;
import java.util.ArrayList;
import java.util.Collection;
-import org.apache.log4j.Logger;
+import jsprit.core.algorithm.recreate.listener.InsertionStartsListener;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.vehicle.VehicleFleetManager;
-import basics.Job;
-import basics.algo.InsertionStartsListener;
-import basics.route.VehicleFleetManager;
-import basics.route.VehicleRoute;
-class ResetAndIniFleetManager implements InsertionStartsListener{
+public class ResetAndIniFleetManager implements InsertionStartsListener{
- private static Logger log = Logger.getLogger(ResetAndIniFleetManager.class);
-
private VehicleFleetManager vehicleFleetManager;
- ResetAndIniFleetManager(VehicleFleetManager vehicleFleetManager) {
+ public ResetAndIniFleetManager(VehicleFleetManager vehicleFleetManager) {
super();
this.vehicleFleetManager = vehicleFleetManager;
}
@@ -42,12 +39,7 @@ class ResetAndIniFleetManager implements InsertionStartsListener{
vehicleFleetManager.unlockAll();
Collection routes = new ArrayList(vehicleRoutes);
for(VehicleRoute route : routes){
-// if(route.isEmpty()){
-// vehicleRoutes.remove(route);
-// }
-// else{
- vehicleFleetManager.lock(route.getVehicle());
-// }
+ vehicleFleetManager.lock(route.getVehicle());
}
}
diff --git a/jsprit-core/src/main/java/basics/algo/SearchStrategy.java b/jsprit-core/src/main/java/jsprit/core/algorithm/SearchStrategy.java
similarity index 92%
rename from jsprit-core/src/main/java/basics/algo/SearchStrategy.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/SearchStrategy.java
index c63ecc2e..465d58a5 100644
--- a/jsprit-core/src/main/java/basics/algo/SearchStrategy.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/SearchStrategy.java
@@ -14,18 +14,21 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics.algo;
+package jsprit.core.algorithm;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import jsprit.core.algorithm.acceptor.SolutionAcceptor;
+import jsprit.core.algorithm.listener.SearchStrategyModuleListener;
+import jsprit.core.algorithm.selector.SolutionSelector;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.solution.SolutionCostCalculator;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+
import org.apache.log4j.Logger;
-import algorithms.acceptors.SolutionAcceptor;
-import algorithms.selectors.SolutionSelector;
-import basics.VehicleRoutingProblem;
-import basics.VehicleRoutingProblemSolution;
diff --git a/jsprit-core/src/main/java/basics/algo/SearchStrategyManager.java b/jsprit-core/src/main/java/jsprit/core/algorithm/SearchStrategyManager.java
similarity index 93%
rename from jsprit-core/src/main/java/basics/algo/SearchStrategyManager.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/SearchStrategyManager.java
index 853ced35..8b98bb32 100644
--- a/jsprit-core/src/main/java/basics/algo/SearchStrategyManager.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/SearchStrategyManager.java
@@ -14,14 +14,17 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics.algo;
+package jsprit.core.algorithm;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
-import util.RandomNumberGeneration;
+import jsprit.core.algorithm.listener.SearchStrategyListener;
+import jsprit.core.algorithm.listener.SearchStrategyModuleListener;
+import jsprit.core.util.RandomNumberGeneration;
+
public class SearchStrategyManager {
diff --git a/jsprit-core/src/main/java/basics/algo/SearchStrategyModule.java b/jsprit-core/src/main/java/jsprit/core/algorithm/SearchStrategyModule.java
similarity index 87%
rename from jsprit-core/src/main/java/basics/algo/SearchStrategyModule.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/SearchStrategyModule.java
index fde99f71..6551b11b 100644
--- a/jsprit-core/src/main/java/basics/algo/SearchStrategyModule.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/SearchStrategyModule.java
@@ -14,9 +14,10 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics.algo;
+package jsprit.core.algorithm;
-import basics.VehicleRoutingProblemSolution;
+import jsprit.core.algorithm.listener.SearchStrategyModuleListener;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
public interface SearchStrategyModule {
diff --git a/jsprit-core/src/main/java/algorithms/VariablePlusFixedSolutionCostCalculatorFactory.java b/jsprit-core/src/main/java/jsprit/core/algorithm/VariablePlusFixedSolutionCostCalculatorFactory.java
similarity index 51%
rename from jsprit-core/src/main/java/algorithms/VariablePlusFixedSolutionCostCalculatorFactory.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/VariablePlusFixedSolutionCostCalculatorFactory.java
index b24a5df9..6d8104e3 100644
--- a/jsprit-core/src/main/java/algorithms/VariablePlusFixedSolutionCostCalculatorFactory.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/VariablePlusFixedSolutionCostCalculatorFactory.java
@@ -1,14 +1,16 @@
-package algorithms;
+package jsprit.core.algorithm;
-import basics.VehicleRoutingProblemSolution;
-import basics.algo.SolutionCostCalculator;
-import basics.route.VehicleRoute;
+import jsprit.core.problem.solution.SolutionCostCalculator;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.solution.route.state.RouteAndActivityStateGetter;
+import jsprit.core.problem.solution.route.state.StateFactory;
public class VariablePlusFixedSolutionCostCalculatorFactory {
- private StateManager stateManager;
+ private RouteAndActivityStateGetter stateManager;
- public VariablePlusFixedSolutionCostCalculatorFactory(StateManager stateManager) {
+ public VariablePlusFixedSolutionCostCalculatorFactory(RouteAndActivityStateGetter stateManager) {
super();
this.stateManager = stateManager;
}
diff --git a/jsprit-core/src/main/java/basics/VehicleRoutingAlgorithm.java b/jsprit-core/src/main/java/jsprit/core/algorithm/VehicleRoutingAlgorithm.java
similarity index 73%
rename from jsprit-core/src/main/java/basics/VehicleRoutingAlgorithm.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/VehicleRoutingAlgorithm.java
index 150a68f4..313cb388 100644
--- a/jsprit-core/src/main/java/basics/VehicleRoutingAlgorithm.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/VehicleRoutingAlgorithm.java
@@ -14,26 +14,29 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics;
+package jsprit.core.algorithm;
import java.util.ArrayList;
import java.util.Collection;
+import jsprit.core.algorithm.SearchStrategy.DiscoveredSolution;
+import jsprit.core.algorithm.acceptor.SolutionAcceptor;
+import jsprit.core.algorithm.listener.AlgorithmEndsListener;
+import jsprit.core.algorithm.listener.AlgorithmStartsListener;
+import jsprit.core.algorithm.listener.IterationEndsListener;
+import jsprit.core.algorithm.listener.IterationStartsListener;
+import jsprit.core.algorithm.listener.SearchStrategyListener;
+import jsprit.core.algorithm.listener.SearchStrategyModuleListener;
+import jsprit.core.algorithm.listener.StrategySelectedListener;
+import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListener;
+import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners;
+import jsprit.core.algorithm.termination.IterationWithoutImprovementTermination;
+import jsprit.core.algorithm.termination.PrematureAlgorithmTermination;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+
import org.apache.log4j.Logger;
-import util.Counter;
-import algorithms.acceptors.SolutionAcceptor;
-import basics.algo.AlgorithmEndsListener;
-import basics.algo.AlgorithmStartsListener;
-import basics.algo.IterationEndsListener;
-import basics.algo.IterationStartsListener;
-import basics.algo.IterationWithoutImprovementBreaker;
-import basics.algo.PrematureAlgorithmBreaker;
-import basics.algo.SearchStrategy;
-import basics.algo.SearchStrategy.DiscoveredSolution;
-import basics.algo.SearchStrategyManager;
-import basics.algo.VehicleRoutingAlgorithmListener;
-import basics.algo.VehicleRoutingAlgorithmListeners;
/**
* Algorithm that solves a {@link VehicleRoutingProblem}.
@@ -43,7 +46,36 @@ import basics.algo.VehicleRoutingAlgorithmListeners;
*/
public class VehicleRoutingAlgorithm {
-
+ private static class Counter {
+ private final String name;
+ private long counter = 0;
+ private long nextCounter = 1;
+ private static final Logger log = Logger.getLogger(Counter.class);
+
+ public Counter(final String name) {
+ this.name = name;
+ }
+
+ public void incCounter() {
+ long i = counter++;
+ long n = nextCounter;
+ if (i >= n) {
+ if (nextCounter==n) {
+ nextCounter=n*2;
+ log.info(this.name + n);
+ }
+ }
+ }
+
+ public void print() {
+ log.info(this.name + counter);
+ }
+
+ public void reset() {
+ counter=0;
+ nextCounter=1;
+ }
+ }
public static final int NOBREAK = Integer.MAX_VALUE;
@@ -61,7 +93,7 @@ public class VehicleRoutingAlgorithm {
private Collection initialSolutions;
- private PrematureAlgorithmBreaker prematureAlgorithmBreaker = new PrematureAlgorithmBreaker() {
+ private PrematureAlgorithmTermination prematureAlgorithmTermination = new PrematureAlgorithmTermination() {
@Override
public boolean isPrematureBreak(DiscoveredSolution discoveredSolution) {
@@ -100,15 +132,16 @@ public class VehicleRoutingAlgorithm {
* Improvement is what {@link SolutionAcceptor} understands about improvement. Or to put it in other words, the algo breaks prematurely after
* the assigned number of iterations without solution-acceptance.
*
- *
+ * @deprecated use setPrematureAlgorithmTermination(new IterationWithoutImprovementTermination(int nuIterationsWithoutImprovement));
* @param nuIterationsWithoutImprovement
*/
+ @Deprecated
public void setPrematureBreak(int nuIterationsWithoutImprovement){
- prematureAlgorithmBreaker = new IterationWithoutImprovementBreaker(nuIterationsWithoutImprovement);
+ prematureAlgorithmTermination = new IterationWithoutImprovementTermination(nuIterationsWithoutImprovement);
}
- public void setPrematureAlgorithmBreaker(PrematureAlgorithmBreaker prematureAlgorithmBreaker){
- this.prematureAlgorithmBreaker = prematureAlgorithmBreaker;
+ public void setPrematureAlgorithmTermination(PrematureAlgorithmTermination prematureAlgorithmTermination){
+ this.prematureAlgorithmTermination = prematureAlgorithmTermination;
}
/**
@@ -146,7 +179,7 @@ public class VehicleRoutingAlgorithm {
SearchStrategy strategy = searchStrategyManager.getRandomStrategy();
DiscoveredSolution discoveredSolution = strategy.run(problem, solutions);
selectedStrategy(strategy.getName(),problem, solutions);
- if(prematureAlgorithmBreaker.isPrematureBreak(discoveredSolution)){
+ if(prematureAlgorithmTermination.isPrematureBreak(discoveredSolution)){
logger.info("premature break at iteration "+ (i+1));
nuOfIterationsThisAlgoIsRunning = (i+1);
break;
@@ -193,6 +226,12 @@ public class VehicleRoutingAlgorithm {
public VehicleRoutingAlgorithmListeners getAlgorithmListeners() {
return algoListeners;
}
+
+ public void addListener(VehicleRoutingAlgorithmListener l){
+ algoListeners.addListener(l);
+ if(l instanceof SearchStrategyListener) searchStrategyManager.addSearchStrategyListener((SearchStrategyListener) l);
+ if(l instanceof SearchStrategyModuleListener) searchStrategyManager.addSearchStrategyModuleListener((SearchStrategyModuleListener) l);
+ }
private void iterationEnds(int i, VehicleRoutingProblem problem, Collection solutions) {
algoListeners.iterationEnds(i,problem, solutions);
diff --git a/jsprit-core/src/main/java/basics/algo/VehicleRoutingAlgorithmFactory.java b/jsprit-core/src/main/java/jsprit/core/algorithm/VehicleRoutingAlgorithmFactory.java
similarity index 91%
rename from jsprit-core/src/main/java/basics/algo/VehicleRoutingAlgorithmFactory.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/VehicleRoutingAlgorithmFactory.java
index e0b9be1c..40749bdb 100644
--- a/jsprit-core/src/main/java/basics/algo/VehicleRoutingAlgorithmFactory.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/VehicleRoutingAlgorithmFactory.java
@@ -14,10 +14,9 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics.algo;
+package jsprit.core.algorithm;
-import basics.VehicleRoutingAlgorithm;
-import basics.VehicleRoutingProblem;
+import jsprit.core.problem.VehicleRoutingProblem;
public interface VehicleRoutingAlgorithmFactory {
diff --git a/jsprit-core/src/main/java/algorithms/acceptors/AcceptNewRemoveFirst.java b/jsprit-core/src/main/java/jsprit/core/algorithm/acceptor/AcceptNewRemoveFirst.java
similarity index 94%
rename from jsprit-core/src/main/java/algorithms/acceptors/AcceptNewRemoveFirst.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/acceptor/AcceptNewRemoveFirst.java
index abaa1e00..8da92a94 100644
--- a/jsprit-core/src/main/java/algorithms/acceptors/AcceptNewRemoveFirst.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/acceptor/AcceptNewRemoveFirst.java
@@ -14,11 +14,12 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms.acceptors;
+package jsprit.core.algorithm.acceptor;
import java.util.Collection;
-import basics.VehicleRoutingProblemSolution;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+
public class AcceptNewRemoveFirst implements SolutionAcceptor{
diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/acceptor/ExperimentalSchrimpfAcceptance.java b/jsprit-core/src/main/java/jsprit/core/algorithm/acceptor/ExperimentalSchrimpfAcceptance.java
new file mode 100644
index 00000000..ab81bbd3
--- /dev/null
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/acceptor/ExperimentalSchrimpfAcceptance.java
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * Copyright (C) 2013 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 jsprit.core.algorithm.acceptor;
+
+import java.net.URL;
+import java.util.Collection;
+
+import jsprit.core.algorithm.VehicleRoutingAlgorithm;
+import jsprit.core.algorithm.io.AlgorithmConfig;
+import jsprit.core.algorithm.io.AlgorithmConfigXmlReader;
+import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
+import jsprit.core.algorithm.listener.AlgorithmStartsListener;
+import jsprit.core.algorithm.listener.IterationEndsListener;
+import jsprit.core.algorithm.listener.IterationStartsListener;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+import jsprit.core.util.Resource;
+import jsprit.core.util.Solutions;
+
+import org.apache.commons.math.stat.descriptive.moment.StandardDeviation;
+import org.apache.log4j.Logger;
+
+
+
+
+public class ExperimentalSchrimpfAcceptance implements SolutionAcceptor, IterationStartsListener, AlgorithmStartsListener{
+
+ private static Logger logger = Logger.getLogger(ExperimentalSchrimpfAcceptance.class);
+
+ private final double alpha;
+
+ private int nOfTotalIterations = 1000;
+
+ private int currentIteration = 0;
+
+ private double initialThreshold = 0.0;
+
+ private final int nOfRandomWalks;
+
+ private final int solutionMemory;
+
+
+ public ExperimentalSchrimpfAcceptance(int solutionMemory, double alpha, int nOfWarmupIterations) {
+ super();
+ this.alpha = alpha;
+ this.nOfRandomWalks = nOfWarmupIterations;
+ this.solutionMemory = solutionMemory;
+ logger.info("initialise " + this);
+ }
+
+
+
+ @Override
+ public boolean acceptSolution(Collection solutions, VehicleRoutingProblemSolution newSolution) {
+ boolean solutionAccepted = false;
+ if (solutions.size() < solutionMemory) {
+ solutions.add(newSolution);
+ solutionAccepted = true;
+ } else {
+ VehicleRoutingProblemSolution worst = null;
+ double threshold = getThreshold(currentIteration);
+ for(VehicleRoutingProblemSolution solutionInMemory : solutions){
+ if(worst == null) worst = solutionInMemory;
+ else if(solutionInMemory.getCost() > worst.getCost()) worst = solutionInMemory;
+ }
+ if(newSolution.getRoutes().size() < worst.getRoutes().size()){
+ solutions.remove(worst);
+ solutions.add(newSolution);
+ solutionAccepted = true;
+ }
+ else if(newSolution.getRoutes().size() == worst.getRoutes().size() && newSolution.getCost() < worst.getCost() + threshold){
+ solutions.remove(worst);
+ solutions.add(newSolution);
+ solutionAccepted = true;
+ }
+ }
+ return solutionAccepted;
+ }
+
+ @Override
+ public String toString() {
+ return "[name=schrimpfAcceptanceFunction][alpha="+alpha+"][warmup=" + nOfRandomWalks + "]";
+ }
+
+ private double getThreshold(int iteration) {
+ double scheduleVariable = (double) iteration / (double) nOfTotalIterations;
+// logger.debug("iter="+iteration+" totalIter="+nOfTotalIterations+" scheduling="+scheduleVariable);
+ double currentThreshold = initialThreshold * Math.exp(-Math.log(2) * scheduleVariable / alpha);
+ return currentThreshold;
+ }
+
+
+ @Override
+ public void informAlgorithmStarts(VehicleRoutingProblem problem, VehicleRoutingAlgorithm algorithm, Collection solutions) {
+ reset();
+ logger.info("---------------------------------------------------------------------");
+ logger.info("prepare schrimpfAcceptanceFunction, i.e. determine initial threshold");
+ logger.info("start random-walk (see randomWalk.xml)");
+ double now = System.currentTimeMillis();
+ this.nOfTotalIterations = algorithm.getNuOfIterations();
+
+ /*
+ * randomWalk to determine standardDev
+ */
+ final double[] results = new double[nOfRandomWalks];
+
+ URL resource = Resource.getAsURL("randomWalk.xml");
+ AlgorithmConfig algorithmConfig = new AlgorithmConfig();
+ new AlgorithmConfigXmlReader(algorithmConfig).read(resource);
+ VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.createAlgorithm(problem, algorithmConfig);
+ vra.setNuOfIterations(nOfRandomWalks);
+ vra.getAlgorithmListeners().addListener(new IterationEndsListener() {
+
+ @Override
+ public void informIterationEnds(int iteration, VehicleRoutingProblem problem, Collection solutions) {
+ double result = Solutions.getBest(solutions).getCost();
+// logger.info("result="+result);
+ results[iteration-1] = result;
+ }
+
+ });
+ vra.searchSolutions();
+
+ StandardDeviation dev = new StandardDeviation();
+ double standardDeviation = dev.evaluate(results);
+ initialThreshold = standardDeviation / 2;
+
+ logger.info("warmup done");
+ logger.info("total time: " + ((System.currentTimeMillis()-now)/1000.0) + "s");
+ logger.info("initial threshold: " + initialThreshold);
+ logger.info("---------------------------------------------------------------------");
+
+ }
+
+ private void reset() {
+ currentIteration = 0;
+ }
+
+ @Override
+ public void informIterationStarts(int i, VehicleRoutingProblem problem, Collection solutions) {
+ currentIteration = i;
+ }
+
+}
diff --git a/jsprit-core/src/main/java/algorithms/acceptors/AcceptNewIfBetterThanWorst.java b/jsprit-core/src/main/java/jsprit/core/algorithm/acceptor/GreedyAcceptance.java
similarity index 83%
rename from jsprit-core/src/main/java/algorithms/acceptors/AcceptNewIfBetterThanWorst.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/acceptor/GreedyAcceptance.java
index 6ed85659..1f896697 100644
--- a/jsprit-core/src/main/java/algorithms/acceptors/AcceptNewIfBetterThanWorst.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/acceptor/GreedyAcceptance.java
@@ -14,18 +14,19 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms.acceptors;
+package jsprit.core.algorithm.acceptor;
import java.util.Collection;
-import basics.VehicleRoutingProblemSolution;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
-public class AcceptNewIfBetterThanWorst implements SolutionAcceptor{
+
+public class GreedyAcceptance implements SolutionAcceptor{
private final int solutionMemory;
- public AcceptNewIfBetterThanWorst(int solutionMemory){
+ public GreedyAcceptance(int solutionMemory){
this.solutionMemory = solutionMemory;
}
@@ -47,6 +48,12 @@ public class AcceptNewIfBetterThanWorst implements SolutionAcceptor{
if (worstSolution == null) worstSolution = s;
else if (s.getCost() > worstSolution.getCost()) worstSolution = s;
}
+// if(newSolution.getRoutes().size() < worstSolution.getRoutes().size()){
+// solutions.remove(worstSolution);
+// solutions.add(newSolution);
+// solutionAccepted = true;
+// }
+// else
if(newSolution.getCost() < worstSolution.getCost()){
solutions.remove(worstSolution);
solutions.add(newSolution);
diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/acceptor/GreedyAcceptance_minVehFirst.java b/jsprit-core/src/main/java/jsprit/core/algorithm/acceptor/GreedyAcceptance_minVehFirst.java
new file mode 100644
index 00000000..ae5b0976
--- /dev/null
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/acceptor/GreedyAcceptance_minVehFirst.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (C) 2013 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 jsprit.core.algorithm.acceptor;
+
+import java.util.Collection;
+
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+
+
+
+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/algorithms/acceptors/SchrimpfAcceptance.java b/jsprit-core/src/main/java/jsprit/core/algorithm/acceptor/SchrimpfAcceptance.java
similarity index 88%
rename from jsprit-core/src/main/java/algorithms/acceptors/SchrimpfAcceptance.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/acceptor/SchrimpfAcceptance.java
index 544b8872..9b181c8a 100644
--- a/jsprit-core/src/main/java/algorithms/acceptors/SchrimpfAcceptance.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/acceptor/SchrimpfAcceptance.java
@@ -14,25 +14,26 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms.acceptors;
+package jsprit.core.algorithm.acceptor;
import java.net.URL;
import java.util.Collection;
+import jsprit.core.algorithm.VehicleRoutingAlgorithm;
+import jsprit.core.algorithm.io.AlgorithmConfig;
+import jsprit.core.algorithm.io.AlgorithmConfigXmlReader;
+import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
+import jsprit.core.algorithm.listener.AlgorithmStartsListener;
+import jsprit.core.algorithm.listener.IterationEndsListener;
+import jsprit.core.algorithm.listener.IterationStartsListener;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+import jsprit.core.util.Resource;
+import jsprit.core.util.Solutions;
+
import org.apache.commons.math.stat.descriptive.moment.StandardDeviation;
import org.apache.log4j.Logger;
-import util.Resource;
-import util.Solutions;
-import algorithms.VehicleRoutingAlgorithms;
-import basics.VehicleRoutingAlgorithm;
-import basics.VehicleRoutingProblem;
-import basics.VehicleRoutingProblemSolution;
-import basics.algo.AlgorithmStartsListener;
-import basics.algo.IterationEndsListener;
-import basics.algo.IterationStartsListener;
-import basics.io.AlgorithmConfig;
-import basics.io.AlgorithmConfigXmlReader;
diff --git a/jsprit-core/src/main/java/algorithms/acceptors/SolutionAcceptor.java b/jsprit-core/src/main/java/jsprit/core/algorithm/acceptor/SolutionAcceptor.java
similarity index 93%
rename from jsprit-core/src/main/java/algorithms/acceptors/SolutionAcceptor.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/acceptor/SolutionAcceptor.java
index f0debbeb..23cd70d1 100644
--- a/jsprit-core/src/main/java/algorithms/acceptors/SolutionAcceptor.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/acceptor/SolutionAcceptor.java
@@ -14,11 +14,12 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms.acceptors;
+package jsprit.core.algorithm.acceptor;
import java.util.Collection;
-import basics.VehicleRoutingProblemSolution;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+
/**
* Acceptor that decides whether the newSolution is accepted or not.
diff --git a/jsprit-core/src/main/java/algorithms/GreedySchrimpfFactory.java b/jsprit-core/src/main/java/jsprit/core/algorithm/box/GreedySchrimpfFactory.java
similarity index 86%
rename from jsprit-core/src/main/java/algorithms/GreedySchrimpfFactory.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/box/GreedySchrimpfFactory.java
index c8faf88f..a757b9a5 100644
--- a/jsprit-core/src/main/java/algorithms/GreedySchrimpfFactory.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/box/GreedySchrimpfFactory.java
@@ -14,15 +14,17 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.box;
import java.net.URL;
-import util.Resource;
-import basics.VehicleRoutingAlgorithm;
-import basics.VehicleRoutingProblem;
-import basics.io.AlgorithmConfig;
-import basics.io.AlgorithmConfigXmlReader;
+import jsprit.core.algorithm.VehicleRoutingAlgorithm;
+import jsprit.core.algorithm.io.AlgorithmConfig;
+import jsprit.core.algorithm.io.AlgorithmConfigXmlReader;
+import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.util.Resource;
+
/**
diff --git a/jsprit-core/src/main/java/algorithms/SchrimpfFactory.java b/jsprit-core/src/main/java/jsprit/core/algorithm/box/SchrimpfFactory.java
similarity index 86%
rename from jsprit-core/src/main/java/algorithms/SchrimpfFactory.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/box/SchrimpfFactory.java
index 0d54ee20..efb1655a 100644
--- a/jsprit-core/src/main/java/algorithms/SchrimpfFactory.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/box/SchrimpfFactory.java
@@ -14,15 +14,17 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.box;
import java.net.URL;
-import util.Resource;
-import basics.VehicleRoutingAlgorithm;
-import basics.VehicleRoutingProblem;
-import basics.io.AlgorithmConfig;
-import basics.io.AlgorithmConfigXmlReader;
+import jsprit.core.algorithm.VehicleRoutingAlgorithm;
+import jsprit.core.algorithm.io.AlgorithmConfig;
+import jsprit.core.algorithm.io.AlgorithmConfigXmlReader;
+import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.util.Resource;
+
/**
diff --git a/jsprit-core/src/main/java/basics/io/AlgorithmConfig.java b/jsprit-core/src/main/java/jsprit/core/algorithm/io/AlgorithmConfig.java
similarity index 97%
rename from jsprit-core/src/main/java/basics/io/AlgorithmConfig.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/io/AlgorithmConfig.java
index 6aaefc90..1fa3f1c1 100644
--- a/jsprit-core/src/main/java/basics/io/AlgorithmConfig.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/io/AlgorithmConfig.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics.io;
+package jsprit.core.algorithm.io;
import org.apache.commons.configuration.XMLConfiguration;
diff --git a/jsprit-core/src/main/java/basics/io/AlgorithmConfigXmlReader.java b/jsprit-core/src/main/java/jsprit/core/algorithm/io/AlgorithmConfigXmlReader.java
similarity index 97%
rename from jsprit-core/src/main/java/basics/io/AlgorithmConfigXmlReader.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/io/AlgorithmConfigXmlReader.java
index 13d2709e..c3ae89be 100644
--- a/jsprit-core/src/main/java/basics/io/AlgorithmConfigXmlReader.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/io/AlgorithmConfigXmlReader.java
@@ -14,19 +14,20 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics.io;
+package jsprit.core.algorithm.io;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import jsprit.core.util.Resource;
+
import org.apache.commons.configuration.ConfigurationException;
import org.apache.log4j.Logger;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
-import util.Resource;
public class AlgorithmConfigXmlReader {
diff --git a/jsprit-core/src/main/java/algorithms/InsertionFactory.java b/jsprit-core/src/main/java/jsprit/core/algorithm/io/InsertionFactory.java
similarity index 76%
rename from jsprit-core/src/main/java/algorithms/InsertionFactory.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/io/InsertionFactory.java
index 64ec876e..6f23a2a9 100644
--- a/jsprit-core/src/main/java/algorithms/InsertionFactory.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/io/InsertionFactory.java
@@ -14,19 +14,24 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.io;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
+import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners.PrioritizedVRAListener;
+import jsprit.core.algorithm.recreate.BestInsertionBuilder;
+import jsprit.core.algorithm.recreate.InsertionStrategy;
+import jsprit.core.algorithm.recreate.listener.InsertionListener;
+import jsprit.core.algorithm.state.StateManager;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.constraint.ConstraintManager;
+import jsprit.core.problem.vehicle.VehicleFleetManager;
+
import org.apache.commons.configuration.HierarchicalConfiguration;
import org.apache.log4j.Logger;
-import basics.VehicleRoutingProblem;
-import basics.algo.InsertionListener;
-import basics.algo.VehicleRoutingAlgorithmListeners.PrioritizedVRAListener;
-import basics.route.VehicleFleetManager;
class InsertionFactory {
@@ -44,16 +49,17 @@ class InsertionFactory {
List insertionListeners = new ArrayList();
List algoListeners = new ArrayList();
- CalculatorBuilder calcBuilder = new CalculatorBuilder(insertionListeners, algorithmListeners);
- calcBuilder.setStates(routeStates);
- calcBuilder.setVehicleRoutingProblem(vrp);
- calcBuilder.setVehicleFleetManager(vehicleFleetManager);
- calcBuilder.setConstraintManager(constraintManager);
+ BestInsertionBuilder iBuilder = new BestInsertionBuilder(vrp, vehicleFleetManager, routeStates, constraintManager);
+
+ if(executorService != null){
+ iBuilder.setConcurrentMode(executorService, nuOfThreads);
+ }
if(config.containsKey("level")){
String level = config.getString("level");
if(level.equals("local")){
- calcBuilder.setLocalLevel();
+ iBuilder.setLocalLevel();
+// calcBuilder.setLocalLevel();
}
else if(level.equals("route")){
int forwardLooking = 0;
@@ -64,11 +70,12 @@ class InsertionFactory {
else log.warn("parameter route[@forwardLooking] is missing. by default it is 0 which equals to local level");
if(mem != null) memory = Integer.parseInt(mem);
else log.warn("parameter route[@memory] is missing. by default it is 1");
- calcBuilder.setRouteLevel(forwardLooking, memory);
+ iBuilder.setRouteLevel(forwardLooking, memory);
+// calcBuilder.setRouteLevel(forwardLooking, memory);
}
else throw new IllegalStateException("level " + level + " is not known. currently it only knows \"local\" or \"route\"");
}
- else calcBuilder.setLocalLevel();
+ else iBuilder.setLocalLevel();
if(config.containsKey("considerFixedCosts") || config.containsKey("considerFixedCost")){
String val = config.getString("considerFixedCosts");
@@ -79,21 +86,19 @@ class InsertionFactory {
if(weight == null) weight = config.getString("considerFixedCost[@weight]");
if(weight != null) fixedCostWeight = Double.parseDouble(weight);
else log.warn("parameter considerFixedCosts[@weight] is missing. by default, it is 0.5.");
- calcBuilder.considerFixedCosts(fixedCostWeight);
+ iBuilder.considerFixedCosts(fixedCostWeight);
}
}
String timeSliceString = config.getString("experimental[@timeSlice]");
String neighbors = config.getString("experimental[@neighboringSlices]");
if(timeSliceString != null && neighbors != null){
- calcBuilder.experimentalTimeScheduler(Double.parseDouble(timeSliceString),Integer.parseInt(neighbors));
+ iBuilder.experimentalTimeScheduler(Double.parseDouble(timeSliceString),Integer.parseInt(neighbors));
}
- JobInsertionCostsCalculator jic = calcBuilder.build();
-
-
if(insertionName.equals("bestInsertion")){
- insertionStrategy = new BestInsertion(jic);
+ insertionStrategy = iBuilder.build();
}
+ else throw new IllegalStateException("currently only 'bestInsertion' is supported");
for(InsertionListener l : insertionListeners) insertionStrategy.addListener(l);
algorithmListeners.addAll(algoListeners);
diff --git a/jsprit-core/src/main/java/algorithms/VehicleRoutingAlgorithms.java b/jsprit-core/src/main/java/jsprit/core/algorithm/io/VehicleRoutingAlgorithms.java
similarity index 74%
rename from jsprit-core/src/main/java/algorithms/VehicleRoutingAlgorithms.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/io/VehicleRoutingAlgorithms.java
index 8d3ae5ed..faa84ee3 100644
--- a/jsprit-core/src/main/java/algorithms/VehicleRoutingAlgorithms.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/io/VehicleRoutingAlgorithms.java
@@ -14,9 +14,10 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.io;
+import java.lang.Thread.UncaughtExceptionHandler;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
@@ -26,48 +27,68 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import jsprit.core.algorithm.InsertionInitialSolutionFactory;
+import jsprit.core.algorithm.RemoveEmptyVehicles;
+import jsprit.core.algorithm.ResetAndIniFleetManager;
+import jsprit.core.algorithm.SearchStrategy;
+import jsprit.core.algorithm.SearchStrategy.DiscoveredSolution;
+import jsprit.core.algorithm.SearchStrategyManager;
+import jsprit.core.algorithm.SearchStrategyModule;
+import jsprit.core.algorithm.VehicleRoutingAlgorithm;
+import jsprit.core.algorithm.acceptor.AcceptNewRemoveFirst;
+import jsprit.core.algorithm.acceptor.ExperimentalSchrimpfAcceptance;
+import jsprit.core.algorithm.acceptor.GreedyAcceptance;
+import jsprit.core.algorithm.acceptor.GreedyAcceptance_minVehFirst;
+import jsprit.core.algorithm.acceptor.SchrimpfAcceptance;
+import jsprit.core.algorithm.acceptor.SolutionAcceptor;
+import jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap.AbstractKey;
+import jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap.AcceptorKey;
+import jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap.InsertionStrategyKey;
+import jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap.RuinStrategyKey;
+import jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap.SelectorKey;
+import jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap.StrategyModuleKey;
+import jsprit.core.algorithm.listener.AlgorithmEndsListener;
+import jsprit.core.algorithm.listener.AlgorithmStartsListener;
+import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners.PrioritizedVRAListener;
+import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners.Priority;
+import jsprit.core.algorithm.module.RuinAndRecreateModule;
+import jsprit.core.algorithm.recreate.InsertionStrategy;
+import jsprit.core.algorithm.recreate.VehicleSwitched;
+import jsprit.core.algorithm.recreate.listener.InsertionListener;
+import jsprit.core.algorithm.ruin.RadialRuinStrategyFactory;
+import jsprit.core.algorithm.ruin.RandomRuinStrategyFactory;
+import jsprit.core.algorithm.ruin.RuinStrategy;
+import jsprit.core.algorithm.ruin.distance.AvgServiceAndShipmentDistance;
+import jsprit.core.algorithm.ruin.distance.JobDistance;
+import jsprit.core.algorithm.selector.SelectBest;
+import jsprit.core.algorithm.selector.SelectRandomly;
+import jsprit.core.algorithm.selector.SolutionSelector;
+import jsprit.core.algorithm.state.StateManager;
+import jsprit.core.algorithm.state.UpdateActivityTimes;
+import jsprit.core.algorithm.state.UpdateVariableCosts;
+import jsprit.core.algorithm.termination.IterationWithoutImprovementTermination;
+import jsprit.core.algorithm.termination.PrematureAlgorithmTermination;
+import jsprit.core.algorithm.termination.TimeTermination;
+import jsprit.core.algorithm.termination.VariationCoefficientTermination;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
+import jsprit.core.problem.constraint.ConstraintManager;
+import jsprit.core.problem.solution.SolutionCostCalculator;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.solution.route.state.StateFactory;
+import jsprit.core.problem.vehicle.FiniteFleetManagerFactory;
+import jsprit.core.problem.vehicle.InfiniteFleetManagerFactory;
+import jsprit.core.problem.vehicle.Vehicle;
+import jsprit.core.problem.vehicle.VehicleFleetManager;
+import jsprit.core.util.SolutionVerifier;
import org.apache.commons.configuration.HierarchicalConfiguration;
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.log4j.Logger;
-import algorithms.VehicleRoutingAlgorithms.TypedMap.AbstractKey;
-import algorithms.VehicleRoutingAlgorithms.TypedMap.AcceptorKey;
-import algorithms.VehicleRoutingAlgorithms.TypedMap.InsertionStrategyKey;
-import algorithms.VehicleRoutingAlgorithms.TypedMap.RuinStrategyKey;
-import algorithms.VehicleRoutingAlgorithms.TypedMap.SelectorKey;
-import algorithms.VehicleRoutingAlgorithms.TypedMap.StrategyModuleKey;
-import algorithms.acceptors.AcceptNewIfBetterThanWorst;
-import algorithms.acceptors.AcceptNewRemoveFirst;
-import algorithms.acceptors.SchrimpfAcceptance;
-import algorithms.acceptors.SolutionAcceptor;
-import algorithms.selectors.SelectBest;
-import algorithms.selectors.SelectRandomly;
-import algorithms.selectors.SolutionSelector;
-import basics.VehicleRoutingAlgorithm;
-import basics.VehicleRoutingProblem;
-import basics.VehicleRoutingProblem.FleetSize;
-import basics.VehicleRoutingProblemSolution;
-import basics.algo.AlgorithmStartsListener;
-import basics.algo.InsertionListener;
-import basics.algo.IterationWithoutImprovementBreaker;
-import basics.algo.PrematureAlgorithmBreaker;
-import basics.algo.SearchStrategy;
-import basics.algo.SearchStrategy.DiscoveredSolution;
-import basics.algo.SearchStrategyManager;
-import basics.algo.SearchStrategyModule;
-import basics.algo.SolutionCostCalculator;
-import basics.algo.TimeBreaker;
-import basics.algo.VariationCoefficientBreaker;
-import basics.algo.VehicleRoutingAlgorithmListeners.PrioritizedVRAListener;
-import basics.algo.VehicleRoutingAlgorithmListeners.Priority;
-import basics.io.AlgorithmConfig;
-import basics.io.AlgorithmConfigXmlReader;
-import basics.route.FiniteFleetManagerFactory;
-import basics.route.InfiniteFleetManagerFactory;
-import basics.route.Vehicle;
-import basics.route.VehicleFleetManager;
-import basics.route.VehicleRoute;
@@ -371,12 +392,12 @@ public class VehicleRoutingAlgorithms {
* @return {@link VehicleRoutingAlgorithm}
*/
public static VehicleRoutingAlgorithm createAlgorithm(final VehicleRoutingProblem vrp, final AlgorithmConfig algorithmConfig){
- return createAlgo(vrp,algorithmConfig.getXMLConfiguration(),null,0);
+ return createAlgo(vrp,algorithmConfig.getXMLConfiguration(),0);
}
@Deprecated
public static VehicleRoutingAlgorithm readAndCreateAlgorithm(final VehicleRoutingProblem vrp, final XMLConfiguration config){
- return createAlgo(vrp,config,null,0);
+ return createAlgo(vrp,config,0);
}
/**
@@ -390,7 +411,7 @@ public class VehicleRoutingAlgorithms {
AlgorithmConfig algorithmConfig = new AlgorithmConfig();
AlgorithmConfigXmlReader xmlReader = new AlgorithmConfigXmlReader(algorithmConfig);
xmlReader.read(configURL);
- return createAlgo(vrp,algorithmConfig.getXMLConfiguration(),null,0);
+ return createAlgo(vrp,algorithmConfig.getXMLConfiguration(),0);
}
/**
@@ -404,26 +425,18 @@ public class VehicleRoutingAlgorithms {
AlgorithmConfig algorithmConfig = new AlgorithmConfig();
AlgorithmConfigXmlReader xmlReader = new AlgorithmConfigXmlReader(algorithmConfig);
xmlReader.read(configFileName);
- return createAlgo(vrp,algorithmConfig.getXMLConfiguration(),null, 0);
+ return createAlgo(vrp,algorithmConfig.getXMLConfiguration(),0);
}
- /**
- * Read and creates {@link VehicleRoutingAlgorithm} from config-file.
- *
- * @param vrp
- * @param configFileName
- * @param nuOfThreads TODO
- * @param {@link ExecutorService}
- * @return {@link VehicleRoutingAlgorithm}
- */
- private static VehicleRoutingAlgorithm readAndCreateConcurrentAlgorithm(final VehicleRoutingProblem vrp, final String configFileName, final ExecutorService executorService, int nuOfThreads){
+ public static VehicleRoutingAlgorithm readAndCreateAlgorithm(VehicleRoutingProblem vrp, int nThreads, String configFileName) {
AlgorithmConfig algorithmConfig = new AlgorithmConfig();
AlgorithmConfigXmlReader xmlReader = new AlgorithmConfigXmlReader(algorithmConfig);
xmlReader.read(configFileName);
- return createAlgo(vrp,algorithmConfig.getXMLConfiguration(), executorService, nuOfThreads);
+ return createAlgo(vrp,algorithmConfig.getXMLConfiguration(),nThreads);
}
- private static VehicleRoutingAlgorithm createAlgo(final VehicleRoutingProblem vrp, XMLConfiguration config, ExecutorService executorService, int nuOfThreads){
+ private static VehicleRoutingAlgorithm createAlgo(final VehicleRoutingProblem vrp, XMLConfiguration config, int nuOfThreads){
+
// map to store constructed modules
TypedMap definedClasses = new TypedMap();
@@ -434,11 +447,46 @@ public class VehicleRoutingAlgorithms {
// insertion listeners
List insertionListeners = new ArrayList();
+ //threading
+ final ExecutorService executorService;
+ if(nuOfThreads > 0){
+ log.info("setup executor-service with " + nuOfThreads + " threads");
+ executorService = Executors.newFixedThreadPool(nuOfThreads);
+ algorithmListeners.add(new PrioritizedVRAListener(Priority.LOW, new AlgorithmEndsListener() {
+
+ @Override
+ public void informAlgorithmEnds(VehicleRoutingProblem problem,Collection solutions) {
+ log.info("shutdown executor-service");
+ executorService.shutdown();
+ }
+ }));
+ Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
+
+ @Override
+ public void uncaughtException(Thread arg0, Throwable arg1) {
+ System.err.println(arg1.toString());
+ System.exit(0);
+ }
+ });
+ Runtime.getRuntime().addShutdownHook(new Thread(){
+ public void run(){
+ if(!executorService.isShutdown()){
+ System.err.println("shutdowHook shuts down executorService");
+ executorService.shutdown();
+ }
+ }
+ });
+ }
+ else executorService = null;
+
+
//create fleetmanager
final VehicleFleetManager vehicleFleetManager = createFleetManager(vrp);
//create state-manager
- final StateManager stateManager = new StateManager();
+ final StateManager stateManager = new StateManager(vrp);
+ stateManager.updateLoadStates();
+ stateManager.updateTimeWindowStates();
/*
* define constraints
@@ -486,8 +534,8 @@ public class VehicleRoutingAlgorithms {
// UpdateLoads loadUpdater = new UpdateLoads(stateManager);
// stateManager.addListener(loadUpdater);
// stateManager.addActivityVisitor(loadUpdater);
- stateManager.addActivityVisitor(new UpdateActivityTimes(vrp.getTransportCosts()));
- stateManager.addActivityVisitor(new UpdateVariableCosts(vrp.getActivityCosts(), vrp.getTransportCosts(), stateManager));
+ stateManager.addStateUpdater(new UpdateActivityTimes(vrp.getTransportCosts()));
+ stateManager.addStateUpdater(new UpdateVariableCosts(vrp.getActivityCosts(), vrp.getTransportCosts(), stateManager));
// stateManager.addActivityVisitor(new UpdateOccuredDeliveries(stateManager));
// stateManager.addActivityVisitor(new TimeWindowUpdater(stateManager, vrp.getTransportCosts()));
@@ -501,8 +549,8 @@ public class VehicleRoutingAlgorithms {
metaAlgorithm.getSearchStrategyManager().addSearchStrategyModuleListener(new VehicleSwitched(vehicleFleetManager));
//define prematureBreak
- PrematureAlgorithmBreaker prematureAlgoBreaker = getPrematureBreaker(config,algorithmListeners);
- metaAlgorithm.setPrematureAlgorithmBreaker(prematureAlgoBreaker);
+ PrematureAlgorithmTermination prematureAlgoBreaker = getPrematureBreaker(config,algorithmListeners);
+ metaAlgorithm.setPrematureAlgorithmTermination(prematureAlgoBreaker);
//misc
algorithmListeners.add(new PrioritizedVRAListener(Priority.LOW, new SolutionVerifier()));
@@ -546,11 +594,11 @@ public class VehicleRoutingAlgorithms {
"makes sure your config file contains one of these options");
}
- private static PrematureAlgorithmBreaker getPrematureBreaker(XMLConfiguration config, Set algorithmListeners) {
+ private static PrematureAlgorithmTermination getPrematureBreaker(XMLConfiguration config, Set algorithmListeners) {
String basedOn = config.getString("prematureBreak[@basedOn]");
if(basedOn == null){
log.info("set default prematureBreak, i.e. no premature break at all.");
- return new PrematureAlgorithmBreaker() {
+ return new PrematureAlgorithmTermination() {
@Override
public boolean isPrematureBreak(DiscoveredSolution discoveredSolution) {
@@ -563,14 +611,14 @@ public class VehicleRoutingAlgorithms {
String iter = config.getString("prematureBreak.iterations");
if(iter == null) throw new IllegalStateException("prematureBreak.iterations is missing");
int iterations = Integer.valueOf(iter);
- return new IterationWithoutImprovementBreaker(iterations);
+ return new IterationWithoutImprovementTermination(iterations);
}
if(basedOn.equals("time")){
log.info("set prematureBreak based on time");
String timeString = config.getString("prematureBreak.time");
if(timeString == null) throw new IllegalStateException("prematureBreak.time is missing");
double time = Double.valueOf(timeString);
- TimeBreaker timeBreaker = new TimeBreaker(time);
+ TimeTermination timeBreaker = new TimeTermination(time);
algorithmListeners.add(new PrioritizedVRAListener(Priority.LOW, timeBreaker));
return timeBreaker;
}
@@ -582,7 +630,7 @@ public class VehicleRoutingAlgorithms {
if(iterationsString == null) throw new IllegalStateException("prematureBreak.iterations is missing");
double threshold = Double.valueOf(thresholdString);
int iterations = Integer.valueOf(iterationsString);
- VariationCoefficientBreaker variationCoefficientBreaker = new VariationCoefficientBreaker(iterations, threshold);
+ VariationCoefficientTermination variationCoefficientBreaker = new VariationCoefficientTermination(iterations, threshold);
algorithmListeners.add(new PrioritizedVRAListener(Priority.LOW, variationCoefficientBreaker));
return variationCoefficientBreaker;
}
@@ -687,7 +735,7 @@ public class VehicleRoutingAlgorithms {
SolutionAcceptor definedAcceptor = typedMap.get(acceptorKey);
if(definedAcceptor != null) return definedAcceptor;
if(acceptorName.equals("acceptNewRemoveWorst")){
- AcceptNewIfBetterThanWorst acceptor = new AcceptNewIfBetterThanWorst(solutionMemory);
+ GreedyAcceptance acceptor = new GreedyAcceptance(solutionMemory);
typedMap.put(acceptorKey, acceptor);
return acceptor;
}
@@ -696,6 +744,16 @@ public class VehicleRoutingAlgorithms {
typedMap.put(acceptorKey, acceptor);
return acceptor;
}
+ if(acceptorName.equals("greedyAcceptance")){
+ GreedyAcceptance acceptor = new GreedyAcceptance(solutionMemory);
+ 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")){
int iterOfSchrimpf = strategyConfig.getInt("acceptor.warmup");
double alpha = strategyConfig.getDouble("acceptor.alpha");
@@ -704,6 +762,14 @@ public class VehicleRoutingAlgorithms {
typedMap.put(acceptorKey, schrimpf);
return schrimpf;
}
+ if(acceptorName.equals("experimentalSchrimpfAcceptance")){
+ int iterOfSchrimpf = strategyConfig.getInt("acceptor.warmup");
+ double alpha = strategyConfig.getDouble("acceptor.alpha");
+ ExperimentalSchrimpfAcceptance schrimpf = new ExperimentalSchrimpfAcceptance(solutionMemory, alpha, iterOfSchrimpf);
+ algorithmListeners.add(new PrioritizedVRAListener(Priority.LOW, schrimpf));
+ typedMap.put(acceptorKey, schrimpf);
+ return schrimpf;
+ }
else{
throw new IllegalStateException("solution acceptor " + acceptorName + " is not known");
}
@@ -735,7 +801,7 @@ public class VehicleRoutingAlgorithms {
}
else if(ruin_name.equals("radialRuin")){
String ruin_distance = moduleConfig.getString("ruin.distance");
- JobDistance jobDistance = new AvgJobDistance(vrp.getTransportCosts());
+ JobDistance jobDistance = new AvgServiceAndShipmentDistance(vrp.getTransportCosts());
// if(ruin_distance == null) jobDistance
// else {
// if(ruin_distance.equals("euclidean")){
@@ -768,39 +834,40 @@ public class VehicleRoutingAlgorithms {
return rrModule;
}
if(moduleName.equals("gendreau")){
- int iterations = moduleConfig.getInt("iterations");
- double share = moduleConfig.getDouble("share");
- String ruinName = moduleConfig.getString("ruin[@name]");
- if(ruinName == null) throw new IllegalStateException("gendreau.ruin[@name] is missing. set it to \"radialRuin\" or \"randomRuin\"");
- String ruinId = moduleConfig.getString("ruin[@id]");
- if(ruinId == null) ruinId = "noId";
- ModKey ruinKey = makeKey(ruinName,ruinId);
- RuinStrategyKey stratKey = new RuinStrategyKey(ruinKey);
- RuinStrategy ruin = definedClasses.get(stratKey);
- if(ruin == null){
- ruin = new RuinRadial(vrp, 0.3, new AvgJobDistance(vrp.getTransportCosts()));
- definedClasses.put(stratKey, ruin);
- }
-
- String insertionName = moduleConfig.getString("insertion[@name]");
- if(insertionName == null) throw new IllegalStateException("gendreau.insertion[@name] is missing. set it to \"regretInsertion\" or \"bestInsertion\"");
- String insertionId = moduleConfig.getString("insertion[@id]");
- if(insertionId == null) insertionId = "noId";
- ModKey insertionKey = makeKey(insertionName,insertionId);
- InsertionStrategyKey insertionStrategyKey = new InsertionStrategyKey(insertionKey);
- InsertionStrategy insertion = definedClasses.get(insertionStrategyKey);
- if(insertion == null){
- List insertionConfigs = moduleConfig.configurationsAt("insertion");
- if(insertionConfigs.size() != 1) throw new IllegalStateException("this should be 1");
- List prioListeners = new ArrayList();
- insertion = createInsertionStrategy(insertionConfigs.get(0), vrp, vehicleFleetManager, routeStates, prioListeners, executorService, nuOfThreads, constraintManager);
- algorithmListeners.addAll(prioListeners);
- }
- Gendreau gendreau = new Gendreau(vrp, ruin, insertion, vehicleFleetManager);
- gendreau.setShareOfJobsToRuin(share);
- gendreau.setNuOfIterations(iterations);
- definedClasses.put(strategyModuleKey, gendreau);
- return gendreau;
+ throw new UnsupportedOperationException("gendreau is not supported yet");
+// int iterations = moduleConfig.getInt("iterations");
+// double share = moduleConfig.getDouble("share");
+// String ruinName = moduleConfig.getString("ruin[@name]");
+// if(ruinName == null) throw new IllegalStateException("gendreau.ruin[@name] is missing. set it to \"radialRuin\" or \"randomRuin\"");
+// String ruinId = moduleConfig.getString("ruin[@id]");
+// if(ruinId == null) ruinId = "noId";
+// ModKey ruinKey = makeKey(ruinName,ruinId);
+// RuinStrategyKey stratKey = new RuinStrategyKey(ruinKey);
+// RuinStrategy ruin = definedClasses.get(stratKey);
+// if(ruin == null){
+// ruin = new RadialRuinStrategyFactory(0.3, new AvgJobDistance(vrp.getTransportCosts())).createStrategy(vrp);
+// definedClasses.put(stratKey, ruin);
+// }
+//
+// String insertionName = moduleConfig.getString("insertion[@name]");
+// if(insertionName == null) throw new IllegalStateException("gendreau.insertion[@name] is missing. set it to \"regretInsertion\" or \"bestInsertion\"");
+// String insertionId = moduleConfig.getString("insertion[@id]");
+// if(insertionId == null) insertionId = "noId";
+// ModKey insertionKey = makeKey(insertionName,insertionId);
+// InsertionStrategyKey insertionStrategyKey = new InsertionStrategyKey(insertionKey);
+// InsertionStrategy insertion = definedClasses.get(insertionStrategyKey);
+// if(insertion == null){
+// List insertionConfigs = moduleConfig.configurationsAt("insertion");
+// if(insertionConfigs.size() != 1) throw new IllegalStateException("this should be 1");
+// List prioListeners = new ArrayList();
+// insertion = createInsertionStrategy(insertionConfigs.get(0), vrp, vehicleFleetManager, routeStates, prioListeners, executorService, nuOfThreads, constraintManager);
+// algorithmListeners.addAll(prioListeners);
+// }
+// Gendreau gendreau = new Gendreau(vrp, ruin, insertion, vehicleFleetManager);
+// gendreau.setShareOfJobsToRuin(share);
+// gendreau.setNuOfIterations(iterations);
+// definedClasses.put(strategyModuleKey, gendreau);
+// return gendreau;
}
throw new NullPointerException("no module found with moduleName=" + moduleName +
"\n\tcheck config whether the correct names are used" +
@@ -815,7 +882,7 @@ public class VehicleRoutingAlgorithms {
RuinStrategyKey stratKey = new RuinStrategyKey(modKey);
RuinStrategy ruin = definedClasses.get(stratKey);
if(ruin == null){
- ruin = new RuinRadial(vrp, shareToRuin, jobDistance);
+ ruin = new RadialRuinStrategyFactory(shareToRuin, jobDistance).createStrategy(vrp);
definedClasses.put(stratKey, ruin);
}
return ruin;
@@ -825,7 +892,7 @@ public class VehicleRoutingAlgorithms {
RuinStrategyKey stratKey = new RuinStrategyKey(modKey);
RuinStrategy ruin = definedClasses.get(stratKey);
if(ruin == null){
- ruin = new RuinRandom(vrp, shareToRuin);
+ ruin = new RandomRuinStrategyFactory(shareToRuin).createStrategy(vrp);
definedClasses.put(stratKey, ruin);
}
return ruin;
diff --git a/jsprit-core/src/main/java/basics/algo/AlgorithmEndsListener.java b/jsprit-core/src/main/java/jsprit/core/algorithm/listener/AlgorithmEndsListener.java
similarity index 87%
rename from jsprit-core/src/main/java/basics/algo/AlgorithmEndsListener.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/listener/AlgorithmEndsListener.java
index 87142e9b..fc0a617b 100644
--- a/jsprit-core/src/main/java/basics/algo/AlgorithmEndsListener.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/listener/AlgorithmEndsListener.java
@@ -14,12 +14,13 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics.algo;
+package jsprit.core.algorithm.listener;
import java.util.Collection;
-import basics.VehicleRoutingProblem;
-import basics.VehicleRoutingProblemSolution;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+
diff --git a/jsprit-core/src/main/java/basics/algo/AlgorithmStartsListener.java b/jsprit-core/src/main/java/jsprit/core/algorithm/listener/AlgorithmStartsListener.java
similarity index 84%
rename from jsprit-core/src/main/java/basics/algo/AlgorithmStartsListener.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/listener/AlgorithmStartsListener.java
index e244b9e3..9b917808 100644
--- a/jsprit-core/src/main/java/basics/algo/AlgorithmStartsListener.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/listener/AlgorithmStartsListener.java
@@ -14,13 +14,14 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics.algo;
+package jsprit.core.algorithm.listener;
import java.util.Collection;
-import basics.VehicleRoutingAlgorithm;
-import basics.VehicleRoutingProblem;
-import basics.VehicleRoutingProblemSolution;
+import jsprit.core.algorithm.VehicleRoutingAlgorithm;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+
diff --git a/jsprit-core/src/main/java/basics/algo/IterationEndsListener.java b/jsprit-core/src/main/java/jsprit/core/algorithm/listener/IterationEndsListener.java
similarity index 87%
rename from jsprit-core/src/main/java/basics/algo/IterationEndsListener.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/listener/IterationEndsListener.java
index 7aaf6b9f..6c70c24f 100644
--- a/jsprit-core/src/main/java/basics/algo/IterationEndsListener.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/listener/IterationEndsListener.java
@@ -14,12 +14,13 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics.algo;
+package jsprit.core.algorithm.listener;
import java.util.Collection;
-import basics.VehicleRoutingProblem;
-import basics.VehicleRoutingProblemSolution;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+
diff --git a/jsprit-core/src/main/java/basics/algo/IterationStartsListener.java b/jsprit-core/src/main/java/jsprit/core/algorithm/listener/IterationStartsListener.java
similarity index 87%
rename from jsprit-core/src/main/java/basics/algo/IterationStartsListener.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/listener/IterationStartsListener.java
index db7610fc..a8d492c1 100644
--- a/jsprit-core/src/main/java/basics/algo/IterationStartsListener.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/listener/IterationStartsListener.java
@@ -14,12 +14,13 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics.algo;
+package jsprit.core.algorithm.listener;
import java.util.Collection;
-import basics.VehicleRoutingProblem;
-import basics.VehicleRoutingProblemSolution;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+
diff --git a/jsprit-core/src/main/java/basics/algo/SearchStrategyListener.java b/jsprit-core/src/main/java/jsprit/core/algorithm/listener/SearchStrategyListener.java
similarity index 96%
rename from jsprit-core/src/main/java/basics/algo/SearchStrategyListener.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/listener/SearchStrategyListener.java
index 0d47246b..d4983bb9 100644
--- a/jsprit-core/src/main/java/basics/algo/SearchStrategyListener.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/listener/SearchStrategyListener.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics.algo;
+package jsprit.core.algorithm.listener;
public interface SearchStrategyListener extends VehicleRoutingAlgorithmListener{
diff --git a/jsprit-core/src/main/java/basics/algo/SearchStrategyModuleListener.java b/jsprit-core/src/main/java/jsprit/core/algorithm/listener/SearchStrategyModuleListener.java
similarity index 96%
rename from jsprit-core/src/main/java/basics/algo/SearchStrategyModuleListener.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/listener/SearchStrategyModuleListener.java
index 925585f3..58f7e737 100644
--- a/jsprit-core/src/main/java/basics/algo/SearchStrategyModuleListener.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/listener/SearchStrategyModuleListener.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics.algo;
+package jsprit.core.algorithm.listener;
public interface SearchStrategyModuleListener extends VehicleRoutingAlgorithmListener{
diff --git a/jsprit-core/src/main/java/basics/algo/StrategySelectedListener.java b/jsprit-core/src/main/java/jsprit/core/algorithm/listener/StrategySelectedListener.java
similarity index 87%
rename from jsprit-core/src/main/java/basics/algo/StrategySelectedListener.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/listener/StrategySelectedListener.java
index 2046e6fc..79898d11 100644
--- a/jsprit-core/src/main/java/basics/algo/StrategySelectedListener.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/listener/StrategySelectedListener.java
@@ -14,12 +14,13 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics.algo;
+package jsprit.core.algorithm.listener;
import java.util.Collection;
-import basics.VehicleRoutingProblem;
-import basics.VehicleRoutingProblemSolution;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+
diff --git a/jsprit-core/src/main/java/basics/algo/VehicleRoutingAlgorithmListener.java b/jsprit-core/src/main/java/jsprit/core/algorithm/listener/VehicleRoutingAlgorithmListener.java
similarity index 95%
rename from jsprit-core/src/main/java/basics/algo/VehicleRoutingAlgorithmListener.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/listener/VehicleRoutingAlgorithmListener.java
index 957527a6..c2eaef7f 100644
--- a/jsprit-core/src/main/java/basics/algo/VehicleRoutingAlgorithmListener.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/listener/VehicleRoutingAlgorithmListener.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics.algo;
+package jsprit.core.algorithm.listener;
public interface VehicleRoutingAlgorithmListener {
diff --git a/jsprit-core/src/main/java/basics/algo/VehicleRoutingAlgorithmListeners.java b/jsprit-core/src/main/java/jsprit/core/algorithm/listener/VehicleRoutingAlgorithmListeners.java
similarity index 96%
rename from jsprit-core/src/main/java/basics/algo/VehicleRoutingAlgorithmListeners.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/listener/VehicleRoutingAlgorithmListeners.java
index 2ec3fdd8..9301c847 100644
--- a/jsprit-core/src/main/java/basics/algo/VehicleRoutingAlgorithmListeners.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/listener/VehicleRoutingAlgorithmListeners.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics.algo;
+package jsprit.core.algorithm.listener;
import java.util.ArrayList;
import java.util.Collection;
@@ -23,9 +23,10 @@ import java.util.Comparator;
import java.util.List;
import java.util.TreeSet;
-import basics.VehicleRoutingAlgorithm;
-import basics.VehicleRoutingProblem;
-import basics.VehicleRoutingProblemSolution;
+import jsprit.core.algorithm.VehicleRoutingAlgorithm;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+
diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/module/Gendreau.java b/jsprit-core/src/main/java/jsprit/core/algorithm/module/Gendreau.java
new file mode 100644
index 00000000..2a933c19
--- /dev/null
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/module/Gendreau.java
@@ -0,0 +1,224 @@
+///*******************************************************************************
+// * Copyright (C) 2013 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 jsprit.core.algorithm.module;
+//
+//import java.util.ArrayList;
+//import java.util.Arrays;
+//import java.util.Collection;
+//import java.util.Collections;
+//import java.util.HashSet;
+//import java.util.List;
+//import java.util.Random;
+//import java.util.Set;
+//
+//import jsprit.core.algorithm.SearchStrategyModule;
+//import jsprit.core.algorithm.listener.SearchStrategyModuleListener;
+//import jsprit.core.algorithm.recreate.InsertionStrategy;
+//import jsprit.core.algorithm.recreate.listener.InsertionListener;
+//import jsprit.core.algorithm.recreate.listener.InsertionListeners;
+//import jsprit.core.algorithm.ruin.RuinStrategy;
+//import jsprit.core.algorithm.ruin.listener.RuinListener;
+//import jsprit.core.problem.Job;
+//import jsprit.core.problem.VehicleRoutingProblem;
+//import jsprit.core.problem.VehicleRoutingProblemSolution;
+//import jsprit.core.problem.route.TourActivity;
+//import jsprit.core.problem.route.TourActivity.JobActivity;
+//import jsprit.core.problem.route.VehicleFleetManager;
+//import jsprit.core.problem.route.VehicleRoute;
+//import jsprit.core.util.RandomNumberGeneration;
+//
+//import org.apache.log4j.Logger;
+//
+//
+//final class Gendreau implements SearchStrategyModule{
+//
+// private final static Logger log = Logger.getLogger(Gendreau.class);
+//
+// private final static String NAME = "gendreauPostOpt";
+//
+// private final RuinStrategy ruin;
+//
+// private final VehicleRoutingProblem vrp;
+//
+// private final InsertionStrategy insertionStrategy;
+//
+// private VehicleFleetManager fleetManager;
+//
+// private Random random = RandomNumberGeneration.getRandom();
+//
+// private int nOfIterations = 10;
+//
+// private double shareOfJobsToRuin = 0.15;
+//
+// public void setShareOfJobsToRuin(double shareOfJobsToRuin) {
+// this.shareOfJobsToRuin = shareOfJobsToRuin;
+// }
+//
+// public Gendreau(VehicleRoutingProblem vrp, RuinStrategy ruin, InsertionStrategy insertionStrategy, VehicleFleetManager vehicleFleetManager) {
+// super();
+// InsertionListeners insertionListeners = new InsertionListeners();
+// insertionListeners.addAllListeners(insertionStrategy.getListeners());
+// new Inserter(insertionListeners);
+// this.ruin = ruin;
+// this.vrp = vrp;
+// this.insertionStrategy = insertionStrategy;
+// this.fleetManager = vehicleFleetManager;
+// }
+//
+// @Override
+// public String toString() {
+// return "[name=gendreau][iterations="+nOfIterations+"][share2ruin="+shareOfJobsToRuin+"]";
+// }
+//
+// public void setRandom(Random random) {
+// this.random = random;
+// }
+//
+//
+// public void setNuOfIterations(int nOfIterations) {
+// this.nOfIterations = nOfIterations;
+// }
+//
+//// public void setFleetManager(VehicleFleetManager vehicleFleetManager) {
+//// this.fleetManager = vehicleFleetManager;
+////
+//// }
+//
+// @Override
+// public VehicleRoutingProblemSolution runAndGetSolution(VehicleRoutingProblemSolution vrpSolution) {
+//// log.info("run gendreau postopt");
+// VehicleRoutingProblemSolution bestSolution = vrpSolution;
+// int itersWithoutImprovement = 0;
+//
+// for(int i=0;i copiedRoutes = copyRoutes(bestSolution.getRoutes());
+// iniFleet(copiedRoutes);
+//
+// VehicleRoute route2split = pickRouteThatHasAtLeastTwoJobs(copiedRoutes);
+// if(route2split == null) continue;
+// List jobsInRoute = getJobs(route2split);
+// Set unassignedJobs = new HashSet();
+// unassignedJobs.addAll(jobsInRoute);
+// copiedRoutes.remove(route2split);
+//
+// Collections.shuffle(jobsInRoute,random);
+// Job targetJob = jobsInRoute.get(0);
+// int nOfJobs2BeRemovedAdditionally = (int) (shareOfJobsToRuin*(double)vrp.getJobs().size());
+// Collection unassignedJobsList = ruin.ruin(copiedRoutes, targetJob, nOfJobs2BeRemovedAdditionally);
+// unassignedJobs.addAll(unassignedJobsList);
+//
+// VehicleRoute emptyRoute1 = VehicleRoute.emptyRoute();
+// copiedRoutes.add(emptyRoute1);
+// insertionStrategy.insertJobs(Arrays.asList(emptyRoute1), Arrays.asList(targetJob));
+//
+// unassignedJobs.remove(targetJob);
+//
+// VehicleRoute emptyRoute2 = VehicleRoute.emptyRoute();
+// copiedRoutes.add(emptyRoute2);
+// Job job2 = jobsInRoute.get(1);
+// insertionStrategy.insertJobs(Arrays.asList(emptyRoute2), Arrays.asList(job2));
+//
+// unassignedJobs.remove(job2);
+//
+// insertionStrategy.insertJobs(copiedRoutes, unassignedJobs);
+// double cost = getCost(copiedRoutes);
+//
+// if(cost < bestSolution.getCost()){
+//// log.info("BING - new: " + cost + " old: " + bestSolution.getCost());
+// bestSolution = new VehicleRoutingProblemSolution(copiedRoutes, cost);
+// itersWithoutImprovement=0;
+// }
+// else{
+// itersWithoutImprovement++;
+// if(itersWithoutImprovement > 200){
+//// log.info("BREAK i="+i);
+// break;
+// }
+// }
+// }
+// return bestSolution;
+// }
+//
+// private List copyRoutes(Collection routes) {
+// List routeList = new ArrayList();
+// for(VehicleRoute r : routes){
+// routeList.add(VehicleRoute.copyOf(r));
+// }
+// return routeList;
+// }
+//
+// private void iniFleet(Collection routes) {
+// fleetManager.unlockAll();
+// for(VehicleRoute route : routes){
+// if(!route.isEmpty()){
+// fleetManager.lock(route.getVehicle());
+// }
+// }
+// }
+//
+// private double getCost(Collection routes) {
+// double c = 0.0;
+// for(VehicleRoute r : routes){
+// c+=r.getCost();
+// }
+// return c;
+// }
+//
+// private List getJobs(VehicleRoute route2split) {
+// Set jobs = new HashSet();
+// for(TourActivity act : route2split.getTourActivities().getActivities()){
+// if(act instanceof JobActivity){
+// jobs.add(((JobActivity) act).getJob());
+// }
+// }
+// return new ArrayList(jobs);
+// }
+//
+// private VehicleRoute pickRouteThatHasAtLeastTwoJobs(Collection routeList) {
+// List routes = new ArrayList();
+// for(VehicleRoute r : routeList){
+// if(getJobs(r).size() > 1){
+// routes.add(r);
+// }
+// }
+// if(routes.isEmpty()) return null;
+// Collections.shuffle(routes,random);
+// return routes.get(0);
+// }
+//
+// @Override
+// public String getName() {
+// return NAME;
+// }
+//
+// @Override
+// public void addModuleListener(SearchStrategyModuleListener moduleListener) {
+// if(moduleListener instanceof InsertionListener){
+// InsertionListener iListener = (InsertionListener) moduleListener;
+// if(!insertionStrategy.getListeners().contains(iListener)){
+// insertionStrategy.addListener(iListener);
+// }
+// }
+// if(moduleListener instanceof RuinListener){
+// RuinListener rListener = (RuinListener) moduleListener;
+// if(!ruin.getListeners().contains(rListener)){
+// ruin.addListener(rListener);
+// }
+// }
+//
+// }
+//}
diff --git a/jsprit-core/src/main/java/algorithms/RuinAndRecreateModule.java b/jsprit-core/src/main/java/jsprit/core/algorithm/module/RuinAndRecreateModule.java
similarity index 81%
rename from jsprit-core/src/main/java/algorithms/RuinAndRecreateModule.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/module/RuinAndRecreateModule.java
index 53703592..29f79a1e 100644
--- a/jsprit-core/src/main/java/algorithms/RuinAndRecreateModule.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/module/RuinAndRecreateModule.java
@@ -14,16 +14,19 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.module;
import java.util.Collection;
-import basics.Job;
-import basics.VehicleRoutingProblemSolution;
-import basics.algo.InsertionListener;
-import basics.algo.RuinListener;
-import basics.algo.SearchStrategyModule;
-import basics.algo.SearchStrategyModuleListener;
+import jsprit.core.algorithm.SearchStrategyModule;
+import jsprit.core.algorithm.listener.SearchStrategyModuleListener;
+import jsprit.core.algorithm.recreate.InsertionStrategy;
+import jsprit.core.algorithm.recreate.listener.InsertionListener;
+import jsprit.core.algorithm.ruin.RuinStrategy;
+import jsprit.core.algorithm.ruin.listener.RuinListener;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+
public class RuinAndRecreateModule implements SearchStrategyModule{
diff --git a/jsprit-core/src/main/java/algorithms/ActivityInsertionCostsCalculator.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/ActivityInsertionCostsCalculator.java
similarity index 83%
rename from jsprit-core/src/main/java/algorithms/ActivityInsertionCostsCalculator.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/ActivityInsertionCostsCalculator.java
index bed0a9c5..681c9366 100644
--- a/jsprit-core/src/main/java/algorithms/ActivityInsertionCostsCalculator.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/ActivityInsertionCostsCalculator.java
@@ -18,9 +18,10 @@
* Contributors:
* Stefan Schroeder - initial API and implementation
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.recreate;
-import basics.route.TourActivity;
+import jsprit.core.problem.misc.JobInsertionContext;
+import jsprit.core.problem.solution.route.activity.TourActivity;
public interface ActivityInsertionCostsCalculator {
@@ -50,6 +51,6 @@ public interface ActivityInsertionCostsCalculator {
}
- public ActivityInsertionCosts getCosts(InsertionContext iContext, TourActivity prevAct, TourActivity nextAct, TourActivity newAct, double depTimeAtPrevAct);
+ public ActivityInsertionCosts getCosts(JobInsertionContext iContext, TourActivity prevAct, TourActivity nextAct, TourActivity newAct, double depTimeAtPrevAct);
}
diff --git a/jsprit-core/src/main/java/algorithms/AuxilliaryCostCalculator.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/AuxilliaryCostCalculator.java
similarity index 92%
rename from jsprit-core/src/main/java/algorithms/AuxilliaryCostCalculator.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/AuxilliaryCostCalculator.java
index bbb1f091..2ff04582 100644
--- a/jsprit-core/src/main/java/algorithms/AuxilliaryCostCalculator.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/AuxilliaryCostCalculator.java
@@ -14,16 +14,17 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.recreate;
import java.util.Iterator;
import java.util.List;
-import basics.costs.VehicleRoutingActivityCosts;
-import basics.costs.VehicleRoutingTransportCosts;
-import basics.route.Driver;
-import basics.route.TourActivity;
-import basics.route.Vehicle;
+import jsprit.core.problem.cost.VehicleRoutingActivityCosts;
+import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
+import jsprit.core.problem.driver.Driver;
+import jsprit.core.problem.solution.route.activity.TourActivity;
+import jsprit.core.problem.vehicle.Vehicle;
+
final class AuxilliaryCostCalculator {
diff --git a/jsprit-core/src/main/java/algorithms/BestInsertion.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/BestInsertion.java
similarity index 92%
rename from jsprit-core/src/main/java/algorithms/BestInsertion.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/BestInsertion.java
index f5e7b506..10cea48e 100644
--- a/jsprit-core/src/main/java/algorithms/BestInsertion.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/BestInsertion.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.recreate;
import java.util.ArrayList;
import java.util.Collection;
@@ -22,15 +22,17 @@ import java.util.Collections;
import java.util.List;
import java.util.Random;
+import jsprit.core.algorithm.recreate.InsertionData.NoInsertionFound;
+import jsprit.core.algorithm.recreate.listener.InsertionListener;
+import jsprit.core.algorithm.recreate.listener.InsertionListeners;
+import jsprit.core.problem.driver.Driver;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.vehicle.Vehicle;
+import jsprit.core.util.RandomNumberGeneration;
+
import org.apache.log4j.Logger;
-import util.RandomNumberGeneration;
-import algorithms.InsertionData.NoInsertionFound;
-import basics.Job;
-import basics.algo.InsertionListener;
-import basics.route.Driver;
-import basics.route.Vehicle;
-import basics.route.VehicleRoute;
diff --git a/jsprit-core/src/main/java/algorithms/BestInsertionBuilder.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/BestInsertionBuilder.java
similarity index 76%
rename from jsprit-core/src/main/java/algorithms/BestInsertionBuilder.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/BestInsertionBuilder.java
index 424acce7..5d115c69 100644
--- a/jsprit-core/src/main/java/algorithms/BestInsertionBuilder.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/BestInsertionBuilder.java
@@ -1,13 +1,16 @@
-package algorithms;
+package jsprit.core.algorithm.recreate;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
-import basics.VehicleRoutingProblem;
-import basics.algo.InsertionListener;
-import basics.algo.VehicleRoutingAlgorithmListeners.PrioritizedVRAListener;
-import basics.route.VehicleFleetManager;
+import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners.PrioritizedVRAListener;
+import jsprit.core.algorithm.recreate.listener.InsertionListener;
+import jsprit.core.algorithm.state.StateManager;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.constraint.ConstraintManager;
+import jsprit.core.problem.vehicle.VehicleFleetManager;
+
public class BestInsertionBuilder {
@@ -34,6 +37,12 @@ public class BestInsertionBuilder {
private ExecutorService executor;
private int nuOfThreads;
+
+ private double timeSlice;
+
+ private int nNeighbors;
+
+ private boolean timeScheduling=false;
public BestInsertionBuilder(VehicleRoutingProblem vrp, VehicleFleetManager vehicleFleetManager, StateManager stateManager, ConstraintManager constraintManager) {
super();
@@ -92,6 +101,9 @@ public class BestInsertionBuilder {
if(considerFixedCosts) {
calcBuilder.considerFixedCosts(weightOfFixedCosts);
}
+ if(timeScheduling){
+ calcBuilder.experimentalTimeScheduler(timeSlice, nNeighbors);
+ }
JobInsertionCostsCalculator jobInsertions = calcBuilder.build();
InsertionStrategy bestInsertion;
if(executor == null){
@@ -107,6 +119,18 @@ public class BestInsertionBuilder {
return bestInsertion;
}
+ /**
+ * @deprecated this is experimental and can disappear.
+ * @param parseDouble
+ * @param parseInt
+ */
+ @Deprecated
+ public void experimentalTimeScheduler(double timeSlice, int nNeighbors) {
+ this.timeSlice=timeSlice;
+ this.nNeighbors=nNeighbors;
+ timeScheduling=true;
+ }
+
diff --git a/jsprit-core/src/main/java/algorithms/BestInsertionConcurrent.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/BestInsertionConcurrent.java
similarity index 94%
rename from jsprit-core/src/main/java/algorithms/BestInsertionConcurrent.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/BestInsertionConcurrent.java
index afb37573..1cbf0113 100644
--- a/jsprit-core/src/main/java/algorithms/BestInsertionConcurrent.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/BestInsertionConcurrent.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.recreate;
import java.util.ArrayList;
import java.util.Collection;
@@ -27,15 +27,17 @@ import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
+import jsprit.core.algorithm.recreate.InsertionData.NoInsertionFound;
+import jsprit.core.algorithm.recreate.listener.InsertionListener;
+import jsprit.core.algorithm.recreate.listener.InsertionListeners;
+import jsprit.core.problem.driver.Driver;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.vehicle.Vehicle;
+import jsprit.core.util.RandomNumberGeneration;
+
import org.apache.log4j.Logger;
-import util.RandomNumberGeneration;
-import algorithms.InsertionData.NoInsertionFound;
-import basics.Job;
-import basics.algo.InsertionListener;
-import basics.route.Driver;
-import basics.route.Vehicle;
-import basics.route.VehicleRoute;
@@ -170,7 +172,7 @@ final class BestInsertionConcurrent implements InsertionStrategy{
bestInsertion = new Insertion(newRoute,newIData);
bestInsertionCost = newIData.getInsertionCost();
vehicleRoutes.add(newRoute);
- batches.get(0).routes.add(newRoute);
+ batches.get(random.nextInt(batches.size())).routes.add(newRoute);
}
}
diff --git a/jsprit-core/src/main/java/algorithms/CalculatesServiceInsertionWithTimeScheduling.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/CalculatesServiceInsertionWithTimeScheduling.java
similarity index 93%
rename from jsprit-core/src/main/java/algorithms/CalculatesServiceInsertionWithTimeScheduling.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/CalculatesServiceInsertionWithTimeScheduling.java
index 13ec9da2..a879fe06 100644
--- a/jsprit-core/src/main/java/algorithms/CalculatesServiceInsertionWithTimeScheduling.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/CalculatesServiceInsertionWithTimeScheduling.java
@@ -14,18 +14,19 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.recreate;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
+import jsprit.core.problem.driver.Driver;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.vehicle.Vehicle;
+
import org.apache.log4j.Logger;
-import basics.Job;
-import basics.route.Driver;
-import basics.route.Vehicle;
-import basics.route.VehicleRoute;
class CalculatesServiceInsertionWithTimeScheduling implements JobInsertionCostsCalculator{
diff --git a/jsprit-core/src/main/java/algorithms/CalculatorBuilder.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/CalculatorBuilder.java
similarity index 90%
rename from jsprit-core/src/main/java/algorithms/CalculatorBuilder.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/CalculatorBuilder.java
index b82b7d25..f078a338 100644
--- a/jsprit-core/src/main/java/algorithms/CalculatorBuilder.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/CalculatorBuilder.java
@@ -14,20 +14,23 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.recreate;
import java.util.ArrayList;
import java.util.List;
-import basics.Delivery;
-import basics.Job;
-import basics.Pickup;
-import basics.Service;
-import basics.Shipment;
-import basics.VehicleRoutingProblem;
-import basics.algo.InsertionListener;
-import basics.algo.VehicleRoutingAlgorithmListeners.PrioritizedVRAListener;
-import basics.route.VehicleFleetManager;
+import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners.PrioritizedVRAListener;
+import jsprit.core.algorithm.recreate.listener.InsertionListener;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.constraint.ConstraintManager;
+import jsprit.core.problem.job.Delivery;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.job.Pickup;
+import jsprit.core.problem.job.Service;
+import jsprit.core.problem.job.Shipment;
+import jsprit.core.problem.solution.route.state.RouteAndActivityStateGetter;
+import jsprit.core.problem.vehicle.VehicleFleetManager;
+
@@ -64,7 +67,7 @@ class CalculatorBuilder {
private VehicleRoutingProblem vrp;
- private StateGetter states;
+ private RouteAndActivityStateGetter states;
private boolean local = true;
@@ -109,7 +112,7 @@ class CalculatorBuilder {
*
* @return
*/
- public CalculatorBuilder setStates(StateGetter states){
+ public CalculatorBuilder setStates(RouteAndActivityStateGetter states){
this.states = states;
return this;
}
@@ -235,7 +238,7 @@ class CalculatorBuilder {
}
}
- private CalculatorPlusListeners createStandardLocal(VehicleRoutingProblem vrp, StateGetter statesManager){
+ private CalculatorPlusListeners createStandardLocal(VehicleRoutingProblem vrp, RouteAndActivityStateGetter statesManager){
if(constraintManager == null) throw new IllegalStateException("constraint-manager is null");
@@ -263,7 +266,7 @@ class CalculatorBuilder {
return calcPlusListeners;
}
- private CalculatorPlusListeners createCalculatorConsideringFixedCosts(VehicleRoutingProblem vrp, JobInsertionCostsCalculator baseCalculator, StateGetter activityStates2, double weightOfFixedCosts){
+ private CalculatorPlusListeners createCalculatorConsideringFixedCosts(VehicleRoutingProblem vrp, JobInsertionCostsCalculator baseCalculator, RouteAndActivityStateGetter activityStates2, double weightOfFixedCosts){
final JobInsertionConsideringFixCostsCalculator withFixCost = new JobInsertionConsideringFixCostsCalculator(baseCalculator, activityStates2);
withFixCost.setWeightOfFixCost(weightOfFixedCosts);
CalculatorPlusListeners calcPlusListeners = new CalculatorPlusListeners(withFixCost);
@@ -271,7 +274,7 @@ class CalculatorBuilder {
return calcPlusListeners;
}
- private CalculatorPlusListeners createStandardRoute(VehicleRoutingProblem vrp, StateGetter activityStates2, int forwardLooking, int solutionMemory){
+ private CalculatorPlusListeners createStandardRoute(VehicleRoutingProblem vrp, RouteAndActivityStateGetter activityStates2, int forwardLooking, int solutionMemory){
int after = forwardLooking;
ActivityInsertionCostsCalculator routeLevelCostEstimator;
if(activityInsertionCostCalculator == null){
@@ -289,7 +292,7 @@ class CalculatorBuilder {
return calcPlusListener;
}
- private JobInsertionCostsCalculator createFinalInsertion(VehicleFleetManager fleetManager, JobInsertionCostsCalculator baseCalc, StateGetter activityStates2){
+ private JobInsertionCostsCalculator createFinalInsertion(VehicleFleetManager fleetManager, JobInsertionCostsCalculator baseCalc, RouteAndActivityStateGetter activityStates2){
return new VehicleTypeDependentJobInsertionCalculator(fleetManager, baseCalc);
}
diff --git a/jsprit-core/src/main/java/algorithms/ConfigureFixCostCalculator.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/ConfigureFixCostCalculator.java
similarity index 87%
rename from jsprit-core/src/main/java/algorithms/ConfigureFixCostCalculator.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/ConfigureFixCostCalculator.java
index ed9fb977..c0d3316a 100644
--- a/jsprit-core/src/main/java/algorithms/ConfigureFixCostCalculator.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/ConfigureFixCostCalculator.java
@@ -14,18 +14,19 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.recreate;
import java.util.Collection;
+import jsprit.core.algorithm.recreate.listener.InsertionStartsListener;
+import jsprit.core.algorithm.recreate.listener.JobInsertedListener;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.solution.route.VehicleRoute;
+
import org.apache.log4j.Logger;
-import basics.Job;
-import basics.VehicleRoutingProblem;
-import basics.algo.InsertionStartsListener;
-import basics.algo.JobInsertedListener;
-import basics.route.VehicleRoute;
diff --git a/jsprit-core/src/main/java/algorithms/Inserter.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/Inserter.java
similarity index 86%
rename from jsprit-core/src/main/java/algorithms/Inserter.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/Inserter.java
index afe677ba..6e73e670 100644
--- a/jsprit-core/src/main/java/algorithms/Inserter.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/Inserter.java
@@ -14,18 +14,19 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.recreate;
-import algorithms.InsertionData.NoInsertionFound;
-import basics.Job;
-import basics.Service;
-import basics.Shipment;
-import basics.route.DefaultShipmentActivityFactory;
-import basics.route.DefaultTourActivityFactory;
-import basics.route.TourActivity;
-import basics.route.TourActivityFactory;
-import basics.route.TourShipmentActivityFactory;
-import basics.route.VehicleRoute;
+import jsprit.core.algorithm.recreate.InsertionData.NoInsertionFound;
+import jsprit.core.algorithm.recreate.listener.InsertionListeners;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.job.Service;
+import jsprit.core.problem.job.Shipment;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.solution.route.activity.DefaultShipmentActivityFactory;
+import jsprit.core.problem.solution.route.activity.DefaultTourActivityFactory;
+import jsprit.core.problem.solution.route.activity.TourActivity;
+import jsprit.core.problem.solution.route.activity.TourActivityFactory;
+import jsprit.core.problem.solution.route.activity.TourShipmentActivityFactory;
class Inserter {
diff --git a/jsprit-core/src/main/java/algorithms/InsertionData.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/InsertionData.java
similarity index 97%
rename from jsprit-core/src/main/java/algorithms/InsertionData.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/InsertionData.java
index e033684d..147eb80c 100644
--- a/jsprit-core/src/main/java/algorithms/InsertionData.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/InsertionData.java
@@ -14,10 +14,10 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.recreate;
-import basics.route.Driver;
-import basics.route.Vehicle;
+import jsprit.core.problem.driver.Driver;
+import jsprit.core.problem.vehicle.Vehicle;
/**
* Data object that collects insertion information. It collects insertionCosts, insertionIndeces, vehicle and driver to be employed
diff --git a/jsprit-core/src/main/java/algorithms/InsertionStrategy.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/InsertionStrategy.java
similarity index 87%
rename from jsprit-core/src/main/java/algorithms/InsertionStrategy.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/InsertionStrategy.java
index 17c84fad..b7f77521 100644
--- a/jsprit-core/src/main/java/algorithms/InsertionStrategy.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/InsertionStrategy.java
@@ -14,13 +14,14 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.recreate;
import java.util.Collection;
-import basics.Job;
-import basics.algo.InsertionListener;
-import basics.route.VehicleRoute;
+import jsprit.core.algorithm.recreate.listener.InsertionListener;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.solution.route.VehicleRoute;
+
diff --git a/jsprit-core/src/main/java/algorithms/InsertionStrategyFactory.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/InsertionStrategyFactory.java
similarity index 91%
rename from jsprit-core/src/main/java/algorithms/InsertionStrategyFactory.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/InsertionStrategyFactory.java
index 024a8615..8c36e9a0 100644
--- a/jsprit-core/src/main/java/algorithms/InsertionStrategyFactory.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/InsertionStrategyFactory.java
@@ -14,9 +14,9 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.recreate;
-import basics.VehicleRoutingProblem;
+import jsprit.core.problem.VehicleRoutingProblem;
public interface InsertionStrategyFactory {
diff --git a/jsprit-core/src/main/java/algorithms/JobCalculatorSwitcher.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/JobCalculatorSwitcher.java
similarity index 73%
rename from jsprit-core/src/main/java/algorithms/JobCalculatorSwitcher.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/JobCalculatorSwitcher.java
index da3485b8..a4858749 100644
--- a/jsprit-core/src/main/java/algorithms/JobCalculatorSwitcher.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/JobCalculatorSwitcher.java
@@ -1,14 +1,15 @@
-package algorithms;
+package jsprit.core.algorithm.recreate;
import java.util.HashMap;
import java.util.Map;
-import basics.Job;
-import basics.route.Driver;
-import basics.route.Vehicle;
-import basics.route.VehicleRoute;
+import jsprit.core.problem.driver.Driver;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.vehicle.Vehicle;
-public class JobCalculatorSwitcher implements JobInsertionCostsCalculator{
+
+class JobCalculatorSwitcher implements JobInsertionCostsCalculator{
private Map,JobInsertionCostsCalculator> calcMap = new HashMap, JobInsertionCostsCalculator>();
diff --git a/jsprit-core/src/main/java/algorithms/JobInsertionConsideringFixCostsCalculator.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/JobInsertionConsideringFixCostsCalculator.java
similarity index 87%
rename from jsprit-core/src/main/java/algorithms/JobInsertionConsideringFixCostsCalculator.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/JobInsertionConsideringFixCostsCalculator.java
index 87c70abb..5537649e 100644
--- a/jsprit-core/src/main/java/algorithms/JobInsertionConsideringFixCostsCalculator.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/JobInsertionConsideringFixCostsCalculator.java
@@ -14,16 +14,19 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.recreate;
+
+import jsprit.core.algorithm.recreate.InsertionData.NoInsertionFound;
+import jsprit.core.problem.driver.Driver;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.solution.route.state.RouteAndActivityStateGetter;
+import jsprit.core.problem.solution.route.state.StateFactory;
+import jsprit.core.problem.vehicle.Vehicle;
+import jsprit.core.problem.vehicle.VehicleImpl.NoVehicle;
import org.apache.log4j.Logger;
-import algorithms.InsertionData.NoInsertionFound;
-import basics.Job;
-import basics.route.Driver;
-import basics.route.Vehicle;
-import basics.route.VehicleImpl.NoVehicle;
-import basics.route.VehicleRoute;
@@ -37,9 +40,9 @@ final class JobInsertionConsideringFixCostsCalculator implements JobInsertionCos
private double solution_completeness_ratio = 0.5;
- private StateGetter stateGetter;
+ private RouteAndActivityStateGetter stateGetter;
- public JobInsertionConsideringFixCostsCalculator(final JobInsertionCostsCalculator standardInsertionCalculator, StateGetter stateGetter) {
+ public JobInsertionConsideringFixCostsCalculator(final JobInsertionCostsCalculator standardInsertionCalculator, RouteAndActivityStateGetter stateGetter) {
super();
this.standardServiceInsertion = standardInsertionCalculator;
this.stateGetter = stateGetter;
diff --git a/jsprit-core/src/main/java/algorithms/JobInsertionCostsCalculator.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/JobInsertionCostsCalculator.java
similarity index 83%
rename from jsprit-core/src/main/java/algorithms/JobInsertionCostsCalculator.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/JobInsertionCostsCalculator.java
index 28f908dd..3d5599ac 100644
--- a/jsprit-core/src/main/java/algorithms/JobInsertionCostsCalculator.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/JobInsertionCostsCalculator.java
@@ -14,12 +14,12 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.recreate;
-import basics.Job;
-import basics.route.Driver;
-import basics.route.Vehicle;
-import basics.route.VehicleRoute;
+import jsprit.core.problem.driver.Driver;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.vehicle.Vehicle;
public interface JobInsertionCostsCalculator {
diff --git a/jsprit-core/src/main/java/algorithms/LocalActivityInsertionCostsCalculator.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/LocalActivityInsertionCostsCalculator.java
similarity index 89%
rename from jsprit-core/src/main/java/algorithms/LocalActivityInsertionCostsCalculator.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/LocalActivityInsertionCostsCalculator.java
index dd19a15c..92dacfb9 100644
--- a/jsprit-core/src/main/java/algorithms/LocalActivityInsertionCostsCalculator.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/LocalActivityInsertionCostsCalculator.java
@@ -18,11 +18,13 @@
* Contributors:
* Stefan Schroeder - initial API and implementation
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.recreate;
-import basics.costs.VehicleRoutingActivityCosts;
-import basics.costs.VehicleRoutingTransportCosts;
-import basics.route.TourActivity;
+import jsprit.core.problem.cost.VehicleRoutingActivityCosts;
+import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
+import jsprit.core.problem.misc.JobInsertionContext;
+import jsprit.core.problem.solution.route.activity.TourActivity;
+import jsprit.core.util.CalculationUtils;
/**
* Calculates activity insertion costs locally, i.e. by comparing the additional costs of insertion the new activity k between
@@ -34,7 +36,7 @@ import basics.route.TourActivity;
* @author stefan
*
*/
-public class LocalActivityInsertionCostsCalculator implements ActivityInsertionCostsCalculator{
+class LocalActivityInsertionCostsCalculator implements ActivityInsertionCostsCalculator{
private VehicleRoutingTransportCosts routingCosts;
@@ -48,7 +50,7 @@ public class LocalActivityInsertionCostsCalculator implements ActivityInsertionC
}
@Override
- public ActivityInsertionCosts getCosts(InsertionContext iFacts, TourActivity prevAct, TourActivity nextAct, TourActivity newAct, double depTimeAtPrevAct) {
+ public ActivityInsertionCosts getCosts(JobInsertionContext iFacts, TourActivity prevAct, TourActivity nextAct, TourActivity newAct, double depTimeAtPrevAct) {
double tp_costs_prevAct_newAct = routingCosts.getTransportCost(prevAct.getLocationId(), newAct.getLocationId(), depTimeAtPrevAct, iFacts.getNewDriver(), iFacts.getNewVehicle());
double tp_time_prevAct_newAct = routingCosts.getTransportTime(prevAct.getLocationId(), newAct.getLocationId(), depTimeAtPrevAct, iFacts.getNewDriver(), iFacts.getNewVehicle());
diff --git a/jsprit-core/src/main/java/algorithms/ParRegretInsertion.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/ParRegretInsertion.java
similarity index 99%
rename from jsprit-core/src/main/java/algorithms/ParRegretInsertion.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/ParRegretInsertion.java
index 2bcaf045..9d7fcafd 100644
--- a/jsprit-core/src/main/java/algorithms/ParRegretInsertion.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/ParRegretInsertion.java
@@ -1,3 +1,4 @@
+package jsprit.core.algorithm.recreate;
/*******************************************************************************
* Copyright (C) 2013 Stefan Schroeder
*
diff --git a/jsprit-core/src/main/java/algorithms/RegretInsertion.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/RegretInsertion.java
similarity index 99%
rename from jsprit-core/src/main/java/algorithms/RegretInsertion.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/RegretInsertion.java
index 300e6a6b..cbac3d07 100644
--- a/jsprit-core/src/main/java/algorithms/RegretInsertion.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/RegretInsertion.java
@@ -1,3 +1,4 @@
+package jsprit.core.algorithm.recreate;
/*******************************************************************************
* Copyright (C) 2013 Stefan Schroeder
*
diff --git a/jsprit-core/src/main/java/algorithms/RouteLevelActivityInsertionCostsEstimator.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/RouteLevelActivityInsertionCostsEstimator.java
similarity index 79%
rename from jsprit-core/src/main/java/algorithms/RouteLevelActivityInsertionCostsEstimator.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/RouteLevelActivityInsertionCostsEstimator.java
index adc9776f..b846979e 100644
--- a/jsprit-core/src/main/java/algorithms/RouteLevelActivityInsertionCostsEstimator.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/RouteLevelActivityInsertionCostsEstimator.java
@@ -18,17 +18,21 @@
* Contributors:
* Stefan Schroeder - initial API and implementation
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.recreate;
import java.util.ArrayList;
import java.util.List;
-import basics.costs.VehicleRoutingActivityCosts;
-import basics.costs.VehicleRoutingTransportCosts;
-import basics.route.End;
-import basics.route.Start;
-import basics.route.TourActivity;
-import basics.route.VehicleRoute;
+import jsprit.core.problem.cost.VehicleRoutingActivityCosts;
+import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
+import jsprit.core.problem.misc.JobInsertionContext;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.solution.route.activity.End;
+import jsprit.core.problem.solution.route.activity.Start;
+import jsprit.core.problem.solution.route.activity.TourActivity;
+import jsprit.core.problem.solution.route.state.RouteAndActivityStateGetter;
+import jsprit.core.problem.solution.route.state.StateFactory;
+
class RouteLevelActivityInsertionCostsEstimator implements ActivityInsertionCostsCalculator{
@@ -36,11 +40,11 @@ class RouteLevelActivityInsertionCostsEstimator implements ActivityInsertionCost
private AuxilliaryCostCalculator auxilliaryPathCostCalculator;
- private StateGetter stateManager;
+ private RouteAndActivityStateGetter stateManager;
private int nuOfActivities2LookForward = 0;
- public RouteLevelActivityInsertionCostsEstimator(VehicleRoutingTransportCosts routingCosts, VehicleRoutingActivityCosts actCosts, StateGetter stateManager) {
+ public RouteLevelActivityInsertionCostsEstimator(VehicleRoutingTransportCosts routingCosts, VehicleRoutingActivityCosts actCosts, RouteAndActivityStateGetter stateManager) {
super();
this.activityCosts = actCosts;
this.stateManager = stateManager;
@@ -48,7 +52,7 @@ class RouteLevelActivityInsertionCostsEstimator implements ActivityInsertionCost
}
@Override
- public ActivityInsertionCosts getCosts(InsertionContext iFacts, TourActivity prevAct, TourActivity nextAct, TourActivity newAct, double depTimeAtPrevAct) {
+ public ActivityInsertionCosts getCosts(JobInsertionContext iFacts, TourActivity prevAct, TourActivity nextAct, TourActivity newAct, double depTimeAtPrevAct) {
List path = new ArrayList();
path.add(prevAct); path.add(newAct); path.add(nextAct);
int actIndex;
diff --git a/jsprit-core/src/main/java/algorithms/ServiceInsertionCalculator.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/ServiceInsertionCalculator.java
similarity index 80%
rename from jsprit-core/src/main/java/algorithms/ServiceInsertionCalculator.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/ServiceInsertionCalculator.java
index d8ea37f3..1a1ead9c 100644
--- a/jsprit-core/src/main/java/algorithms/ServiceInsertionCalculator.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/ServiceInsertionCalculator.java
@@ -14,25 +14,30 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.recreate;
+
+import jsprit.core.algorithm.recreate.ActivityInsertionCostsCalculator.ActivityInsertionCosts;
+import jsprit.core.problem.constraint.HardActivityStateLevelConstraint;
+import jsprit.core.problem.constraint.HardActivityStateLevelConstraint.ConstraintsStatus;
+import jsprit.core.problem.constraint.HardRouteStateLevelConstraint;
+import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
+import jsprit.core.problem.driver.Driver;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.job.Service;
+import jsprit.core.problem.misc.JobInsertionContext;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.solution.route.activity.DefaultTourActivityFactory;
+import jsprit.core.problem.solution.route.activity.End;
+import jsprit.core.problem.solution.route.activity.Start;
+import jsprit.core.problem.solution.route.activity.TourActivity;
+import jsprit.core.problem.solution.route.activity.TourActivityFactory;
+import jsprit.core.problem.vehicle.Vehicle;
+import jsprit.core.problem.vehicle.VehicleImpl.NoVehicle;
+import jsprit.core.util.CalculationUtils;
+import jsprit.core.util.Neighborhood;
import org.apache.log4j.Logger;
-import util.Neighborhood;
-import algorithms.ActivityInsertionCostsCalculator.ActivityInsertionCosts;
-import algorithms.HardActivityStateLevelConstraint.ConstraintsStatus;
-import basics.Job;
-import basics.Service;
-import basics.costs.VehicleRoutingTransportCosts;
-import basics.route.DefaultTourActivityFactory;
-import basics.route.Driver;
-import basics.route.End;
-import basics.route.Start;
-import basics.route.TourActivity;
-import basics.route.TourActivityFactory;
-import basics.route.Vehicle;
-import basics.route.VehicleImpl.NoVehicle;
-import basics.route.VehicleRoute;
@@ -89,7 +94,7 @@ final class ServiceInsertionCalculator implements JobInsertionCostsCalculator{
if(jobToInsert == null) throw new IllegalStateException("jobToInsert is missing.");
if(newVehicle == null || newVehicle instanceof NoVehicle) throw new IllegalStateException("newVehicle is missing.");
- InsertionContext insertionContext = new InsertionContext(currentRoute, jobToInsert, newVehicle, newDriver, newVehicleDepartureTime);
+ JobInsertionContext insertionContext = new JobInsertionContext(currentRoute, jobToInsert, newVehicle, newDriver, newVehicleDepartureTime);
if(!hardRouteLevelConstraint.fulfilled(insertionContext)){
return InsertionData.createEmptyInsertionData();
}
@@ -155,7 +160,7 @@ final class ServiceInsertionCalculator implements JobInsertionCostsCalculator{
return insertionData;
}
- public ActivityInsertionCosts calculate(InsertionContext iFacts, TourActivity prevAct, TourActivity nextAct, TourActivity newAct, double departureTimeAtPrevAct) {
+ public ActivityInsertionCosts calculate(JobInsertionContext iFacts, TourActivity prevAct, TourActivity nextAct, TourActivity newAct, double departureTimeAtPrevAct) {
return activityInsertionCostsCalculator.getCosts(iFacts, prevAct, nextAct, newAct, departureTimeAtPrevAct);
}
}
diff --git a/jsprit-core/src/main/java/algorithms/ServiceInsertionOnRouteLevelCalculator.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/ServiceInsertionOnRouteLevelCalculator.java
similarity index 89%
rename from jsprit-core/src/main/java/algorithms/ServiceInsertionOnRouteLevelCalculator.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/ServiceInsertionOnRouteLevelCalculator.java
index 7b420ebd..f5dc6b79 100644
--- a/jsprit-core/src/main/java/algorithms/ServiceInsertionOnRouteLevelCalculator.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/ServiceInsertionOnRouteLevelCalculator.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.recreate;
import java.util.ArrayList;
import java.util.Comparator;
@@ -23,25 +23,31 @@ import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
+import jsprit.core.algorithm.recreate.ActivityInsertionCostsCalculator.ActivityInsertionCosts;
+import jsprit.core.problem.constraint.HardActivityStateLevelConstraint;
+import jsprit.core.problem.constraint.HardActivityStateLevelConstraint.ConstraintsStatus;
+import jsprit.core.problem.constraint.HardRouteStateLevelConstraint;
+import jsprit.core.problem.cost.VehicleRoutingActivityCosts;
+import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
+import jsprit.core.problem.driver.Driver;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.job.Service;
+import jsprit.core.problem.misc.JobInsertionContext;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.solution.route.activity.DefaultTourActivityFactory;
+import jsprit.core.problem.solution.route.activity.End;
+import jsprit.core.problem.solution.route.activity.Start;
+import jsprit.core.problem.solution.route.activity.TourActivities;
+import jsprit.core.problem.solution.route.activity.TourActivity;
+import jsprit.core.problem.solution.route.activity.TourActivityFactory;
+import jsprit.core.problem.solution.route.state.RouteAndActivityStateGetter;
+import jsprit.core.problem.solution.route.state.StateFactory;
+import jsprit.core.problem.vehicle.Vehicle;
+import jsprit.core.problem.vehicle.VehicleImpl.NoVehicle;
+import jsprit.core.util.Neighborhood;
+
import org.apache.log4j.Logger;
-import util.Neighborhood;
-import algorithms.ActivityInsertionCostsCalculator.ActivityInsertionCosts;
-import algorithms.HardActivityStateLevelConstraint.ConstraintsStatus;
-import basics.Job;
-import basics.Service;
-import basics.costs.VehicleRoutingActivityCosts;
-import basics.costs.VehicleRoutingTransportCosts;
-import basics.route.DefaultTourActivityFactory;
-import basics.route.Driver;
-import basics.route.End;
-import basics.route.Start;
-import basics.route.TourActivities;
-import basics.route.TourActivity;
-import basics.route.TourActivityFactory;
-import basics.route.Vehicle;
-import basics.route.VehicleImpl.NoVehicle;
-import basics.route.VehicleRoute;
@@ -57,7 +63,7 @@ final class ServiceInsertionOnRouteLevelCalculator implements JobInsertionCostsC
private TourActivityFactory tourActivityFactory = new DefaultTourActivityFactory();
- private StateGetter stateManager;
+ private RouteAndActivityStateGetter stateManager;
private HardRouteStateLevelConstraint hardRouteLevelConstraint;
@@ -108,7 +114,7 @@ final class ServiceInsertionOnRouteLevelCalculator implements JobInsertionCostsC
}
- public void setStates(StateGetter stateManager){
+ public void setStates(RouteAndActivityStateGetter stateManager){
this.stateManager = stateManager;
}
@@ -135,7 +141,7 @@ final class ServiceInsertionOnRouteLevelCalculator implements JobInsertionCostsC
if(jobToInsert == null) throw new IllegalStateException("job is null. cannot calculate the insertion of a null-job.");
if(newVehicle == null || newVehicle instanceof NoVehicle) throw new IllegalStateException("no vehicle given. set para vehicle!");
- InsertionContext insertionContext = new InsertionContext(currentRoute, jobToInsert, newVehicle, newDriver, newVehicleDepartureTime);
+ JobInsertionContext insertionContext = new JobInsertionContext(currentRoute, jobToInsert, newVehicle, newDriver, newVehicleDepartureTime);
if(!hardRouteLevelConstraint.fulfilled(insertionContext)){
return InsertionData.createEmptyInsertionData();
}
diff --git a/jsprit-core/src/main/java/algorithms/ShipmentInsertionCalculator.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/ShipmentInsertionCalculator.java
similarity index 87%
rename from jsprit-core/src/main/java/algorithms/ShipmentInsertionCalculator.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/ShipmentInsertionCalculator.java
index bd393852..67cba2ca 100644
--- a/jsprit-core/src/main/java/algorithms/ShipmentInsertionCalculator.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/ShipmentInsertionCalculator.java
@@ -14,27 +14,32 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.recreate;
import java.util.List;
+import jsprit.core.algorithm.recreate.ActivityInsertionCostsCalculator.ActivityInsertionCosts;
+import jsprit.core.problem.constraint.HardActivityStateLevelConstraint;
+import jsprit.core.problem.constraint.HardActivityStateLevelConstraint.ConstraintsStatus;
+import jsprit.core.problem.constraint.HardRouteStateLevelConstraint;
+import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
+import jsprit.core.problem.driver.Driver;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.job.Shipment;
+import jsprit.core.problem.misc.JobInsertionContext;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.solution.route.activity.DefaultShipmentActivityFactory;
+import jsprit.core.problem.solution.route.activity.End;
+import jsprit.core.problem.solution.route.activity.Start;
+import jsprit.core.problem.solution.route.activity.TourActivity;
+import jsprit.core.problem.solution.route.activity.TourShipmentActivityFactory;
+import jsprit.core.problem.vehicle.Vehicle;
+import jsprit.core.problem.vehicle.VehicleImpl.NoVehicle;
+import jsprit.core.util.CalculationUtils;
+import jsprit.core.util.Neighborhood;
+
import org.apache.log4j.Logger;
-import util.Neighborhood;
-import algorithms.ActivityInsertionCostsCalculator.ActivityInsertionCosts;
-import algorithms.HardActivityStateLevelConstraint.ConstraintsStatus;
-import basics.Job;
-import basics.Shipment;
-import basics.costs.VehicleRoutingTransportCosts;
-import basics.route.DefaultShipmentActivityFactory;
-import basics.route.Driver;
-import basics.route.End;
-import basics.route.Start;
-import basics.route.TourActivity;
-import basics.route.TourShipmentActivityFactory;
-import basics.route.Vehicle;
-import basics.route.VehicleImpl.NoVehicle;
-import basics.route.VehicleRoute;
@@ -91,7 +96,7 @@ final class ShipmentInsertionCalculator implements JobInsertionCostsCalculator{
if(newVehicle == null || newVehicle instanceof NoVehicle) throw new IllegalStateException("newVehicle is missing.");
if(!(jobToInsert instanceof Shipment)) throw new IllegalStateException("jobToInsert should be of type Shipment!");
- InsertionContext insertionContext = new InsertionContext(currentRoute, jobToInsert, newVehicle, newDriver, newVehicleDepartureTime);
+ JobInsertionContext insertionContext = new JobInsertionContext(currentRoute, jobToInsert, newVehicle, newDriver, newVehicleDepartureTime);
if(!hardRouteLevelConstraint.fulfilled(insertionContext)){
return InsertionData.createEmptyInsertionData();
}
@@ -201,7 +206,7 @@ final class ShipmentInsertionCalculator implements JobInsertionCostsCalculator{
return insertionData;
}
- private ActivityInsertionCosts calculate(InsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double departureTimeAtPrevAct) {
+ private ActivityInsertionCosts calculate(JobInsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double departureTimeAtPrevAct) {
return activityInsertionCostsCalculator.getCosts(iFacts, prevAct, nextAct, newAct, departureTimeAtPrevAct);
}
diff --git a/jsprit-core/src/main/java/algorithms/VehicleSwitched.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/VehicleSwitched.java
similarity index 74%
rename from jsprit-core/src/main/java/algorithms/VehicleSwitched.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/VehicleSwitched.java
index a9aa86bd..d368ce54 100644
--- a/jsprit-core/src/main/java/algorithms/VehicleSwitched.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/VehicleSwitched.java
@@ -14,18 +14,19 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.recreate;
-import basics.route.Vehicle;
-import basics.route.VehicleFleetManager;
-import basics.route.VehicleRoute;
+import jsprit.core.algorithm.recreate.listener.VehicleSwitchedListener;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.vehicle.Vehicle;
+import jsprit.core.problem.vehicle.VehicleFleetManager;
-class VehicleSwitched implements VehicleSwitchedListener{
+public class VehicleSwitched implements VehicleSwitchedListener{
private VehicleFleetManager fleetManager;
- VehicleSwitched(VehicleFleetManager fleetManager){
+ public VehicleSwitched(VehicleFleetManager fleetManager){
this.fleetManager = fleetManager;
}
diff --git a/jsprit-core/src/main/java/algorithms/VehicleTypeDependentJobInsertionCalculator.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/VehicleTypeDependentJobInsertionCalculator.java
similarity index 87%
rename from jsprit-core/src/main/java/algorithms/VehicleTypeDependentJobInsertionCalculator.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/VehicleTypeDependentJobInsertionCalculator.java
index b729b94a..8065ac43 100644
--- a/jsprit-core/src/main/java/algorithms/VehicleTypeDependentJobInsertionCalculator.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/VehicleTypeDependentJobInsertionCalculator.java
@@ -14,20 +14,21 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.recreate;
import java.util.ArrayList;
import java.util.Collection;
+import jsprit.core.algorithm.recreate.InsertionData.NoInsertionFound;
+import jsprit.core.problem.driver.Driver;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.vehicle.Vehicle;
+import jsprit.core.problem.vehicle.VehicleFleetManager;
+import jsprit.core.problem.vehicle.VehicleImpl.NoVehicle;
+
import org.apache.log4j.Logger;
-import algorithms.InsertionData.NoInsertionFound;
-import basics.Job;
-import basics.route.Driver;
-import basics.route.Vehicle;
-import basics.route.VehicleFleetManager;
-import basics.route.VehicleImpl.NoVehicle;
-import basics.route.VehicleRoute;
diff --git a/jsprit-core/src/main/java/algorithms/BeforeJobInsertionListener.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/listener/BeforeJobInsertionListener.java
similarity index 84%
rename from jsprit-core/src/main/java/algorithms/BeforeJobInsertionListener.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/listener/BeforeJobInsertionListener.java
index 0ff16539..befbc0cf 100644
--- a/jsprit-core/src/main/java/algorithms/BeforeJobInsertionListener.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/listener/BeforeJobInsertionListener.java
@@ -14,11 +14,11 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.recreate.listener;
-import basics.Job;
-import basics.algo.InsertionListener;
-import basics.route.VehicleRoute;
+import jsprit.core.algorithm.recreate.InsertionData;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.solution.route.VehicleRoute;
interface BeforeJobInsertionListener extends InsertionListener{
diff --git a/jsprit-core/src/main/java/basics/algo/InsertionEndsListener.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/listener/InsertionEndsListener.java
similarity index 90%
rename from jsprit-core/src/main/java/basics/algo/InsertionEndsListener.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/listener/InsertionEndsListener.java
index 58f64bc2..7420f1b2 100644
--- a/jsprit-core/src/main/java/basics/algo/InsertionEndsListener.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/listener/InsertionEndsListener.java
@@ -14,11 +14,12 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics.algo;
+package jsprit.core.algorithm.recreate.listener;
import java.util.Collection;
-import basics.route.VehicleRoute;
+import jsprit.core.problem.solution.route.VehicleRoute;
+
public interface InsertionEndsListener extends InsertionListener {
diff --git a/jsprit-core/src/main/java/basics/algo/InsertionListener.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/listener/InsertionListener.java
similarity index 89%
rename from jsprit-core/src/main/java/basics/algo/InsertionListener.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/listener/InsertionListener.java
index 6c75a5e7..eb32b31c 100644
--- a/jsprit-core/src/main/java/basics/algo/InsertionListener.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/listener/InsertionListener.java
@@ -14,7 +14,9 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics.algo;
+package jsprit.core.algorithm.recreate.listener;
+
+import jsprit.core.algorithm.listener.SearchStrategyModuleListener;
diff --git a/jsprit-core/src/main/java/algorithms/InsertionListeners.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/listener/InsertionListeners.java
similarity index 90%
rename from jsprit-core/src/main/java/algorithms/InsertionListeners.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/listener/InsertionListeners.java
index 6997fccb..67443c46 100644
--- a/jsprit-core/src/main/java/algorithms/InsertionListeners.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/listener/InsertionListeners.java
@@ -14,20 +14,18 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.recreate.listener;
import java.util.ArrayList;
import java.util.Collection;
-import basics.Job;
-import basics.algo.InsertionEndsListener;
-import basics.algo.InsertionListener;
-import basics.algo.InsertionStartsListener;
-import basics.algo.JobInsertedListener;
-import basics.route.Vehicle;
-import basics.route.VehicleRoute;
+import jsprit.core.algorithm.recreate.InsertionData;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.vehicle.Vehicle;
-class InsertionListeners {
+
+public class InsertionListeners {
private Collection listeners = new ArrayList();
diff --git a/jsprit-core/src/main/java/basics/algo/InsertionStartsListener.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/listener/InsertionStartsListener.java
similarity index 88%
rename from jsprit-core/src/main/java/basics/algo/InsertionStartsListener.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/listener/InsertionStartsListener.java
index 0923a02f..6751c422 100644
--- a/jsprit-core/src/main/java/basics/algo/InsertionStartsListener.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/listener/InsertionStartsListener.java
@@ -14,12 +14,13 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics.algo;
+package jsprit.core.algorithm.recreate.listener;
import java.util.Collection;
-import basics.Job;
-import basics.route.VehicleRoute;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.solution.route.VehicleRoute;
+
public interface InsertionStartsListener extends InsertionListener {
diff --git a/jsprit-core/src/main/java/basics/algo/JobInsertedListener.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/listener/JobInsertedListener.java
similarity index 88%
rename from jsprit-core/src/main/java/basics/algo/JobInsertedListener.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/listener/JobInsertedListener.java
index c6c86924..dd2663d9 100644
--- a/jsprit-core/src/main/java/basics/algo/JobInsertedListener.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/listener/JobInsertedListener.java
@@ -14,10 +14,10 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics.algo;
+package jsprit.core.algorithm.recreate.listener;
-import basics.Job;
-import basics.route.VehicleRoute;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.solution.route.VehicleRoute;
diff --git a/jsprit-core/src/main/java/algorithms/VehicleSwitchedListener.java b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/listener/VehicleSwitchedListener.java
similarity index 81%
rename from jsprit-core/src/main/java/algorithms/VehicleSwitchedListener.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/recreate/listener/VehicleSwitchedListener.java
index edbd32ac..d57fa11e 100644
--- a/jsprit-core/src/main/java/algorithms/VehicleSwitchedListener.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/recreate/listener/VehicleSwitchedListener.java
@@ -14,13 +14,12 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.recreate.listener;
-import basics.algo.InsertionListener;
-import basics.route.Vehicle;
-import basics.route.VehicleRoute;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.vehicle.Vehicle;
-interface VehicleSwitchedListener extends InsertionListener{
+public interface VehicleSwitchedListener extends InsertionListener{
public void vehicleSwitched(VehicleRoute vehicleRoute, Vehicle oldVehicle, Vehicle newVehicle);
diff --git a/jsprit-core/src/main/java/algorithms/RadialRuinStrategyFactory.java b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RadialRuinStrategyFactory.java
similarity index 75%
rename from jsprit-core/src/main/java/algorithms/RadialRuinStrategyFactory.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RadialRuinStrategyFactory.java
index c541c4c9..418fc956 100644
--- a/jsprit-core/src/main/java/algorithms/RadialRuinStrategyFactory.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RadialRuinStrategyFactory.java
@@ -1,6 +1,7 @@
-package algorithms;
+package jsprit.core.algorithm.ruin;
-import basics.VehicleRoutingProblem;
+import jsprit.core.algorithm.ruin.distance.JobDistance;
+import jsprit.core.problem.VehicleRoutingProblem;
public class RadialRuinStrategyFactory implements RuinStrategyFactory{
diff --git a/jsprit-core/src/main/java/algorithms/RandomRuinStrategyFactory.java b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RandomRuinStrategyFactory.java
similarity index 78%
rename from jsprit-core/src/main/java/algorithms/RandomRuinStrategyFactory.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RandomRuinStrategyFactory.java
index 5a32c9f2..b475cc03 100644
--- a/jsprit-core/src/main/java/algorithms/RandomRuinStrategyFactory.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RandomRuinStrategyFactory.java
@@ -1,6 +1,6 @@
-package algorithms;
+package jsprit.core.algorithm.ruin;
-import basics.VehicleRoutingProblem;
+import jsprit.core.problem.VehicleRoutingProblem;
public class RandomRuinStrategyFactory implements RuinStrategyFactory{
diff --git a/jsprit-core/src/main/java/algorithms/RuinRadial.java b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinRadial.java
similarity index 96%
rename from jsprit-core/src/main/java/algorithms/RuinRadial.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinRadial.java
index b7a9f8b0..601a4b40 100644
--- a/jsprit-core/src/main/java/algorithms/RuinRadial.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinRadial.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.ruin;
import java.util.ArrayList;
import java.util.Collection;
@@ -27,15 +27,17 @@ import java.util.Map;
import java.util.Random;
import java.util.TreeSet;
+import jsprit.core.algorithm.ruin.distance.JobDistance;
+import jsprit.core.algorithm.ruin.listener.RuinListener;
+import jsprit.core.algorithm.ruin.listener.RuinListeners;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.util.RandomNumberGeneration;
+import jsprit.core.util.StopWatch;
+
import org.apache.log4j.Logger;
-import util.RandomNumberGeneration;
-import util.StopWatch;
-import basics.Job;
-import basics.VehicleRoutingProblem;
-import basics.algo.RuinListener;
-import basics.algo.RuinListeners;
-import basics.route.VehicleRoute;
/**
diff --git a/jsprit-core/src/main/java/algorithms/RuinRandom.java b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinRandom.java
similarity index 93%
rename from jsprit-core/src/main/java/algorithms/RuinRandom.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinRandom.java
index bbe1b2c6..f4762dee 100644
--- a/jsprit-core/src/main/java/algorithms/RuinRandom.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinRandom.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.ruin;
import java.util.ArrayList;
import java.util.Collection;
@@ -22,14 +22,15 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Random;
+import jsprit.core.algorithm.ruin.listener.RuinListener;
+import jsprit.core.algorithm.ruin.listener.RuinListeners;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.util.RandomNumberGeneration;
+
import org.apache.log4j.Logger;
-import util.RandomNumberGeneration;
-import basics.Job;
-import basics.VehicleRoutingProblem;
-import basics.algo.RuinListener;
-import basics.algo.RuinListeners;
-import basics.route.VehicleRoute;
/**
diff --git a/jsprit-core/src/main/java/algorithms/RuinStrategy.java b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinStrategy.java
similarity index 90%
rename from jsprit-core/src/main/java/algorithms/RuinStrategy.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinStrategy.java
index 3f03b5dc..2e485268 100644
--- a/jsprit-core/src/main/java/algorithms/RuinStrategy.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinStrategy.java
@@ -14,13 +14,14 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.ruin;
import java.util.Collection;
-import basics.Job;
-import basics.algo.RuinListener;
-import basics.route.VehicleRoute;
+import jsprit.core.algorithm.ruin.listener.RuinListener;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.solution.route.VehicleRoute;
+
diff --git a/jsprit-core/src/main/java/algorithms/RuinStrategyFactory.java b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinStrategyFactory.java
similarity index 92%
rename from jsprit-core/src/main/java/algorithms/RuinStrategyFactory.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinStrategyFactory.java
index 26cf1212..21c1f1cf 100644
--- a/jsprit-core/src/main/java/algorithms/RuinStrategyFactory.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/RuinStrategyFactory.java
@@ -14,9 +14,9 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.ruin;
-import basics.VehicleRoutingProblem;
+import jsprit.core.problem.VehicleRoutingProblem;
public interface RuinStrategyFactory {
diff --git a/jsprit-core/src/main/java/algorithms/AvgJobDistance.java b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/distance/AvgServiceAndShipmentDistance.java
similarity index 86%
rename from jsprit-core/src/main/java/algorithms/AvgJobDistance.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/ruin/distance/AvgServiceAndShipmentDistance.java
index da4d68c0..bb380d7a 100644
--- a/jsprit-core/src/main/java/algorithms/AvgJobDistance.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/distance/AvgServiceAndShipmentDistance.java
@@ -14,16 +14,17 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.ruin.distance;
+
+import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.job.Service;
+import jsprit.core.problem.job.Shipment;
+import jsprit.core.util.Coordinate;
+import jsprit.core.util.EuclideanDistanceCalculator;
import org.apache.log4j.Logger;
-import util.Coordinate;
-import util.EuclideanDistanceCalculator;
-import basics.Job;
-import basics.Service;
-import basics.Shipment;
-import basics.costs.VehicleRoutingTransportCosts;
/**
@@ -34,13 +35,13 @@ import basics.costs.VehicleRoutingTransportCosts;
* @author stefan schroeder
*
*/
-public class AvgJobDistance implements JobDistance {
+public class AvgServiceAndShipmentDistance implements JobDistance {
- private static Logger log = Logger.getLogger(AvgJobDistance.class);
+ private static Logger log = Logger.getLogger(AvgServiceAndShipmentDistance.class);
private VehicleRoutingTransportCosts costs;
- public AvgJobDistance(VehicleRoutingTransportCosts costs) {
+ public AvgServiceAndShipmentDistance(VehicleRoutingTransportCosts costs) {
super();
this.costs = costs;
diff --git a/jsprit-core/src/main/java/algorithms/JobDistanceAvgCosts.java b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/distance/AvgServiceDistance.java
similarity index 84%
rename from jsprit-core/src/main/java/algorithms/JobDistanceAvgCosts.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/ruin/distance/AvgServiceDistance.java
index 38dcee47..4c41f656 100644
--- a/jsprit-core/src/main/java/algorithms/JobDistanceAvgCosts.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/distance/AvgServiceDistance.java
@@ -14,13 +14,14 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.ruin.distance;
+
+import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.job.Service;
import org.apache.log4j.Logger;
-import basics.Job;
-import basics.Service;
-import basics.costs.VehicleRoutingTransportCosts;
/**
@@ -31,13 +32,13 @@ import basics.costs.VehicleRoutingTransportCosts;
* @author stefan schroeder
*
*/
-public class JobDistanceAvgCosts implements JobDistance {
+public class AvgServiceDistance implements JobDistance {
- private static Logger log = Logger.getLogger(JobDistanceAvgCosts.class);
+ private static Logger log = Logger.getLogger(AvgServiceDistance.class);
private VehicleRoutingTransportCosts costs;
- public JobDistanceAvgCosts(VehicleRoutingTransportCosts costs) {
+ public AvgServiceDistance(VehicleRoutingTransportCosts costs) {
super();
this.costs = costs;
@@ -61,7 +62,7 @@ public class JobDistanceAvgCosts implements JobDistance {
}
} else {
throw new UnsupportedOperationException(
- "currently, this class just works with shipments and services.");
+ "currently, this class just works services.");
}
return avgCost;
}
diff --git a/jsprit-core/src/main/java/algorithms/EuclideanServiceDistance.java b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/distance/EuclideanServiceDistance.java
similarity index 87%
rename from jsprit-core/src/main/java/algorithms/EuclideanServiceDistance.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/ruin/distance/EuclideanServiceDistance.java
index 0f4641b3..2369e8d6 100644
--- a/jsprit-core/src/main/java/algorithms/EuclideanServiceDistance.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/distance/EuclideanServiceDistance.java
@@ -14,13 +14,13 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.ruin.distance;
-import util.EuclideanDistanceCalculator;
-import basics.Job;
-import basics.Service;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.job.Service;
+import jsprit.core.util.EuclideanDistanceCalculator;
-class EuclideanServiceDistance implements JobDistance {
+public class EuclideanServiceDistance implements JobDistance {
public EuclideanServiceDistance() {
super();
diff --git a/jsprit-core/src/main/java/algorithms/JobDistance.java b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/distance/JobDistance.java
similarity index 92%
rename from jsprit-core/src/main/java/algorithms/JobDistance.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/ruin/distance/JobDistance.java
index 3ac28dbe..45b4428b 100644
--- a/jsprit-core/src/main/java/algorithms/JobDistance.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/distance/JobDistance.java
@@ -14,9 +14,9 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.ruin.distance;
-import basics.Job;
+import jsprit.core.problem.job.Job;
diff --git a/jsprit-core/src/main/java/basics/algo/RuinListener.java b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/listener/RuinListener.java
similarity index 78%
rename from jsprit-core/src/main/java/basics/algo/RuinListener.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/ruin/listener/RuinListener.java
index bb75ca78..7fb0779e 100644
--- a/jsprit-core/src/main/java/basics/algo/RuinListener.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/listener/RuinListener.java
@@ -1,9 +1,11 @@
-package basics.algo;
+package jsprit.core.algorithm.ruin.listener;
import java.util.Collection;
-import basics.Job;
-import basics.route.VehicleRoute;
+import jsprit.core.algorithm.listener.SearchStrategyModuleListener;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.solution.route.VehicleRoute;
+
/**
* Listener that listens to the ruin-process. It informs whoever is interested about start, end and about a removal of a job.
diff --git a/jsprit-core/src/main/java/basics/algo/RuinListeners.java b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/listener/RuinListeners.java
similarity index 93%
rename from jsprit-core/src/main/java/basics/algo/RuinListeners.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/ruin/listener/RuinListeners.java
index fc442cc9..b5b49392 100644
--- a/jsprit-core/src/main/java/basics/algo/RuinListeners.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/ruin/listener/RuinListeners.java
@@ -18,14 +18,15 @@
* Contributors:
* Stefan Schroeder - initial API and implementation
******************************************************************************/
-package basics.algo;
+package jsprit.core.algorithm.ruin.listener;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import basics.Job;
-import basics.route.VehicleRoute;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.solution.route.VehicleRoute;
+
public class RuinListeners {
diff --git a/jsprit-core/src/main/java/algorithms/selectors/SelectBest.java b/jsprit-core/src/main/java/jsprit/core/algorithm/selector/SelectBest.java
similarity index 94%
rename from jsprit-core/src/main/java/algorithms/selectors/SelectBest.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/selector/SelectBest.java
index 93fc29aa..e2db896e 100644
--- a/jsprit-core/src/main/java/algorithms/selectors/SelectBest.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/selector/SelectBest.java
@@ -14,11 +14,12 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms.selectors;
+package jsprit.core.algorithm.selector;
import java.util.Collection;
-import basics.VehicleRoutingProblemSolution;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+
diff --git a/jsprit-core/src/main/java/algorithms/selectors/SelectRandomly.java b/jsprit-core/src/main/java/jsprit/core/algorithm/selector/SelectRandomly.java
similarity index 91%
rename from jsprit-core/src/main/java/algorithms/selectors/SelectRandomly.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/selector/SelectRandomly.java
index 97676297..09731749 100644
--- a/jsprit-core/src/main/java/algorithms/selectors/SelectRandomly.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/selector/SelectRandomly.java
@@ -14,15 +14,16 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms.selectors;
+package jsprit.core.algorithm.selector;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Random;
-import util.RandomNumberGeneration;
-import basics.VehicleRoutingProblemSolution;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+import jsprit.core.util.RandomNumberGeneration;
+
diff --git a/jsprit-core/src/main/java/algorithms/selectors/SolutionSelector.java b/jsprit-core/src/main/java/jsprit/core/algorithm/selector/SolutionSelector.java
similarity index 90%
rename from jsprit-core/src/main/java/algorithms/selectors/SolutionSelector.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/selector/SolutionSelector.java
index 48d26709..410a7a7a 100644
--- a/jsprit-core/src/main/java/algorithms/selectors/SolutionSelector.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/selector/SolutionSelector.java
@@ -14,11 +14,12 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms.selectors;
+package jsprit.core.algorithm.selector;
import java.util.Collection;
-import basics.VehicleRoutingProblemSolution;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+
public interface SolutionSelector {
diff --git a/jsprit-core/src/main/java/algorithms/StateManager.java b/jsprit-core/src/main/java/jsprit/core/algorithm/state/StateManager.java
similarity index 62%
rename from jsprit-core/src/main/java/algorithms/StateManager.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/state/StateManager.java
index 8f259060..16ebe471 100644
--- a/jsprit-core/src/main/java/algorithms/StateManager.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/state/StateManager.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package algorithms;
+package jsprit.core.algorithm.state;
import java.util.ArrayList;
import java.util.Collection;
@@ -22,64 +22,32 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import basics.Job;
-import basics.VehicleRoutingProblem;
-import basics.VehicleRoutingProblemSolution;
-import basics.algo.InsertionEndsListener;
-import basics.algo.InsertionListener;
-import basics.algo.InsertionListeners;
-import basics.algo.InsertionStartsListener;
-import basics.algo.IterationStartsListener;
-import basics.algo.JobInsertedListener;
-import basics.algo.RuinListener;
-import basics.algo.RuinListeners;
-import basics.route.ActivityVisitor;
-import basics.route.ReverseActivityVisitor;
-import basics.route.ReverseRouteActivityVisitor;
-import basics.route.RouteActivityVisitor;
-import basics.route.RouteVisitor;
-import basics.route.TourActivity;
-import basics.route.VehicleRoute;
+import jsprit.core.algorithm.listener.IterationStartsListener;
+import jsprit.core.algorithm.recreate.listener.InsertionEndsListener;
+import jsprit.core.algorithm.recreate.listener.InsertionListener;
+import jsprit.core.algorithm.recreate.listener.InsertionListeners;
+import jsprit.core.algorithm.recreate.listener.InsertionStartsListener;
+import jsprit.core.algorithm.recreate.listener.JobInsertedListener;
+import jsprit.core.algorithm.ruin.listener.RuinListener;
+import jsprit.core.algorithm.ruin.listener.RuinListeners;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+import jsprit.core.problem.solution.route.ReverseRouteActivityVisitor;
+import jsprit.core.problem.solution.route.RouteActivityVisitor;
+import jsprit.core.problem.solution.route.RouteVisitor;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.solution.route.activity.ActivityVisitor;
+import jsprit.core.problem.solution.route.activity.ReverseActivityVisitor;
+import jsprit.core.problem.solution.route.activity.TourActivity;
+import jsprit.core.problem.solution.route.state.RouteAndActivityStateGetter;
+import jsprit.core.problem.solution.route.state.StateFactory;
+import jsprit.core.problem.solution.route.state.StateFactory.State;
+import jsprit.core.problem.solution.route.state.StateFactory.StateId;
+import jsprit.core.problem.solution.route.state.StateFactory.States;
-public class StateManager implements StateGetter, IterationStartsListener, RuinListener, InsertionStartsListener, JobInsertedListener, InsertionEndsListener {
-
-
- private interface States {
-
- State getState(StateId key);
-
- }
-
- static class StateImpl implements State{
- double state;
-
- public StateImpl(double state) {
- super();
- this.state = state;
- }
-
- @Override
- public double toDouble() {
- return state;
- }
-
- }
-
- private static class StatesImpl implements States{
-
- private Map states = new HashMap();
-
- public void putState(StateId key, State state) {
- states.put(key, state);
- }
-
- @Override
- public State getState(StateId key) {
- return states.get(key);
- }
-
- }
+public class StateManager implements RouteAndActivityStateGetter, IterationStartsListener, RuinListener, InsertionStartsListener, JobInsertedListener, InsertionEndsListener {
private Map vehicleRouteStates = new HashMap();
@@ -97,15 +65,24 @@ public class StateManager implements StateGetter, IterationStartsListener, RuinL
private Collection updaters = new ArrayList();
- private Map defaultRouteStates = new HashMap();
+ private Map defaultRouteStates = new HashMap();
private Map defaultActivityStates = new HashMap();
+ private VehicleRoutingProblem vrp;
+
+ public StateManager(VehicleRoutingProblem vrp) {
+ super();
+ this.vrp = vrp;
+ }
+
public void addDefaultRouteState(StateId stateId, State defaultState){
+ if(StateFactory.isReservedId(stateId)) StateFactory.throwReservedIdException(stateId.toString());
defaultRouteStates.put(stateId, defaultState);
}
public void addDefaultActivityState(StateId stateId, State defaultState){
+ if(StateFactory.isReservedId(stateId)) StateFactory.throwReservedIdException(stateId.toString());
defaultActivityStates.put(stateId, defaultState);
}
@@ -119,7 +96,7 @@ public class StateManager implements StateGetter, IterationStartsListener, RuinL
if(!activityStates.containsKey(act)){
return getDefaultActState(stateId,act);
}
- StatesImpl actStates = (StatesImpl) activityStates.get(act);
+ States actStates = activityStates.get(act);
State state = actStates.getState(stateId);
if(state == null){
return getDefaultActState(stateId,act);
@@ -127,29 +104,38 @@ public class StateManager implements StateGetter, IterationStartsListener, RuinL
return state;
}
- public void putActivityState(TourActivity act, StateId stateId, State state){
+ void putInternalActivityState(TourActivity act, StateId stateId, State state){
if(!activityStates.containsKey(act)){
- activityStates.put(act, new StatesImpl());
+ activityStates.put(act, StateFactory.createStates());
}
- StatesImpl actStates = (StatesImpl) activityStates.get(act);
+ States actStates = activityStates.get(act);
actStates.putState(stateId, state);
}
-
-
- public void putRouteState(VehicleRoute route, StateId stateId, State state){
+
+ public void putActivityState(TourActivity act, StateId stateId, State state){
+ if(StateFactory.isReservedId(stateId)) StateFactory.throwReservedIdException(stateId.toString());
+ putInternalActivityState(act, stateId, state);
+ }
+
+ void putInternalRouteState(VehicleRoute route, StateId stateId, State state){
if(!vehicleRouteStates.containsKey(route)){
- vehicleRouteStates.put(route, new StatesImpl());
+ vehicleRouteStates.put(route, StateFactory.createStates());
}
- StatesImpl routeStates = (StatesImpl) vehicleRouteStates.get(route);
+ States routeStates = (States) vehicleRouteStates.get(route);
routeStates.putState(stateId, state);
}
+ public void putRouteState(VehicleRoute route, StateId stateId, State state){
+ if(StateFactory.isReservedId(stateId)) StateFactory.throwReservedIdException(stateId.toString());
+ putInternalRouteState(route, stateId, state);
+ }
+
@Override
public State getRouteState(VehicleRoute route, StateId stateId) {
if(!vehicleRouteStates.containsKey(route)){
return getDefaultRouteState(stateId,route);
}
- StatesImpl routeStates = (StatesImpl) vehicleRouteStates.get(route);
+ States routeStates = vehicleRouteStates.get(route);
State state = routeStates.getState(stateId);
if(state == null){
return getDefaultRouteState(stateId, route);
@@ -225,31 +211,31 @@ public class StateManager implements StateGetter, IterationStartsListener, RuinL
}
private State getDefaultActState(StateId stateId, TourActivity act){
- if(stateId.equals(StateFactory.LOAD)) return new StateImpl(0);
- if(stateId.equals(StateFactory.COSTS)) return new StateImpl(0);
- if(stateId.equals(StateFactory.DURATION)) return new StateImpl(0);
- if(stateId.equals(StateFactory.EARLIEST_OPERATION_START_TIME)) return new StateImpl(act.getTheoreticalEarliestOperationStartTime());
- if(stateId.equals(StateFactory.LATEST_OPERATION_START_TIME)) return new StateImpl(act.getTheoreticalLatestOperationStartTime());
- if(stateId.equals(StateFactory.FUTURE_PICKS)) return new StateImpl(0);
- if(stateId.equals(StateFactory.PAST_DELIVERIES)) return new StateImpl(0);
+ if(stateId.equals(StateFactory.LOAD)) return StateFactory.createState(0);
+ if(stateId.equals(StateFactory.COSTS)) return StateFactory.createState(0);
+ if(stateId.equals(StateFactory.DURATION)) return StateFactory.createState(0);
+ if(stateId.equals(StateFactory.EARLIEST_OPERATION_START_TIME)) return StateFactory.createState(act.getTheoreticalEarliestOperationStartTime());
+ if(stateId.equals(StateFactory.LATEST_OPERATION_START_TIME)) return StateFactory.createState(act.getTheoreticalLatestOperationStartTime());
+ if(stateId.equals(StateFactory.FUTURE_MAXLOAD)) return StateFactory.createState(0);
+ if(stateId.equals(StateFactory.PAST_MAXLOAD)) return StateFactory.createState(0);
if(defaultActivityStates.containsKey(stateId)) return defaultActivityStates.get(stateId);
return null;
}
private State getDefaultRouteState(StateId stateId, VehicleRoute route){
- if(stateId.equals(StateFactory.MAXLOAD)) return new StateImpl(0);
- if(stateId.equals(StateFactory.LOAD)) return new StateImpl(0);
- if(stateId.equals(StateFactory.LOAD_AT_END)) return new StateImpl(0);
- if(stateId.equals(StateFactory.LOAD_AT_BEGINNING)) return new StateImpl(0);
- if(stateId.equals(StateFactory.COSTS)) return new StateImpl(0);
- if(stateId.equals(StateFactory.DURATION)) return new StateImpl(0);
+ if(stateId.equals(StateFactory.MAXLOAD)) return StateFactory.createState(0);
+ if(stateId.equals(StateFactory.LOAD)) return StateFactory.createState(0);
+ if(stateId.equals(StateFactory.LOAD_AT_END)) return StateFactory.createState(0);
+ if(stateId.equals(StateFactory.LOAD_AT_BEGINNING)) return StateFactory.createState(0);
+ if(stateId.equals(StateFactory.COSTS)) return StateFactory.createState(0);
+ if(stateId.equals(StateFactory.DURATION)) return StateFactory.createState(0);
if(defaultRouteStates.containsKey(stateId)) return defaultRouteStates.get(stateId);
return null;
}
@Override
public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) {
- insertionListeners.jobInserted(job2insert, inRoute, additionalCosts, additionalTime);
+ insertionListeners.informJobInserted(job2insert, inRoute, additionalCosts, additionalTime);
for(RouteVisitor v : routeVisitors){ v.visit(inRoute); }
routeActivityVisitor.visit(inRoute);
revRouteActivityVisitor.visit(inRoute);
@@ -257,7 +243,7 @@ public class StateManager implements StateGetter, IterationStartsListener, RuinL
@Override
public void informInsertionStarts(Collection vehicleRoutes,Collection unassignedJobs) {
- insertionListeners.insertionStarts(vehicleRoutes, unassignedJobs);
+ insertionListeners.informInsertionStarts(vehicleRoutes, unassignedJobs);
for(VehicleRoute route : vehicleRoutes){
for(RouteVisitor v : routeVisitors){ v.visit(route); }
routeActivityVisitor.visit(route);
@@ -287,6 +273,19 @@ public class StateManager implements StateGetter, IterationStartsListener, RuinL
@Override
public void informInsertionEnds(Collection vehicleRoutes) {
- insertionListeners.insertionEnds(vehicleRoutes);
+ insertionListeners.informInsertionEndsListeners(vehicleRoutes);
}
+
+ public void updateLoadStates() {
+ UpdateLoads updateLoads = new UpdateLoads(this);
+ addActivityVisitor(updateLoads);
+ addListener(updateLoads);
+ addActivityVisitor(new UpdatePrevMaxLoad(this));
+ addActivityVisitor(new UpdateMaxLoad(this));
+ addActivityVisitor(new UpdateMaxLoad_(this));
+ }
+
+ public void updateTimeWindowStates() {
+ addActivityVisitor(new UpdateTimeWindow(this, vrp.getTransportCosts()));
+ }
}
diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/state/StateUpdater.java b/jsprit-core/src/main/java/jsprit/core/algorithm/state/StateUpdater.java
new file mode 100644
index 00000000..3d170794
--- /dev/null
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/state/StateUpdater.java
@@ -0,0 +1,5 @@
+package jsprit.core.algorithm.state;
+
+public interface StateUpdater {
+
+}
diff --git a/jsprit-core/src/main/java/algorithms/UpdateActivityTimes.java b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateActivityTimes.java
similarity index 74%
rename from jsprit-core/src/main/java/algorithms/UpdateActivityTimes.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateActivityTimes.java
index 8d18d0c9..2698cc4a 100644
--- a/jsprit-core/src/main/java/algorithms/UpdateActivityTimes.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateActivityTimes.java
@@ -1,12 +1,11 @@
-package algorithms;
+package jsprit.core.algorithm.state;
-import org.apache.log4j.Logger;
+import jsprit.core.problem.cost.ForwardTransportTime;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.solution.route.activity.ActivityVisitor;
+import jsprit.core.problem.solution.route.activity.TourActivity;
+import jsprit.core.util.ActivityTimeTracker;
-import util.ActivityTimeTracker;
-import basics.costs.ForwardTransportTime;
-import basics.route.ActivityVisitor;
-import basics.route.TourActivity;
-import basics.route.VehicleRoute;
/**
* Updates arrival and end times of activities.
@@ -16,10 +15,8 @@ import basics.route.VehicleRoute;
* @author stefan
*
*/
-class UpdateActivityTimes implements ActivityVisitor, StateUpdater{
+public class UpdateActivityTimes implements ActivityVisitor, StateUpdater{
- private Logger log = Logger.getLogger(UpdateActivityTimes.class);
-
private ActivityTimeTracker timeTracker;
private VehicleRoute route;
diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateEarliestStartTime.java b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateEarliestStartTime.java
new file mode 100644
index 00000000..a62281d1
--- /dev/null
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateEarliestStartTime.java
@@ -0,0 +1,37 @@
+package jsprit.core.algorithm.state;
+
+import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.solution.route.activity.ActivityVisitor;
+import jsprit.core.problem.solution.route.activity.TourActivity;
+import jsprit.core.problem.solution.route.state.StateFactory;
+import jsprit.core.util.ActivityTimeTracker;
+
+class UpdateEarliestStartTime implements ActivityVisitor,StateUpdater{
+
+ private StateManager states;
+
+ private ActivityTimeTracker timeTracker;
+
+ public UpdateEarliestStartTime(StateManager states, VehicleRoutingTransportCosts transportCosts) {
+ super();
+ this.states = states;
+ timeTracker = new ActivityTimeTracker(transportCosts);
+ }
+
+ @Override
+ public void begin(VehicleRoute route) {
+ timeTracker.begin(route);
+ }
+
+ @Override
+ public void visit(TourActivity activity) {
+ timeTracker.visit(activity);
+ states.putInternalActivityState(activity, StateFactory.EARLIEST_OPERATION_START_TIME, StateFactory.createState(Math.max(timeTracker.getActArrTime(), activity.getTheoreticalEarliestOperationStartTime())));
+
+ }
+
+ @Override
+ public void finish() {}
+
+}
\ No newline at end of file
diff --git a/jsprit-core/src/main/java/algorithms/UpdateLoads.java b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateLoads.java
similarity index 70%
rename from jsprit-core/src/main/java/algorithms/UpdateLoads.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateLoads.java
index ebd6076d..6e9a6df5 100644
--- a/jsprit-core/src/main/java/algorithms/UpdateLoads.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateLoads.java
@@ -1,18 +1,18 @@
-package algorithms;
+package jsprit.core.algorithm.state;
import java.util.Collection;
-import org.apache.log4j.Logger;
+import jsprit.core.algorithm.recreate.listener.InsertionStartsListener;
+import jsprit.core.algorithm.recreate.listener.JobInsertedListener;
+import jsprit.core.problem.job.Delivery;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.job.Pickup;
+import jsprit.core.problem.job.Service;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.solution.route.activity.ActivityVisitor;
+import jsprit.core.problem.solution.route.activity.TourActivity;
+import jsprit.core.problem.solution.route.state.StateFactory;
-import basics.Delivery;
-import basics.Job;
-import basics.Pickup;
-import basics.Service;
-import basics.algo.InsertionStartsListener;
-import basics.algo.JobInsertedListener;
-import basics.route.ActivityVisitor;
-import basics.route.TourActivity;
-import basics.route.VehicleRoute;
/**
* Updates load at activity level.
@@ -29,8 +29,6 @@ class UpdateLoads implements ActivityVisitor, StateUpdater, InsertionStartsListe
private StateManager stateManager;
private int currentLoad = 0;
private VehicleRoute route;
- private static Logger log = Logger.getLogger(UpdateLoads.class);
-
/**
* Updates load at activity level.
*
@@ -59,7 +57,7 @@ class UpdateLoads implements ActivityVisitor, StateUpdater, InsertionStartsListe
@Override
public void visit(TourActivity act) {
currentLoad += act.getCapacityDemand();
- stateManager.putActivityState(act, StateFactory.LOAD, StateFactory.createState(currentLoad));
+ stateManager.putInternalActivityState(act, StateFactory.LOAD, StateFactory.createState(currentLoad));
assert currentLoad <= route.getVehicle().getCapacity() : "currentLoad at activity must not be > vehicleCapacity";
assert currentLoad >= 0 : "currentLoad at act must not be < 0";
}
@@ -81,8 +79,8 @@ class UpdateLoads implements ActivityVisitor, StateUpdater, InsertionStartsListe
loadAtEnd += j.getCapacityDemand();
}
}
- stateManager.putRouteState(route, StateFactory.LOAD_AT_BEGINNING, StateFactory.createState(loadAtDepot));
- stateManager.putRouteState(route, StateFactory.LOAD_AT_END, StateFactory.createState(loadAtEnd));
+ stateManager.putInternalRouteState(route, StateFactory.LOAD_AT_BEGINNING, StateFactory.createState(loadAtDepot));
+ stateManager.putInternalRouteState(route, StateFactory.LOAD_AT_END, StateFactory.createState(loadAtEnd));
}
@Override
@@ -97,22 +95,14 @@ class UpdateLoads implements ActivityVisitor, StateUpdater, InsertionStartsListe
if(job2insert instanceof Delivery){
int loadAtDepot = (int) stateManager.getRouteState(inRoute, StateFactory.LOAD_AT_BEGINNING).toDouble();
// log.info("loadAtDepot="+loadAtDepot);
- stateManager.putRouteState(inRoute, StateFactory.LOAD_AT_BEGINNING, StateFactory.createState(loadAtDepot + job2insert.getCapacityDemand()));
+ stateManager.putInternalRouteState(inRoute, StateFactory.LOAD_AT_BEGINNING, StateFactory.createState(loadAtDepot + job2insert.getCapacityDemand()));
}
else if(job2insert instanceof Pickup || job2insert instanceof Service){
int loadAtEnd = (int) stateManager.getRouteState(inRoute, StateFactory.LOAD_AT_END).toDouble();
// log.info("loadAtEnd="+loadAtEnd);
- stateManager.putRouteState(inRoute, StateFactory.LOAD_AT_END, StateFactory.createState(loadAtEnd + job2insert.getCapacityDemand()));
+ stateManager.putInternalRouteState(inRoute, StateFactory.LOAD_AT_END, StateFactory.createState(loadAtEnd + job2insert.getCapacityDemand()));
}
}
-// private void log(VehicleRoute inRoute) {
-// log.debug(inRoute.getStart());
-// for(TourActivity act : inRoute.getTourActivities().getActivities()){
-// log.debug(act);
-// }
-// log.debug(inRoute.getEnd());
-//
-// }
}
\ No newline at end of file
diff --git a/jsprit-core/src/main/java/algorithms/UpdateMaxLoad.java b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateMaxLoad.java
similarity index 52%
rename from jsprit-core/src/main/java/algorithms/UpdateMaxLoad.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateMaxLoad.java
index 7f33bf3f..8ea51264 100644
--- a/jsprit-core/src/main/java/algorithms/UpdateMaxLoad.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateMaxLoad.java
@@ -1,18 +1,15 @@
-package algorithms;
+package jsprit.core.algorithm.state;
-import org.apache.log4j.Logger;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.solution.route.activity.ReverseActivityVisitor;
+import jsprit.core.problem.solution.route.activity.TourActivity;
+import jsprit.core.problem.solution.route.state.StateFactory;
-import basics.route.ReverseActivityVisitor;
-import basics.route.TourActivity;
-import basics.route.VehicleRoute;
class UpdateMaxLoad implements ReverseActivityVisitor, StateUpdater {
- private static Logger log = Logger.getLogger(UpdateMaxLoad.class);
private StateManager stateManager;
private VehicleRoute route;
private double maxLoad;
- private double currLoad;
-
public UpdateMaxLoad(StateManager stateManager) {
super();
this.stateManager = stateManager;
@@ -22,23 +19,16 @@ class UpdateMaxLoad implements ReverseActivityVisitor, StateUpdater {
public void begin(VehicleRoute route) {
this.route = route;
maxLoad = stateManager.getRouteState(route, StateFactory.LOAD_AT_END).toDouble();
-// currLoad = maxLoad;
-// log.debug("maxLoad@end="+maxLoad);
}
@Override
public void visit(TourActivity act) {
maxLoad = Math.max(maxLoad, stateManager.getActivityState(act, StateFactory.LOAD).toDouble());
-// currLoad -= act.getCapacityDemand();
-// log.debug("maxLoad@"+act+"="+maxLoad);
- stateManager.putActivityState(act, StateFactory.FUTURE_PICKS, StateFactory.createState(maxLoad));
+ stateManager.putInternalActivityState(act, StateFactory.FUTURE_MAXLOAD, StateFactory.createState(maxLoad));
assert maxLoad <= route.getVehicle().getCapacity() : "maxLoad can never be bigger than vehicleCap";
assert maxLoad >= 0 : "maxLoad can never be smaller than 0";
}
@Override
- public void finish() {
-// stateManager.putRouteState(route, StateFactory.MAXLOAD, StateFactory.createState(maxLoad));
-// log.debug("maxLoad@start="+maxLoad);
- }
+ public void finish() {}
}
\ No newline at end of file
diff --git a/jsprit-core/src/main/java/algorithms/UpdateMaxLoad_.java b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateMaxLoad_.java
similarity index 81%
rename from jsprit-core/src/main/java/algorithms/UpdateMaxLoad_.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateMaxLoad_.java
index 382d4811..181ffa77 100644
--- a/jsprit-core/src/main/java/algorithms/UpdateMaxLoad_.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateMaxLoad_.java
@@ -1,8 +1,9 @@
-package algorithms;
+package jsprit.core.algorithm.state;
-import basics.route.ActivityVisitor;
-import basics.route.TourActivity;
-import basics.route.VehicleRoute;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.solution.route.activity.ActivityVisitor;
+import jsprit.core.problem.solution.route.activity.TourActivity;
+import jsprit.core.problem.solution.route.state.StateFactory;
/**
* Updates load at activity level.
@@ -60,7 +61,7 @@ class UpdateMaxLoad_ implements ActivityVisitor, StateUpdater {
@Override
public void finish() {
- stateManager.putRouteState(route, StateFactory.MAXLOAD, StateFactory.createState(maxLoad));
+ stateManager.putInternalRouteState(route, StateFactory.MAXLOAD, StateFactory.createState(maxLoad));
currentLoad = 0;
maxLoad = 0;
}
diff --git a/jsprit-core/src/main/java/algorithms/UpdatePrevMaxLoad.java b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdatePrevMaxLoad.java
similarity index 62%
rename from jsprit-core/src/main/java/algorithms/UpdatePrevMaxLoad.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdatePrevMaxLoad.java
index 1536f1bb..ff87c2cd 100644
--- a/jsprit-core/src/main/java/algorithms/UpdatePrevMaxLoad.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdatePrevMaxLoad.java
@@ -1,13 +1,12 @@
-package algorithms;
+package jsprit.core.algorithm.state;
-import org.apache.log4j.Logger;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.solution.route.activity.ActivityVisitor;
+import jsprit.core.problem.solution.route.activity.TourActivity;
+import jsprit.core.problem.solution.route.state.StateFactory;
-import basics.route.ActivityVisitor;
-import basics.route.TourActivity;
-import basics.route.VehicleRoute;
class UpdatePrevMaxLoad implements ActivityVisitor, StateUpdater {
- private static Logger log = Logger.getLogger(UpdatePrevMaxLoad.class);
private StateManager stateManager;
private VehicleRoute route;
private double currLoad;
@@ -23,20 +22,16 @@ class UpdatePrevMaxLoad implements ActivityVisitor, StateUpdater {
this.route = route;
currLoad = stateManager.getRouteState(route, StateFactory.LOAD_AT_BEGINNING).toDouble();
prevMaxLoad = currLoad;
-// log.debug("prevMaxLoad@start="+prevMaxLoad);
}
@Override
public void visit(TourActivity act) {
prevMaxLoad = Math.max(prevMaxLoad, stateManager.getActivityState(act, StateFactory.LOAD).toDouble());
-// log.debug("prevMaxLoad@"+act+"="+prevMaxLoad);
- stateManager.putActivityState(act, StateFactory.PAST_DELIVERIES, StateFactory.createState(prevMaxLoad));
+ stateManager.putInternalActivityState(act, StateFactory.PAST_MAXLOAD, StateFactory.createState(prevMaxLoad));
assert prevMaxLoad >= 0 : "maxLoad can never be smaller than 0";
assert prevMaxLoad <= route.getVehicle().getCapacity() : "maxLoad can never be bigger than vehicleCap";
}
@Override
- public void finish() {
-// log.debug("prevMaxLoad@end="+prevMaxLoad);
- }
+ public void finish() {}
}
\ No newline at end of file
diff --git a/jsprit-core/src/main/java/algorithms/TimeWindowUpdater.java b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateTimeWindow.java
similarity index 60%
rename from jsprit-core/src/main/java/algorithms/TimeWindowUpdater.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateTimeWindow.java
index e174e5e3..c74cc69a 100644
--- a/jsprit-core/src/main/java/algorithms/TimeWindowUpdater.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateTimeWindow.java
@@ -1,17 +1,14 @@
-package algorithms;
+package jsprit.core.algorithm.state;
-import org.apache.log4j.Logger;
+import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.solution.route.activity.ReverseActivityVisitor;
+import jsprit.core.problem.solution.route.activity.TourActivity;
+import jsprit.core.problem.solution.route.state.StateFactory;
-import algorithms.StateManager.StateImpl;
-import basics.costs.VehicleRoutingTransportCosts;
-import basics.route.ReverseActivityVisitor;
-import basics.route.TourActivity;
-import basics.route.VehicleRoute;
-class TimeWindowUpdater implements ReverseActivityVisitor, StateUpdater{
+class UpdateTimeWindow implements ReverseActivityVisitor, StateUpdater{
- private static Logger log = Logger.getLogger(TimeWindowUpdater.class);
-
private StateManager states;
private VehicleRoute route;
@@ -22,7 +19,7 @@ class TimeWindowUpdater implements ReverseActivityVisitor, StateUpdater{
private TourActivity prevAct;
- public TimeWindowUpdater(StateManager states, VehicleRoutingTransportCosts tpCosts) {
+ public UpdateTimeWindow(StateManager states, VehicleRoutingTransportCosts tpCosts) {
super();
this.states = states;
this.transportCosts = tpCosts;
@@ -40,7 +37,7 @@ class TimeWindowUpdater implements ReverseActivityVisitor, StateUpdater{
double potentialLatestArrivalTimeAtCurrAct = latestArrTimeAtPrevAct - transportCosts.getBackwardTransportTime(activity.getLocationId(), prevAct.getLocationId(), latestArrTimeAtPrevAct, route.getDriver(),route.getVehicle()) - activity.getOperationTime();
double latestArrivalTime = Math.min(activity.getTheoreticalLatestOperationStartTime(), potentialLatestArrivalTimeAtCurrAct);
- states.putActivityState(activity, StateFactory.LATEST_OPERATION_START_TIME, new StateImpl(latestArrivalTime));
+ states.putInternalActivityState(activity, StateFactory.LATEST_OPERATION_START_TIME, StateFactory.createState(latestArrivalTime));
latestArrTimeAtPrevAct = latestArrivalTime;
prevAct = activity;
diff --git a/jsprit-core/src/main/java/algorithms/UpdateVariableCosts.java b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateVariableCosts.java
similarity index 66%
rename from jsprit-core/src/main/java/algorithms/UpdateVariableCosts.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateVariableCosts.java
index f8383b50..391f090c 100644
--- a/jsprit-core/src/main/java/algorithms/UpdateVariableCosts.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/state/UpdateVariableCosts.java
@@ -1,15 +1,16 @@
-package algorithms;
+package jsprit.core.algorithm.state;
+
+import jsprit.core.problem.cost.ForwardTransportCost;
+import jsprit.core.problem.cost.VehicleRoutingActivityCosts;
+import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
+import jsprit.core.problem.solution.route.VehicleRoute;
+import jsprit.core.problem.solution.route.activity.ActivityVisitor;
+import jsprit.core.problem.solution.route.activity.TourActivity;
+import jsprit.core.problem.solution.route.state.StateFactory;
+import jsprit.core.util.ActivityTimeTracker;
import org.apache.log4j.Logger;
-import util.ActivityTimeTracker;
-import algorithms.StateManager.StateImpl;
-import basics.costs.ForwardTransportCost;
-import basics.costs.VehicleRoutingActivityCosts;
-import basics.costs.VehicleRoutingTransportCosts;
-import basics.route.ActivityVisitor;
-import basics.route.TourActivity;
-import basics.route.VehicleRoute;
/**
* Updates total costs (i.e. transport and activity costs) at route and activity level.
@@ -22,7 +23,7 @@ import basics.route.VehicleRoute;
* @param transportCost
* @param states
*/
-class UpdateVariableCosts implements ActivityVisitor,StateUpdater{
+public class UpdateVariableCosts implements ActivityVisitor,StateUpdater{
private static Logger log = Logger.getLogger(UpdateVariableCosts.class);
@@ -64,7 +65,7 @@ class UpdateVariableCosts implements ActivityVisitor,StateUpdater{
@Override
public void begin(VehicleRoute route) {
vehicleRoute = route;
- vehicleRoute.getVehicleRouteCostCalculator().reset();
+// vehicleRoute.getVehicleRouteCostCalculator().reset();
timeTracker.begin(route);
prevAct = route.getStart();
startTimeAtPrevAct = timeTracker.getActEndTime();
@@ -77,13 +78,13 @@ class UpdateVariableCosts implements ActivityVisitor,StateUpdater{
double transportCost = this.transportCost.getTransportCost(prevAct.getLocationId(), act.getLocationId(), startTimeAtPrevAct, vehicleRoute.getDriver(), vehicleRoute.getVehicle());
double actCost = activityCost.getActivityCost(act, timeTracker.getActArrTime(), vehicleRoute.getDriver(), vehicleRoute.getVehicle());
- vehicleRoute.getVehicleRouteCostCalculator().addTransportCost(transportCost);
- vehicleRoute.getVehicleRouteCostCalculator().addActivityCost(actCost);
-
+// vehicleRoute.getVehicleRouteCostCalculator().addTransportCost(transportCost);
+// vehicleRoute.getVehicleRouteCostCalculator().addActivityCost(actCost);
+//
totalOperationCost += transportCost;
totalOperationCost += actCost;
- states.putActivityState(act, StateFactory.COSTS, new StateImpl(totalOperationCost));
+ states.putInternalActivityState(act, StateFactory.COSTS, StateFactory.createState(totalOperationCost));
prevAct = act;
startTimeAtPrevAct = timeTracker.getActEndTime();
@@ -95,19 +96,19 @@ class UpdateVariableCosts implements ActivityVisitor,StateUpdater{
double transportCost = this.transportCost.getTransportCost(prevAct.getLocationId(), vehicleRoute.getEnd().getLocationId(), startTimeAtPrevAct, vehicleRoute.getDriver(), vehicleRoute.getVehicle());
double actCost = activityCost.getActivityCost(vehicleRoute.getEnd(), timeTracker.getActEndTime(), vehicleRoute.getDriver(), vehicleRoute.getVehicle());
- vehicleRoute.getVehicleRouteCostCalculator().addTransportCost(transportCost);
- vehicleRoute.getVehicleRouteCostCalculator().addActivityCost(actCost);
-
+// vehicleRoute.getVehicleRouteCostCalculator().addTransportCost(transportCost);
+// vehicleRoute.getVehicleRouteCostCalculator().addActivityCost(actCost);
+//
totalOperationCost += transportCost;
totalOperationCost += actCost;
// totalOperationCost += getFixCosts(vehicleRoute.getVehicle());
- states.putRouteState(vehicleRoute, StateFactory.COSTS, new StateImpl(totalOperationCost));
+ states.putInternalRouteState(vehicleRoute, StateFactory.COSTS, StateFactory.createState(totalOperationCost));
- //this is rather strange and likely to change
- vehicleRoute.getVehicleRouteCostCalculator().price(vehicleRoute.getDriver());
- vehicleRoute.getVehicleRouteCostCalculator().price(vehicleRoute.getVehicle());
- vehicleRoute.getVehicleRouteCostCalculator().finish();
+// //this is rather strange and likely to change
+// vehicleRoute.getVehicleRouteCostCalculator().price(vehicleRoute.getDriver());
+// vehicleRoute.getVehicleRouteCostCalculator().price(vehicleRoute.getVehicle());
+// vehicleRoute.getVehicleRouteCostCalculator().finish();
startTimeAtPrevAct = 0.0;
prevAct = null;
diff --git a/jsprit-core/src/main/java/basics/algo/IterationWithoutImprovementBreaker.java b/jsprit-core/src/main/java/jsprit/core/algorithm/termination/IterationWithoutImprovementTermination.java
similarity index 83%
rename from jsprit-core/src/main/java/basics/algo/IterationWithoutImprovementBreaker.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/termination/IterationWithoutImprovementTermination.java
index 60478f93..dd14af26 100644
--- a/jsprit-core/src/main/java/basics/algo/IterationWithoutImprovementBreaker.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/termination/IterationWithoutImprovementTermination.java
@@ -14,21 +14,22 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics.algo;
+package jsprit.core.algorithm.termination;
+
+import jsprit.core.algorithm.SearchStrategy.DiscoveredSolution;
import org.apache.log4j.Logger;
-import basics.algo.SearchStrategy.DiscoveredSolution;
-public class IterationWithoutImprovementBreaker implements PrematureAlgorithmBreaker{
+public class IterationWithoutImprovementTermination implements PrematureAlgorithmTermination{
- private static Logger log = Logger.getLogger(IterationWithoutImprovementBreaker.class);
+ private static Logger log = Logger.getLogger(IterationWithoutImprovementTermination.class);
private int nuOfIterationWithoutImprovement;
private int iterationsWithoutImprovement = 0;
- public IterationWithoutImprovementBreaker(int nuOfIterationsWithoutImprovement){
+ public IterationWithoutImprovementTermination(int nuOfIterationsWithoutImprovement){
this.nuOfIterationWithoutImprovement=nuOfIterationsWithoutImprovement;
log.info("initialise " + this);
}
diff --git a/jsprit-core/src/main/java/basics/algo/PrematureAlgorithmBreaker.java b/jsprit-core/src/main/java/jsprit/core/algorithm/termination/PrematureAlgorithmTermination.java
similarity index 86%
rename from jsprit-core/src/main/java/basics/algo/PrematureAlgorithmBreaker.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/termination/PrematureAlgorithmTermination.java
index 0fe78f55..78d31e5d 100644
--- a/jsprit-core/src/main/java/basics/algo/PrematureAlgorithmBreaker.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/termination/PrematureAlgorithmTermination.java
@@ -14,11 +14,11 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics.algo;
+package jsprit.core.algorithm.termination;
-import basics.algo.SearchStrategy.DiscoveredSolution;
+import jsprit.core.algorithm.SearchStrategy.DiscoveredSolution;
-public interface PrematureAlgorithmBreaker {
+public interface PrematureAlgorithmTermination {
public boolean isPrematureBreak(DiscoveredSolution discoveredSolution);
diff --git a/jsprit-core/src/main/java/basics/algo/TimeBreaker.java b/jsprit-core/src/main/java/jsprit/core/algorithm/termination/TimeTermination.java
similarity index 78%
rename from jsprit-core/src/main/java/basics/algo/TimeBreaker.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/termination/TimeTermination.java
index 447f2f7b..641e3337 100644
--- a/jsprit-core/src/main/java/basics/algo/TimeBreaker.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/termination/TimeTermination.java
@@ -14,16 +14,18 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics.algo;
+package jsprit.core.algorithm.termination;
import java.util.Collection;
+import jsprit.core.algorithm.SearchStrategy.DiscoveredSolution;
+import jsprit.core.algorithm.VehicleRoutingAlgorithm;
+import jsprit.core.algorithm.listener.AlgorithmStartsListener;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+
import org.apache.log4j.Logger;
-import basics.VehicleRoutingAlgorithm;
-import basics.VehicleRoutingProblem;
-import basics.VehicleRoutingProblemSolution;
-import basics.algo.SearchStrategy.DiscoveredSolution;
/**
* Breaks algorithm prematurely based on specified time.
@@ -34,9 +36,9 @@ import basics.algo.SearchStrategy.DiscoveredSolution;
* @author stefan
*
*/
-public class TimeBreaker implements PrematureAlgorithmBreaker, AlgorithmStartsListener{
+public class TimeTermination implements PrematureAlgorithmTermination, AlgorithmStartsListener{
- private static Logger logger = Logger.getLogger(TimeBreaker.class);
+ private static Logger logger = Logger.getLogger(TimeTermination.class);
private double timeThreshold;
@@ -51,7 +53,7 @@ public class TimeBreaker implements PrematureAlgorithmBreaker, AlgorithmStartsLi
* @author stefan
*
*/
- public TimeBreaker(double time_in_seconds) {
+ public TimeTermination(double time_in_seconds) {
super();
this.timeThreshold = time_in_seconds;
logger.info("initialise " + this);
diff --git a/jsprit-core/src/main/java/basics/algo/VariationCoefficientBreaker.java b/jsprit-core/src/main/java/jsprit/core/algorithm/termination/VariationCoefficientTermination.java
similarity index 83%
rename from jsprit-core/src/main/java/basics/algo/VariationCoefficientBreaker.java
rename to jsprit-core/src/main/java/jsprit/core/algorithm/termination/VariationCoefficientTermination.java
index f3c75691..f5fe144f 100644
--- a/jsprit-core/src/main/java/basics/algo/VariationCoefficientBreaker.java
+++ b/jsprit-core/src/main/java/jsprit/core/algorithm/termination/VariationCoefficientTermination.java
@@ -14,19 +14,23 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics.algo;
+package jsprit.core.algorithm.termination;
import java.util.Collection;
+import jsprit.core.algorithm.SearchStrategy.DiscoveredSolution;
+import jsprit.core.algorithm.VehicleRoutingAlgorithm;
+import jsprit.core.algorithm.listener.AlgorithmStartsListener;
+import jsprit.core.algorithm.listener.IterationEndsListener;
+import jsprit.core.algorithm.listener.IterationStartsListener;
+import jsprit.core.problem.VehicleRoutingProblem;
+import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
+import jsprit.core.util.Solutions;
+
import org.apache.commons.math.stat.StatUtils;
import org.apache.commons.math.stat.descriptive.moment.StandardDeviation;
import org.apache.log4j.Logger;
-import util.Solutions;
-import basics.VehicleRoutingAlgorithm;
-import basics.VehicleRoutingProblem;
-import basics.VehicleRoutingProblemSolution;
-import basics.algo.SearchStrategy.DiscoveredSolution;
/**
* Breaks algorithm prematurely based on variationCoefficient.
@@ -38,9 +42,9 @@ import basics.algo.SearchStrategy.DiscoveredSolution;
* @author stefan
*
*/
-public class VariationCoefficientBreaker implements PrematureAlgorithmBreaker, IterationStartsListener, AlgorithmStartsListener, IterationEndsListener{
+public class VariationCoefficientTermination implements PrematureAlgorithmTermination, IterationStartsListener, AlgorithmStartsListener, IterationEndsListener{
- private static Logger logger = Logger.getLogger(VariationCoefficientBreaker.class);
+ private static Logger logger = Logger.getLogger(VariationCoefficientTermination.class);
private int nuOfIterations;
@@ -62,7 +66,7 @@ public class VariationCoefficientBreaker implements PrematureAlgorithmBreaker, I
* @author stefan
*
*/
- public VariationCoefficientBreaker(int nuOfIterations, double variationCoefficientThreshold) {
+ public VariationCoefficientTermination(int nuOfIterations, double variationCoefficientThreshold) {
super();
this.nuOfIterations = nuOfIterations;
this.variationCoefficientThreshold = variationCoefficientThreshold;
diff --git a/jsprit-core/src/main/java/basics/VehicleRoutingProblem.java b/jsprit-core/src/main/java/jsprit/core/problem/VehicleRoutingProblem.java
similarity index 92%
rename from jsprit-core/src/main/java/basics/VehicleRoutingProblem.java
rename to jsprit-core/src/main/java/jsprit/core/problem/VehicleRoutingProblem.java
index 076ed956..321a122e 100644
--- a/jsprit-core/src/main/java/basics/VehicleRoutingProblem.java
+++ b/jsprit-core/src/main/java/jsprit/core/problem/VehicleRoutingProblem.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
******************************************************************************/
-package basics;
+package jsprit.core.problem;
import java.util.ArrayList;
import java.util.Collection;
@@ -22,18 +22,23 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import jsprit.core.problem.cost.VehicleRoutingActivityCosts;
+import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
+import jsprit.core.problem.driver.Driver;
+import jsprit.core.problem.job.Job;
+import jsprit.core.problem.job.Service;
+import jsprit.core.problem.job.Shipment;
+import jsprit.core.problem.solution.route.activity.TourActivity;
+import jsprit.core.problem.vehicle.Vehicle;
+import jsprit.core.problem.vehicle.VehicleType;
+import jsprit.core.problem.vehicle.VehicleTypeImpl;
+import jsprit.core.util.Coordinate;
+import jsprit.core.util.CrowFlyCosts;
+import jsprit.core.util.Locations;
+import jsprit.core.util.Neighborhood;
+
import org.apache.log4j.Logger;
-import util.Coordinate;
-import util.CrowFlyCosts;
-import util.Locations;
-import util.Neighborhood;
-import basics.costs.DefaultVehicleRoutingActivityCosts;
-import basics.costs.VehicleRoutingActivityCosts;
-import basics.costs.VehicleRoutingTransportCosts;
-import basics.route.Vehicle;
-import basics.route.VehicleType;
-import basics.route.VehicleTypeImpl;
/**
* Contains and describes the vehicle routing problem.
@@ -81,7 +86,19 @@ public class VehicleRoutingProblem {
private VehicleRoutingTransportCosts transportCosts;
- private VehicleRoutingActivityCosts activityCosts = new DefaultVehicleRoutingActivityCosts();
+ private VehicleRoutingActivityCosts activityCosts = new VehicleRoutingActivityCosts() {
+
+ @Override
+ public double getActivityCost(TourActivity tourAct, double arrivalTime, Driver driver, Vehicle vehicle) {
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return "[name=defaultActivityCosts]";
+ }
+
+ };
private Map jobs;
@@ -201,9 +218,11 @@ public class VehicleRoutingProblem {
*
*