mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
move io to jsprit-io
This commit is contained in:
parent
3966590fc7
commit
667db19f32
33 changed files with 169 additions and 2300 deletions
|
|
@ -26,7 +26,7 @@ import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolutio
|
|||
import com.graphhopper.jsprit.core.util.BenchmarkInstance;
|
||||
import com.graphhopper.jsprit.core.util.BenchmarkResult;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
|
||||
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
|
|
|||
|
|
@ -55,68 +55,25 @@
|
|||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<!--<plugin>-->
|
||||
<!--<artifactId>maven-surefire-plugin</artifactId>-->
|
||||
<!--<version>2.18.1</version>-->
|
||||
<!--<configuration>-->
|
||||
<!--<excludedGroups>IntegrationTest</excludedGroups>-->
|
||||
<!--</configuration>-->
|
||||
<!--</plugin>-->
|
||||
<!--<plugin>-->
|
||||
<!--<artifactId>maven-failsafe-plugin</artifactId>-->
|
||||
<!--<version>2.18.1</version>-->
|
||||
<!--<configuration>-->
|
||||
<!--<includes>-->
|
||||
<!--<include>**/*.java</include>-->
|
||||
<!--</includes>-->
|
||||
<!--<groups>IntegrationTest</groups>-->
|
||||
<!--</configuration>-->
|
||||
<!--<executions>-->
|
||||
<!--<execution>-->
|
||||
<!--<goals>-->
|
||||
<!--<goal>integration-test</goal>-->
|
||||
<!--<goal>verify</goal>-->
|
||||
<!--</goals>-->
|
||||
<!--</execution>-->
|
||||
<!--</executions>-->
|
||||
<!--</plugin>-->
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-math</artifactId>
|
||||
<version>2.2</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-configuration</groupId>
|
||||
<artifactId>commons-configuration</artifactId>
|
||||
<version>1.9</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
<version>2.11.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-math3</artifactId>
|
||||
<version>3.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${logger.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,177 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2014 Stefan Schroeder
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package com.graphhopper.jsprit.core.algorithm;
|
||||
|
||||
import com.graphhopper.jsprit.core.algorithm.io.AlgorithmConfig;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.AlgorithmConfigXmlReader;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.UpdateEndLocationIfRouteIsOpen;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.constraint.ConstraintManager;
|
||||
import com.graphhopper.jsprit.core.problem.solution.SolutionCostCalculator;
|
||||
|
||||
/**
|
||||
* Builder that builds a {@link VehicleRoutingAlgorithm}.
|
||||
*
|
||||
* @author schroeder
|
||||
*/
|
||||
public class VehicleRoutingAlgorithmBuilder {
|
||||
|
||||
private String algorithmConfigFile;
|
||||
|
||||
private AlgorithmConfig algorithmConfig;
|
||||
|
||||
private final VehicleRoutingProblem vrp;
|
||||
|
||||
private SolutionCostCalculator solutionCostCalculator;
|
||||
|
||||
private StateManager stateManager;
|
||||
|
||||
private boolean addCoreConstraints = false;
|
||||
|
||||
private boolean addDefaultCostCalculators = false;
|
||||
|
||||
private ConstraintManager constraintManager;
|
||||
|
||||
private int nuOfThreads = 0;
|
||||
|
||||
/**
|
||||
* Constructs the builder with the problem and an algorithmConfigFile. Latter is to configure and specify the ruin-and-recreate meta-heuristic.
|
||||
*
|
||||
* @param problem to solve
|
||||
* @param algorithmConfig config file of VehicleRoutingAlgorithm
|
||||
*/
|
||||
public VehicleRoutingAlgorithmBuilder(VehicleRoutingProblem problem, String algorithmConfig) {
|
||||
this.vrp = problem;
|
||||
this.algorithmConfigFile = algorithmConfig;
|
||||
this.algorithmConfig = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the builder with the problem and an algorithmConfig. Latter is to configure and specify the ruin-and-recreate meta-heuristic.
|
||||
*
|
||||
* @param problem to solve
|
||||
* @param algorithmConfig config file of VehicleRoutingAlgorithm
|
||||
*/
|
||||
public VehicleRoutingAlgorithmBuilder(VehicleRoutingProblem problem, AlgorithmConfig algorithmConfig) {
|
||||
this.vrp = problem;
|
||||
this.algorithmConfigFile = null;
|
||||
this.algorithmConfig = algorithmConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets custom objective function.
|
||||
* <p>
|
||||
* <p>If objective function is not set, a default function is applied (which basically minimizes
|
||||
* fixed and variable transportation costs ({@link VariablePlusFixedSolutionCostCalculatorFactory}).
|
||||
*
|
||||
* @param objectiveFunction to be minimized
|
||||
* @see VariablePlusFixedSolutionCostCalculatorFactory
|
||||
*/
|
||||
public void setObjectiveFunction(SolutionCostCalculator objectiveFunction) {
|
||||
this.solutionCostCalculator = objectiveFunction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets stateManager to memorize states.
|
||||
*
|
||||
* @param stateManager that memorizes your states
|
||||
* @see StateManager
|
||||
*/
|
||||
public void setStateManager(StateManager stateManager) {
|
||||
this.stateManager = stateManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds core constraints.
|
||||
* <p>
|
||||
* <p>Thus, it adds vehicle-capacity, time-window and skills constraints and their
|
||||
* required stateUpdater.
|
||||
*/
|
||||
public void addCoreConstraints() {
|
||||
addCoreConstraints = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds default cost calculators used by the insertion heuristic,
|
||||
* to calculate activity insertion costs.
|
||||
* By default, marginal transportation costs are calculated. Thus when inserting
|
||||
* act_k between act_i and act_j, marginal (additional) transportation costs
|
||||
* are basically c(act_i,act_k)+c(act_k,act_j)-c(act_i,act_j).
|
||||
* <p>
|
||||
* <p>Do not use this method, if you plan to control the insertion heuristic
|
||||
* entirely via hard- and soft-constraints.
|
||||
*/
|
||||
public void addDefaultCostCalculators() {
|
||||
addDefaultCostCalculators = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets state- and constraintManager.
|
||||
*
|
||||
* @param stateManager that memorizes your states
|
||||
* @param constraintManager that manages your constraints
|
||||
* @see StateManager
|
||||
* @see ConstraintManager
|
||||
*/
|
||||
public void setStateAndConstraintManager(StateManager stateManager, ConstraintManager constraintManager) {
|
||||
this.stateManager = stateManager;
|
||||
this.constraintManager = constraintManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets nuOfThreads.
|
||||
*
|
||||
* @param nuOfThreads to be operated
|
||||
*/
|
||||
public void setNuOfThreads(int nuOfThreads) {
|
||||
this.nuOfThreads = nuOfThreads;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds and returns the algorithm.
|
||||
* <p>
|
||||
* <p>If algorithmConfigFile is set, it reads the configuration.
|
||||
*
|
||||
* @return the algorithm
|
||||
*/
|
||||
public VehicleRoutingAlgorithm build() {
|
||||
if (stateManager == null) stateManager = new StateManager(vrp);
|
||||
if (constraintManager == null) constraintManager = new ConstraintManager(vrp, stateManager);
|
||||
//add core updater
|
||||
stateManager.addStateUpdater(new UpdateEndLocationIfRouteIsOpen());
|
||||
// stateManager.addStateUpdater(new OpenRouteStateVerifier());
|
||||
|
||||
if (addCoreConstraints) {
|
||||
constraintManager.addLoadConstraint();
|
||||
constraintManager.addTimeWindowConstraint();
|
||||
constraintManager.addSkillsConstraint();
|
||||
stateManager.updateLoadStates();
|
||||
stateManager.updateTimeWindowStates();
|
||||
stateManager.updateSkillStates();
|
||||
}
|
||||
if (algorithmConfig == null) {
|
||||
algorithmConfig = new AlgorithmConfig();
|
||||
AlgorithmConfigXmlReader xmlReader = new AlgorithmConfigXmlReader(algorithmConfig);
|
||||
xmlReader.read(algorithmConfigFile);
|
||||
}
|
||||
return VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, algorithmConfig, nuOfThreads, solutionCostCalculator, stateManager, constraintManager, addDefaultCostCalculators);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -17,21 +17,18 @@
|
|||
package com.graphhopper.jsprit.core.algorithm.acceptor;
|
||||
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.AlgorithmConfig;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.AlgorithmConfigXmlReader;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||
import com.graphhopper.jsprit.core.algorithm.box.GreedySchrimpfFactory;
|
||||
import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
||||
import com.graphhopper.jsprit.core.algorithm.listener.AlgorithmStartsListener;
|
||||
import com.graphhopper.jsprit.core.algorithm.listener.IterationEndsListener;
|
||||
import com.graphhopper.jsprit.core.algorithm.listener.IterationStartsListener;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.util.Resource;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import org.apache.commons.math.stat.descriptive.moment.StandardDeviation;
|
||||
import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
|
|
@ -114,10 +111,9 @@ public class ExperimentalSchrimpfAcceptance implements SolutionAcceptor, Iterati
|
|||
*/
|
||||
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);
|
||||
Jsprit.Builder builder = new GreedySchrimpfFactory().createGreedyAlgorithmBuilder(problem);
|
||||
builder.setCustomAcceptor(new AcceptNewRemoveFirst(1));
|
||||
VehicleRoutingAlgorithm vra = builder.buildAlgorithm();
|
||||
vra.setMaxIterations(nOfRandomWalks);
|
||||
vra.getAlgorithmListeners().addListener(new IterationEndsListener() {
|
||||
|
||||
|
|
|
|||
|
|
@ -17,20 +17,17 @@
|
|||
package com.graphhopper.jsprit.core.algorithm.acceptor;
|
||||
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.AlgorithmConfig;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.AlgorithmConfigXmlReader;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||
import com.graphhopper.jsprit.core.algorithm.box.GreedySchrimpfFactory;
|
||||
import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
||||
import com.graphhopper.jsprit.core.algorithm.listener.AlgorithmStartsListener;
|
||||
import com.graphhopper.jsprit.core.algorithm.listener.IterationEndsListener;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.util.Resource;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import org.apache.commons.math.stat.descriptive.moment.StandardDeviation;
|
||||
import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Collection;
|
||||
|
||||
public class SchrimpfInitialThresholdGenerator implements AlgorithmStartsListener {
|
||||
|
|
@ -57,10 +54,9 @@ public class SchrimpfInitialThresholdGenerator implements AlgorithmStartsListene
|
|||
*/
|
||||
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);
|
||||
Jsprit.Builder builder = new GreedySchrimpfFactory().createGreedyAlgorithmBuilder(problem);
|
||||
builder.setCustomAcceptor(new AcceptNewRemoveFirst(1));
|
||||
VehicleRoutingAlgorithm vra = builder.buildAlgorithm();
|
||||
vra.setMaxIterations(nOfRandomWalks);
|
||||
vra.getAlgorithmListeners().addListener(new IterationEndsListener() {
|
||||
|
||||
|
|
|
|||
|
|
@ -17,13 +17,7 @@
|
|||
package com.graphhopper.jsprit.core.algorithm.box;
|
||||
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.AlgorithmConfig;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.AlgorithmConfigXmlReader;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.util.Resource;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -53,11 +47,25 @@ public class GreedySchrimpfFactory {
|
|||
* @return algorithm
|
||||
*/
|
||||
public VehicleRoutingAlgorithm createAlgorithm(VehicleRoutingProblem vrp) {
|
||||
AlgorithmConfig algorithmConfig = new AlgorithmConfig();
|
||||
URL resource = Resource.getAsURL("greedySchrimpf.xml");
|
||||
new AlgorithmConfigXmlReader(algorithmConfig).read(resource);
|
||||
return VehicleRoutingAlgorithms.createAlgorithm(vrp, algorithmConfig);
|
||||
return createGreedyAlgorithmBuilder(vrp).buildAlgorithm();
|
||||
}
|
||||
|
||||
public Jsprit.Builder createGreedyAlgorithmBuilder(VehicleRoutingProblem vrp) {
|
||||
Jsprit.Builder builder = Jsprit.Builder.newInstance(vrp);
|
||||
builder.setProperty(Jsprit.Parameter.THRESHOLD_ALPHA,"0.0");
|
||||
builder.setProperty(Jsprit.Strategy.RADIAL_BEST, "0.5");
|
||||
builder.setProperty(Jsprit.Strategy.RADIAL_REGRET, "0.0");
|
||||
builder.setProperty(Jsprit.Strategy.RANDOM_BEST, "0.5");
|
||||
builder.setProperty(Jsprit.Strategy.RANDOM_REGRET, "0.0");
|
||||
builder.setProperty(Jsprit.Strategy.WORST_BEST, "0.0");
|
||||
builder.setProperty(Jsprit.Strategy.WORST_REGRET, "0.0");
|
||||
builder.setProperty(Jsprit.Strategy.CLUSTER_BEST, "0.0");
|
||||
builder.setProperty(Jsprit.Strategy.CLUSTER_REGRET, "0.0");
|
||||
builder.setProperty(Jsprit.Parameter.RADIAL_MIN_SHARE, String.valueOf(0.3));
|
||||
builder.setProperty(Jsprit.Parameter.RADIAL_MAX_SHARE, String.valueOf(0.3));
|
||||
builder.setProperty(Jsprit.Parameter.RANDOM_BEST_MIN_SHARE, String.valueOf(0.5));
|
||||
builder.setProperty(Jsprit.Parameter.RANDOM_BEST_MAX_SHARE, String.valueOf(0.5));
|
||||
return builder;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.graphhopper.jsprit.core.algorithm.PrettyAlgorithmBuilder;
|
|||
import com.graphhopper.jsprit.core.algorithm.SearchStrategy;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.acceptor.SchrimpfAcceptance;
|
||||
import com.graphhopper.jsprit.core.algorithm.acceptor.SolutionAcceptor;
|
||||
import com.graphhopper.jsprit.core.algorithm.listener.AlgorithmEndsListener;
|
||||
import com.graphhopper.jsprit.core.algorithm.listener.IterationStartsListener;
|
||||
import com.graphhopper.jsprit.core.algorithm.module.RuinAndRecreateModule;
|
||||
|
|
@ -139,6 +140,8 @@ public class Jsprit {
|
|||
|
||||
private ActivityInsertionCostsCalculator activityInsertionCalculator;
|
||||
|
||||
private SolutionAcceptor solutionAcceptor;
|
||||
|
||||
public static Builder newInstance(VehicleRoutingProblem vrp) {
|
||||
return new Builder(vrp);
|
||||
}
|
||||
|
|
@ -197,6 +200,11 @@ public class Jsprit {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder setCustomAcceptor(SolutionAcceptor acceptor){
|
||||
this.solutionAcceptor = acceptor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setRandom(Random random) {
|
||||
this.random = random;
|
||||
return this;
|
||||
|
|
@ -298,6 +306,8 @@ public class Jsprit {
|
|||
|
||||
private Random random;
|
||||
|
||||
private SolutionAcceptor acceptor;
|
||||
|
||||
private Jsprit(Builder builder) {
|
||||
this.stateManager = builder.stateManager;
|
||||
this.constraintManager = builder.constraintManager;
|
||||
|
|
@ -308,6 +318,7 @@ public class Jsprit {
|
|||
this.objectiveFunction = builder.objectiveFunction;
|
||||
this.random = builder.random;
|
||||
this.activityInsertion = builder.activityInsertionCalculator;
|
||||
this.acceptor = builder.solutionAcceptor;
|
||||
}
|
||||
|
||||
private VehicleRoutingAlgorithm create(final VehicleRoutingProblem vrp) {
|
||||
|
|
@ -496,40 +507,44 @@ public class Jsprit {
|
|||
}
|
||||
best.setRandom(random);
|
||||
|
||||
final SchrimpfAcceptance schrimpfAcceptance = new SchrimpfAcceptance(1, toDouble(getProperty(Parameter.THRESHOLD_ALPHA.toString())));
|
||||
IterationStartsListener schrimpfThreshold = new IterationStartsListener() {
|
||||
@Override
|
||||
public void informIterationStarts(int i, VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) {
|
||||
if (i == 1) {
|
||||
double initialThreshold = Solutions.bestOf(solutions).getCost() * toDouble(getProperty(Parameter.THRESHOLD_INI.toString()));
|
||||
schrimpfAcceptance.setInitialThreshold(initialThreshold);
|
||||
IterationStartsListener schrimpfThreshold = null;
|
||||
if(acceptor == null) {
|
||||
final SchrimpfAcceptance schrimpfAcceptance = new SchrimpfAcceptance(1, toDouble(getProperty(Parameter.THRESHOLD_ALPHA.toString())));
|
||||
schrimpfThreshold = new IterationStartsListener() {
|
||||
@Override
|
||||
public void informIterationStarts(int i, VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) {
|
||||
if (i == 1) {
|
||||
double initialThreshold = Solutions.bestOf(solutions).getCost() * toDouble(getProperty(Parameter.THRESHOLD_INI.toString()));
|
||||
schrimpfAcceptance.setInitialThreshold(initialThreshold);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
acceptor = schrimpfAcceptance;
|
||||
}
|
||||
|
||||
SolutionCostCalculator objectiveFunction = getObjectiveFunction(vrp, maxCosts);
|
||||
SearchStrategy radial_regret = new SearchStrategy(Strategy.RADIAL_REGRET.toString(), new SelectBest(), schrimpfAcceptance, objectiveFunction);
|
||||
SearchStrategy radial_regret = new SearchStrategy(Strategy.RADIAL_REGRET.toString(), new SelectBest(), acceptor, objectiveFunction);
|
||||
radial_regret.addModule(new RuinAndRecreateModule(Strategy.RADIAL_REGRET.toString(), regret, radial));
|
||||
|
||||
SearchStrategy radial_best = new SearchStrategy(Strategy.RADIAL_BEST.toString(), new SelectBest(), schrimpfAcceptance, objectiveFunction);
|
||||
SearchStrategy radial_best = new SearchStrategy(Strategy.RADIAL_BEST.toString(), new SelectBest(), acceptor, objectiveFunction);
|
||||
radial_best.addModule(new RuinAndRecreateModule(Strategy.RADIAL_BEST.toString(), best, radial));
|
||||
|
||||
SearchStrategy random_best = new SearchStrategy(Strategy.RANDOM_BEST.toString(), new SelectBest(), schrimpfAcceptance, objectiveFunction);
|
||||
SearchStrategy random_best = new SearchStrategy(Strategy.RANDOM_BEST.toString(), new SelectBest(), acceptor, objectiveFunction);
|
||||
random_best.addModule(new RuinAndRecreateModule(Strategy.RANDOM_BEST.toString(), best, random_for_best));
|
||||
|
||||
SearchStrategy random_regret = new SearchStrategy(Strategy.RANDOM_REGRET.toString(), new SelectBest(), schrimpfAcceptance, objectiveFunction);
|
||||
SearchStrategy random_regret = new SearchStrategy(Strategy.RANDOM_REGRET.toString(), new SelectBest(), acceptor, objectiveFunction);
|
||||
random_regret.addModule(new RuinAndRecreateModule(Strategy.RANDOM_REGRET.toString(), regret, random_for_regret));
|
||||
|
||||
SearchStrategy worst_regret = new SearchStrategy(Strategy.WORST_REGRET.toString(), new SelectBest(), schrimpfAcceptance, objectiveFunction);
|
||||
SearchStrategy worst_regret = new SearchStrategy(Strategy.WORST_REGRET.toString(), new SelectBest(), acceptor, objectiveFunction);
|
||||
worst_regret.addModule(new RuinAndRecreateModule(Strategy.WORST_REGRET.toString(), regret, worst));
|
||||
|
||||
SearchStrategy worst_best = new SearchStrategy(Strategy.WORST_BEST.toString(), new SelectBest(), schrimpfAcceptance, objectiveFunction);
|
||||
SearchStrategy worst_best = new SearchStrategy(Strategy.WORST_BEST.toString(), new SelectBest(), acceptor, objectiveFunction);
|
||||
worst_best.addModule(new RuinAndRecreateModule(Strategy.WORST_BEST.toString(), best, worst));
|
||||
|
||||
final SearchStrategy clusters_regret = new SearchStrategy(Strategy.CLUSTER_REGRET.toString(), new SelectBest(), schrimpfAcceptance, objectiveFunction);
|
||||
final SearchStrategy clusters_regret = new SearchStrategy(Strategy.CLUSTER_REGRET.toString(), new SelectBest(), acceptor, objectiveFunction);
|
||||
clusters_regret.addModule(new RuinAndRecreateModule(Strategy.CLUSTER_REGRET.toString(), regret, clusters));
|
||||
|
||||
final SearchStrategy clusters_best = new SearchStrategy(Strategy.CLUSTER_BEST.toString(), new SelectBest(), schrimpfAcceptance, objectiveFunction);
|
||||
final SearchStrategy clusters_best = new SearchStrategy(Strategy.CLUSTER_BEST.toString(), new SelectBest(), acceptor, objectiveFunction);
|
||||
clusters_best.addModule(new RuinAndRecreateModule(Strategy.CLUSTER_BEST.toString(), best, clusters));
|
||||
|
||||
|
||||
|
|
@ -554,7 +569,9 @@ public class Jsprit {
|
|||
|
||||
|
||||
VehicleRoutingAlgorithm vra = prettyBuilder.build();
|
||||
vra.addListener(schrimpfThreshold);
|
||||
if(schrimpfThreshold != null) {
|
||||
vra.addListener(schrimpfThreshold);
|
||||
}
|
||||
vra.addListener(noiseConfigurator);
|
||||
vra.addListener(noise);
|
||||
vra.addListener(clusters);
|
||||
|
|
|
|||
|
|
@ -17,13 +17,7 @@
|
|||
package com.graphhopper.jsprit.core.algorithm.box;
|
||||
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.AlgorithmConfig;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.AlgorithmConfigXmlReader;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.util.Resource;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -53,10 +47,23 @@ public class SchrimpfFactory {
|
|||
* @return algorithm
|
||||
*/
|
||||
public VehicleRoutingAlgorithm createAlgorithm(VehicleRoutingProblem vrp) {
|
||||
AlgorithmConfig algorithmConfig = new AlgorithmConfig();
|
||||
URL resource = Resource.getAsURL("schrimpf.xml");
|
||||
new AlgorithmConfigXmlReader(algorithmConfig).read(resource);
|
||||
return VehicleRoutingAlgorithms.createAlgorithm(vrp, algorithmConfig);
|
||||
//TODO determine alpha threshold
|
||||
|
||||
Jsprit.Builder builder = Jsprit.Builder.newInstance(vrp);
|
||||
builder.setProperty(Jsprit.Parameter.THRESHOLD_ALPHA,"0.0");
|
||||
builder.setProperty(Jsprit.Strategy.RADIAL_BEST, "0.5");
|
||||
builder.setProperty(Jsprit.Strategy.RADIAL_REGRET, "0.0");
|
||||
builder.setProperty(Jsprit.Strategy.RANDOM_BEST, "0.5");
|
||||
builder.setProperty(Jsprit.Strategy.RANDOM_REGRET, "0.0");
|
||||
builder.setProperty(Jsprit.Strategy.WORST_BEST, "0.0");
|
||||
builder.setProperty(Jsprit.Strategy.WORST_REGRET, "0.0");
|
||||
builder.setProperty(Jsprit.Strategy.CLUSTER_BEST, "0.0");
|
||||
builder.setProperty(Jsprit.Strategy.CLUSTER_REGRET, "0.0");
|
||||
builder.setProperty(Jsprit.Parameter.RADIAL_MIN_SHARE, String.valueOf(0.3));
|
||||
builder.setProperty(Jsprit.Parameter.RADIAL_MAX_SHARE, String.valueOf(0.3));
|
||||
builder.setProperty(Jsprit.Parameter.RANDOM_BEST_MIN_SHARE, String.valueOf(0.5));
|
||||
builder.setProperty(Jsprit.Parameter.RANDOM_BEST_MAX_SHARE, String.valueOf(0.5));
|
||||
return builder.buildAlgorithm();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ import com.graphhopper.jsprit.core.algorithm.listener.IterationStartsListener;
|
|||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import org.apache.commons.math.stat.StatUtils;
|
||||
import org.apache.commons.math.stat.descriptive.moment.StandardDeviation;
|
||||
import org.apache.commons.math3.stat.StatUtils;
|
||||
import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
******************************************************************************/
|
||||
package com.graphhopper.jsprit.core.util;
|
||||
|
||||
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
|
||||
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
|
||||
|
||||
|
||||
public class BenchmarkResult {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute;
|
|||
import com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import com.graphhopper.jsprit.io.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl;
|
|||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleType;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import com.graphhopper.jsprit.core.util.TestUtils;
|
||||
import com.graphhopper.jsprit.io.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,285 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2014 Stefan Schroeder
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package com.graphhopper.jsprit.core.algorithm.io;
|
||||
|
||||
import com.graphhopper.jsprit.core.algorithm.SearchStrategy;
|
||||
import com.graphhopper.jsprit.core.algorithm.SearchStrategyModule;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.acceptor.GreedyAcceptance;
|
||||
import com.graphhopper.jsprit.core.algorithm.acceptor.SolutionAcceptor;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.VehicleRoutingAlgorithms.ModKey;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap.AcceptorKey;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap.RuinStrategyKey;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap.SelectorKey;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap.StrategyModuleKey;
|
||||
import com.graphhopper.jsprit.core.algorithm.listener.IterationEndsListener;
|
||||
import com.graphhopper.jsprit.core.algorithm.listener.SearchStrategyModuleListener;
|
||||
import com.graphhopper.jsprit.core.algorithm.ruin.RuinStrategy;
|
||||
import com.graphhopper.jsprit.core.algorithm.ruin.listener.RuinListener;
|
||||
import com.graphhopper.jsprit.core.algorithm.selector.SelectBest;
|
||||
import com.graphhopper.jsprit.core.algorithm.selector.SolutionSelector;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.io.VrpXMLReader;
|
||||
import com.graphhopper.jsprit.core.problem.job.Job;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import junit.framework.Assert;
|
||||
import org.apache.commons.configuration.ConfigurationException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
||||
public class TestAlgorithmReader {
|
||||
|
||||
AlgorithmConfig config;
|
||||
|
||||
VehicleRoutingProblem vrp;
|
||||
|
||||
Collection<VehicleRoutingProblemSolution> solutions;
|
||||
|
||||
@Before
|
||||
public void doBefore() throws ConfigurationException {
|
||||
config = new AlgorithmConfig();
|
||||
new AlgorithmConfigXmlReader(config).setSchemaValidation(false).read("src/test/resources/testConfig.xml");
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
solutions = new ArrayList<VehicleRoutingProblemSolution>();
|
||||
new VrpXMLReader(vrpBuilder, solutions).read("src/test/resources/finiteVrp.xml");
|
||||
vrp = vrpBuilder.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldReadMaxIterations() {
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfigForReaderTest.xml");
|
||||
Assert.assertEquals(2000, vra.getMaxIterations());
|
||||
}
|
||||
|
||||
static class IterationCounter implements IterationEndsListener {
|
||||
|
||||
int iterations = 0;
|
||||
|
||||
@Override
|
||||
public void informIterationEnds(int i, VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) {
|
||||
iterations = i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSettingPrematureBreak_itShouldReadTermination() {
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfigForReaderTest2.xml");
|
||||
IterationCounter iCounter = new IterationCounter();
|
||||
vra.addListener(iCounter);
|
||||
vra.searchSolutions();
|
||||
Assert.assertEquals(100, iCounter.iterations);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itShouldReadTermination() {
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfigForReaderTest.xml");
|
||||
IterationCounter iCounter = new IterationCounter();
|
||||
vra.addListener(iCounter);
|
||||
vra.searchSolutions();
|
||||
Assert.assertEquals(25, iCounter.iterations);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testTypedMap() {
|
||||
VehicleRoutingAlgorithms.TypedMap typedMap = new VehicleRoutingAlgorithms.TypedMap();
|
||||
|
||||
String acceptorName = "acceptor";
|
||||
String acceptorId = "acceptorId";
|
||||
|
||||
ModKey key = new ModKey(acceptorName, acceptorId);
|
||||
AcceptorKey accKey = new AcceptorKey(key);
|
||||
|
||||
SolutionAcceptor acceptor = new GreedyAcceptance(1);
|
||||
|
||||
typedMap.put(accKey, acceptor);
|
||||
|
||||
assertEquals(acceptor, typedMap.get(accKey));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTypedMap2() {
|
||||
VehicleRoutingAlgorithms.TypedMap typedMap = new VehicleRoutingAlgorithms.TypedMap();
|
||||
|
||||
String acceptorName = "acceptor";
|
||||
String acceptorId = "acceptorId";
|
||||
|
||||
String selectorName = "selector";
|
||||
String selectorId = "selectorId";
|
||||
|
||||
ModKey key = new ModKey(acceptorName, acceptorId);
|
||||
AcceptorKey accKey = new AcceptorKey(key);
|
||||
SolutionAcceptor acceptor = new GreedyAcceptance(1);
|
||||
|
||||
SelectorKey selKey = new SelectorKey(new ModKey(selectorName, selectorId));
|
||||
SolutionSelector selector = new SelectBest();
|
||||
|
||||
typedMap.put(accKey, acceptor);
|
||||
typedMap.put(selKey, selector);
|
||||
|
||||
assertEquals(acceptor, typedMap.get(accKey));
|
||||
assertEquals(selector, typedMap.get(selKey));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTypedMap3() {
|
||||
VehicleRoutingAlgorithms.TypedMap typedMap = new VehicleRoutingAlgorithms.TypedMap();
|
||||
|
||||
String acceptorName = "acceptor";
|
||||
String acceptorId = "acceptorId";
|
||||
|
||||
String acceptorName2 = "acceptor2";
|
||||
String acceptorId2 = "acceptorId2";
|
||||
|
||||
String selectorName = "selector";
|
||||
String selectorId = "selectorId";
|
||||
|
||||
ModKey key = new ModKey(acceptorName, acceptorId);
|
||||
AcceptorKey accKey = new AcceptorKey(key);
|
||||
SolutionAcceptor acceptor = new GreedyAcceptance(1);
|
||||
|
||||
SelectorKey selKey = new SelectorKey(new ModKey(selectorName, selectorId));
|
||||
SolutionSelector selector = new SelectBest();
|
||||
|
||||
AcceptorKey accKey2 = new AcceptorKey(new ModKey(acceptorName2, acceptorId2));
|
||||
SolutionAcceptor acceptor2 = new GreedyAcceptance(1);
|
||||
|
||||
typedMap.put(accKey, acceptor);
|
||||
typedMap.put(selKey, selector);
|
||||
typedMap.put(accKey2, acceptor2);
|
||||
|
||||
assertEquals(acceptor, typedMap.get(accKey));
|
||||
assertEquals(selector, typedMap.get(selKey));
|
||||
assertEquals(acceptor2, typedMap.get(accKey2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTypedMap4() {
|
||||
VehicleRoutingAlgorithms.TypedMap typedMap = new VehicleRoutingAlgorithms.TypedMap();
|
||||
|
||||
String acceptorName = "acceptor";
|
||||
String acceptorId = "acceptorId";
|
||||
|
||||
ModKey key = new ModKey(acceptorName, acceptorId);
|
||||
RuinStrategyKey accKey = new RuinStrategyKey(key);
|
||||
RuinStrategy acceptor = new RuinStrategy() {
|
||||
|
||||
@Override
|
||||
public Collection<Job> ruin(Collection<VehicleRoute> vehicleRoutes) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addListener(RuinListener ruinListener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(RuinListener ruinListener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<RuinListener> getListeners() {
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
StrategyModuleKey moduleKey = new StrategyModuleKey(key);
|
||||
SearchStrategyModule stratModule = new SearchStrategyModule() {
|
||||
|
||||
@Override
|
||||
public VehicleRoutingProblemSolution runAndGetSolution(VehicleRoutingProblemSolution vrpSolution) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addModuleListener(
|
||||
SearchStrategyModuleListener moduleListener) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
typedMap.put(accKey, acceptor);
|
||||
typedMap.put(moduleKey, stratModule);
|
||||
typedMap.put(moduleKey, stratModule);
|
||||
|
||||
assertEquals(acceptor, typedMap.get(accKey));
|
||||
assertEquals(stratModule, typedMap.get(moduleKey));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initialiseConstructionAlgoCorrectly() {
|
||||
VehicleRoutingAlgorithms.createAlgorithm(vrp, config);
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreatingAlgorithm_nOfStrategiesIsCorrect() {
|
||||
VehicleRoutingAlgorithm algo = VehicleRoutingAlgorithms.createAlgorithm(vrp, config);
|
||||
assertEquals(3, algo.getSearchStrategyManager().getStrategies().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreatingAlgorithm_nOfIterationsIsReadCorrectly() {
|
||||
VehicleRoutingAlgorithm algo = VehicleRoutingAlgorithms.createAlgorithm(vrp, config);
|
||||
assertEquals(10, algo.getMaxIterations());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCreatingAlgorithm_nOfStrategyModulesIsCorrect() {
|
||||
VehicleRoutingAlgorithm algo = VehicleRoutingAlgorithms.createAlgorithm(vrp, config);
|
||||
int nOfModules = 0;
|
||||
for (SearchStrategy strat : algo.getSearchStrategyManager().getStrategies()) {
|
||||
nOfModules += strat.getSearchStrategyModules().size();
|
||||
}
|
||||
assertEquals(3, nOfModules);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readerTest_whenReadingAlgoWithSchemaValidation_itReadsCorrectly() {
|
||||
AlgorithmConfig algoConfig = new AlgorithmConfig();
|
||||
new AlgorithmConfigXmlReader(algoConfig).read("src/test/resources/algorithmConfig.xml");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readerTest_whenReadingAlgoWithSchemaValidationWithoutIterations_itReadsCorrectly() {
|
||||
AlgorithmConfig algoConfig = new AlgorithmConfig();
|
||||
new AlgorithmConfigXmlReader(algoConfig).read("src/test/resources/algorithmConfig_withoutIterations.xml");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,644 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2014 Stefan Schroeder
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package com.graphhopper.jsprit.core.problem.io;
|
||||
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
||||
import com.graphhopper.jsprit.core.problem.job.Job;
|
||||
import com.graphhopper.jsprit.core.problem.job.Service;
|
||||
import com.graphhopper.jsprit.core.problem.job.Shipment;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.DeliverShipment;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.PickupService;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.PickupShipment;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.TourActivity;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
public class VrpXMLReaderTest {
|
||||
|
||||
private String inFileName;
|
||||
|
||||
@Before
|
||||
public void doBefore() {
|
||||
inFileName = "src/test/resources/finiteVrpForReaderTest.xml";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReadNameOfService() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Service s = (Service) vrp.getJobs().get("1");
|
||||
assertTrue(s.getName().equals("cleaning"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReadNameOfShipment() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Shipment s = (Shipment) vrp.getJobs().get("3");
|
||||
assertTrue(s.getName().equals("deliver-smth"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingVrp_problemTypeIsReadCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(FleetSize.FINITE, vrp.getFleetSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingVrp_vehiclesAreReadCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(5, vrp.getVehicles().size());
|
||||
assertTrue(idsInCollection(Arrays.asList("v1", "v2"), vrp.getVehicles()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingVrp_vehiclesAreReadCorrectly2() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Vehicle v1 = getVehicle("v1", vrp.getVehicles());
|
||||
assertEquals(20, v1.getType().getCapacityDimensions().get(0));
|
||||
assertEquals(100.0, v1.getStartLocation().getCoordinate().getX(), 0.01);
|
||||
assertEquals(0.0, v1.getEarliestDeparture(), 0.01);
|
||||
assertEquals("depotLoc2", v1.getStartLocation().getId());
|
||||
assertNotNull(v1.getType());
|
||||
assertEquals("vehType", v1.getType().getTypeId());
|
||||
assertNotNull(v1.getStartLocation());
|
||||
assertEquals(1, v1.getStartLocation().getIndex());
|
||||
assertEquals(1000.0, v1.getLatestArrival(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingVehicles_skill1ShouldBeAssigned() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Vehicle v1 = getVehicle("v1", vrp.getVehicles());
|
||||
assertTrue(v1.getSkills().containsSkill("skill1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingVehicles_skill2ShouldBeAssigned() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Vehicle v1 = getVehicle("v1", vrp.getVehicles());
|
||||
assertTrue(v1.getSkills().containsSkill("skill2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingVehicles_nuSkillsShouldBeCorrect() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Vehicle v1 = getVehicle("v1", vrp.getVehicles());
|
||||
assertEquals(2, v1.getSkills().values().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingVehicles_nuSkillsOfV2ShouldBeCorrect() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Vehicle v = getVehicle("v2", vrp.getVehicles());
|
||||
assertEquals(0, v.getSkills().values().size());
|
||||
}
|
||||
|
||||
private Vehicle getVehicle(String string, Collection<Vehicle> vehicles) {
|
||||
for (Vehicle v : vehicles) if (string.equals(v.getId())) return v;
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean idsInCollection(List<String> asList, Collection<Vehicle> vehicles) {
|
||||
List<String> ids = new ArrayList<String>(asList);
|
||||
for (Vehicle v : vehicles) {
|
||||
if (ids.contains(v.getId())) ids.remove(v.getId());
|
||||
}
|
||||
return ids.isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingVrp_vehicleTypesAreReadCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(3, vrp.getTypes().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingVrpWithInfiniteSize_itReadsCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(FleetSize.FINITE, vrp.getFleetSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingJobs_nuOfJobsIsReadThemCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(4, vrp.getJobs().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingServices_itReadsThemCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
int servCounter = 0;
|
||||
for (Job j : vrp.getJobs().values()) {
|
||||
if (j instanceof Service) servCounter++;
|
||||
}
|
||||
assertEquals(2, servCounter);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingService1_skill1ShouldBeAssigned() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Service s = (Service) vrp.getJobs().get("1");
|
||||
assertTrue(s.getRequiredSkills().containsSkill("skill1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingService1_skill2ShouldBeAssigned() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Service s = (Service) vrp.getJobs().get("1");
|
||||
assertTrue(s.getRequiredSkills().containsSkill("skill2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingService1_nuSkillsShouldBeCorrect() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Service s = (Service) vrp.getJobs().get("1");
|
||||
assertEquals(2, s.getRequiredSkills().values().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingService2_nuSkillsOfV2ShouldBeCorrect() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Service s = (Service) vrp.getJobs().get("2");
|
||||
assertEquals(0, s.getRequiredSkills().values().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingShipments_itReadsThemCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
int shipCounter = 0;
|
||||
for (Job j : vrp.getJobs().values()) {
|
||||
if (j instanceof Shipment) shipCounter++;
|
||||
}
|
||||
assertEquals(2, shipCounter);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingShipment3_skill1ShouldBeAssigned() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Shipment s = (Shipment) vrp.getJobs().get("3");
|
||||
assertTrue(s.getRequiredSkills().containsSkill("skill1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingShipment3_skill2ShouldBeAssigned() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Shipment s = (Shipment) vrp.getJobs().get("3");
|
||||
assertTrue(s.getRequiredSkills().containsSkill("skill2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingShipment3_nuSkillsShouldBeCorrect() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Shipment s = (Shipment) vrp.getJobs().get("3");
|
||||
assertEquals(2, s.getRequiredSkills().values().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingShipment4_nuSkillsOfV2ShouldBeCorrect() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Shipment s = (Shipment) vrp.getJobs().get("4");
|
||||
assertEquals(0, s.getRequiredSkills().values().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingServices_capOfService1IsReadCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Service s1 = (Service) vrp.getJobs().get("1");
|
||||
assertEquals(1, s1.getSize().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingServices_durationOfService1IsReadCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Service s1 = (Service) vrp.getJobs().get("1");
|
||||
assertEquals(10.0, s1.getServiceDuration(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingServices_twOfService1IsReadCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Service s1 = (Service) vrp.getJobs().get("1");
|
||||
assertEquals(0.0, s1.getTimeWindow().getStart(), 0.01);
|
||||
assertEquals(4000.0, s1.getTimeWindow().getEnd(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingServices_typeOfService1IsReadCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Service s1 = (Service) vrp.getJobs().get("1");
|
||||
assertEquals("service", s1.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingFile_v2MustNotReturnToDepot() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Vehicle v = getVehicle("v2", vrp.getVehicles());
|
||||
assertFalse(v.isReturnToDepot());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingFile_v3HasTheCorrectStartLocation() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Vehicle v3 = getVehicle("v3", vrp.getVehicles());
|
||||
assertEquals("startLoc", v3.getStartLocation().getId());
|
||||
assertNotNull(v3.getEndLocation());
|
||||
assertEquals(4, v3.getEndLocation().getIndex());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingFile_v3HasTheCorrectEndLocation() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Vehicle v3 = getVehicle("v3", vrp.getVehicles());
|
||||
assertEquals("endLoc", v3.getEndLocation().getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingFile_v3HasTheCorrectEndLocationCoordinate() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Vehicle v3 = getVehicle("v3", vrp.getVehicles());
|
||||
assertEquals(1000.0, v3.getEndLocation().getCoordinate().getX(), 0.01);
|
||||
assertEquals(2000.0, v3.getEndLocation().getCoordinate().getY(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingFile_v3HasTheCorrectStartLocationCoordinate() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Vehicle v3 = getVehicle("v3", vrp.getVehicles());
|
||||
assertEquals(10.0, v3.getStartLocation().getCoordinate().getX(), 0.01);
|
||||
assertEquals(100.0, v3.getStartLocation().getCoordinate().getY(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingFile_v3HasTheCorrectLocationCoordinate() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Vehicle v3 = getVehicle("v3", vrp.getVehicles());
|
||||
assertEquals(10.0, v3.getStartLocation().getCoordinate().getX(), 0.01);
|
||||
assertEquals(100.0, v3.getStartLocation().getCoordinate().getY(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingFile_v3HasTheCorrectLocationId() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Vehicle v3 = getVehicle("v3", vrp.getVehicles());
|
||||
assertEquals("startLoc", v3.getStartLocation().getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingFile_v4HasTheCorrectStartLocation() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Vehicle v = getVehicle("v4", vrp.getVehicles());
|
||||
assertEquals("startLoc", v.getStartLocation().getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingFile_v4HasTheCorrectEndLocation() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Vehicle v = getVehicle("v4", vrp.getVehicles());
|
||||
assertEquals("endLoc", v.getEndLocation().getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingFile_v4HasTheCorrectEndLocationCoordinate() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Vehicle v = getVehicle("v4", vrp.getVehicles());
|
||||
assertEquals(1000.0, v.getEndLocation().getCoordinate().getX(), 0.01);
|
||||
assertEquals(2000.0, v.getEndLocation().getCoordinate().getY(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingFile_v4HasTheCorrectStartLocationCoordinate() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Vehicle v = getVehicle("v4", vrp.getVehicles());
|
||||
assertEquals(10.0, v.getStartLocation().getCoordinate().getX(), 0.01);
|
||||
assertEquals(100.0, v.getStartLocation().getCoordinate().getY(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingFile_v4HasTheCorrectLocationCoordinate() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Vehicle v = getVehicle("v4", vrp.getVehicles());
|
||||
assertEquals(10.0, v.getStartLocation().getCoordinate().getX(), 0.01);
|
||||
assertEquals(100.0, v.getStartLocation().getCoordinate().getY(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingFile_v4HasTheCorrectLocationId() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Vehicle v = getVehicle("v4", vrp.getVehicles());
|
||||
assertEquals("startLoc", v.getStartLocation().getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingJobs_capOfShipment3IsReadCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Shipment s = (Shipment) vrp.getJobs().get("3");
|
||||
assertEquals(10, s.getSize().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingJobs_pickupServiceTimeOfShipment3IsReadCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Shipment s = (Shipment) vrp.getJobs().get("3");
|
||||
assertEquals(10.0, s.getPickupServiceTime(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingJobs_pickupTimeWindowOfShipment3IsReadCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Shipment s = (Shipment) vrp.getJobs().get("3");
|
||||
assertEquals(1000.0, s.getPickupTimeWindow().getStart(), 0.01);
|
||||
assertEquals(4000.0, s.getPickupTimeWindow().getEnd(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingJobs_deliveryTimeWindowOfShipment3IsReadCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Shipment s = (Shipment) vrp.getJobs().get("3");
|
||||
assertEquals(6000.0, s.getDeliveryTimeWindow().getStart(), 0.01);
|
||||
assertEquals(10000.0, s.getDeliveryTimeWindow().getEnd(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingJobs_deliveryServiceTimeOfShipment3IsReadCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Shipment s = (Shipment) vrp.getJobs().get("3");
|
||||
assertEquals(100.0, s.getDeliveryServiceTime(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingJobs_deliveryCoordShipment3IsReadCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Shipment s = (Shipment) vrp.getJobs().get("3");
|
||||
assertEquals(10.0, s.getDeliveryLocation().getCoordinate().getX(), 0.01);
|
||||
assertEquals(0.0, s.getDeliveryLocation().getCoordinate().getY(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingJobs_pickupCoordShipment3IsReadCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Shipment s = (Shipment) vrp.getJobs().get("3");
|
||||
assertEquals(10.0, s.getPickupLocation().getCoordinate().getX(), 0.01);
|
||||
assertEquals(10.0, s.getPickupLocation().getCoordinate().getY(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingJobs_deliveryIdShipment3IsReadCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Shipment s = (Shipment) vrp.getJobs().get("3");
|
||||
assertEquals("i(9,9)", s.getDeliveryLocation().getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingJobs_pickupIdShipment3IsReadCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Shipment s = (Shipment) vrp.getJobs().get("3");
|
||||
assertEquals("i(3,9)", s.getPickupLocation().getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingJobs_pickupLocationIdShipment4IsReadCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Shipment s = (Shipment) vrp.getJobs().get("4");
|
||||
assertEquals("[x=10.0][y=10.0]", s.getPickupLocation().getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingJobs_deliveryLocationIdShipment4IsReadCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Shipment s = (Shipment) vrp.getJobs().get("4");
|
||||
assertEquals("[x=10.0][y=0.0]", s.getDeliveryLocation().getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingJobs_pickupServiceTimeOfShipment4IsReadCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Shipment s = (Shipment) vrp.getJobs().get("4");
|
||||
assertEquals(0.0, s.getPickupServiceTime(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingJobs_deliveryServiceTimeOfShipment4IsReadCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Shipment s = (Shipment) vrp.getJobs().get("4");
|
||||
assertEquals(100.0, s.getDeliveryServiceTime(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingFile_v5AndItsTypeHasTheCorrectCapacityDimensionValues() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read(inFileName);
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
Vehicle v = getVehicle("v5", vrp.getVehicles());
|
||||
assertEquals(100, v.getType().getCapacityDimensions().get(0));
|
||||
assertEquals(1000, v.getType().getCapacityDimensions().get(1));
|
||||
assertEquals(10000, v.getType().getCapacityDimensions().get(2));
|
||||
assertEquals(0, v.getType().getCapacityDimensions().get(3));
|
||||
assertEquals(0, v.getType().getCapacityDimensions().get(5));
|
||||
assertEquals(100000, v.getType().getCapacityDimensions().get(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInitialRouteWithShipment4_thisShipmentShouldNotAppearInJobMap() { //since it is not part of the problem anymore
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder).read("src/test/resources/finiteVrpWithInitialSolutionForReaderTest.xml");
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertFalse(vrp.getJobs().containsKey("4"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInitialRouteWithDepTime10_departureTimeOfRouteShouldBeReadCorrectly() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder).read("src/test/resources/finiteVrpWithInitialSolutionForReaderTest.xml");
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(10., vrp.getInitialVehicleRoutes().iterator().next().getDepartureTime(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInitialRoute_nuInitialRoutesShouldBeCorrect() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read("src/test/resources/finiteVrpWithInitialSolutionForReaderTest.xml");
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(1, vrp.getInitialVehicleRoutes().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingInitialRoute_nuActivitiesShouldBeCorrect() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder, null).read("src/test/resources/finiteVrpWithInitialSolutionForReaderTest.xml");
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
assertEquals(2, vrp.getInitialVehicleRoutes().iterator().next().getActivities().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRead_ifReaderIsCalled_itReadsSuccessfullyV2() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
ArrayList<VehicleRoutingProblemSolution> solutions = new ArrayList<VehicleRoutingProblemSolution>();
|
||||
new VrpXMLReader(vrpBuilder, solutions).read("src/test/resources/finiteVrpWithShipmentsAndSolution.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
assertEquals(4, vrp.getJobs().size());
|
||||
assertEquals(1, solutions.size());
|
||||
|
||||
assertEquals(1, solutions.get(0).getRoutes().size());
|
||||
List<TourActivity> activities = solutions.get(0).getRoutes().iterator().next().getTourActivities().getActivities();
|
||||
assertEquals(4, activities.size());
|
||||
assertTrue(activities.get(0) instanceof PickupService);
|
||||
assertTrue(activities.get(1) instanceof PickupService);
|
||||
assertTrue(activities.get(2) instanceof PickupShipment);
|
||||
assertTrue(activities.get(3) instanceof DeliverShipment);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRead_ifReaderIsCalled_itReadsSuccessfully() {
|
||||
new VrpXMLReader(VehicleRoutingProblem.Builder.newInstance(), new ArrayList<VehicleRoutingProblemSolution>()).read("src/test/resources/lui-shen-solution.xml");
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void unassignedJobShouldBeRead() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
ArrayList<VehicleRoutingProblemSolution> solutions = new ArrayList<VehicleRoutingProblemSolution>();
|
||||
new VrpXMLReader(vrpBuilder, solutions).read("src/test/resources/finiteVrpWithShipmentsAndSolution.xml");
|
||||
|
||||
VehicleRoutingProblemSolution solution = Solutions.bestOf(solutions);
|
||||
assertEquals(1, solution.getUnassignedJobs().size());
|
||||
assertEquals("4", solution.getUnassignedJobs().iterator().next().getId());
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void solutionListShouldBeEmpty(){
|
||||
// VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
// ArrayList<VehicleRoutingProblemSolution> solutions = new ArrayList<VehicleRoutingProblemSolution>();
|
||||
// new VrpXMLReader(vrpBuilder, solutions).read("src/test/resources/finiteVrpforReaderTest.xml");
|
||||
// assertTrue(solutions.isEmpty());
|
||||
// }
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -2,7 +2,7 @@
|
|||
<problem xmlns="http://www.w3schools.com"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd">
|
||||
<problemType>
|
||||
<fleetSize>FINITE</fleetSize>
|
||||
<fleetSize>INFINITE</fleetSize>
|
||||
</problemType>
|
||||
<vehicles>
|
||||
<vehicle>
|
||||
|
|
@ -20,21 +20,6 @@
|
|||
</timeSchedule>
|
||||
<returnToDepot>true</returnToDepot>
|
||||
</vehicle>
|
||||
<vehicle>
|
||||
<id>v2</id>
|
||||
<typeId>vehType2</typeId>
|
||||
<startLocation>
|
||||
<id>loc</id>
|
||||
</startLocation>
|
||||
<endLocation>
|
||||
<id>loc</id>
|
||||
</endLocation>
|
||||
<timeSchedule>
|
||||
<start>0.0</start>
|
||||
<end>1.7976931348623157E308</end>
|
||||
</timeSchedule>
|
||||
<returnToDepot>true</returnToDepot>
|
||||
</vehicle>
|
||||
</vehicles>
|
||||
<vehicleTypes>
|
||||
<type>
|
||||
|
|
@ -50,18 +35,58 @@
|
|||
<wait>0.0</wait>
|
||||
</costs>
|
||||
</type>
|
||||
<type>
|
||||
<id>vehType2</id>
|
||||
<capacity-dimensions>
|
||||
<dimension index="0">200</dimension>
|
||||
</capacity-dimensions>
|
||||
<costs>
|
||||
<fixed>0.0</fixed>
|
||||
<distance>1.0</distance>
|
||||
<time>0.0</time>
|
||||
<service>0.0</service>
|
||||
<wait>0.0</wait>
|
||||
</costs>
|
||||
</type>
|
||||
</vehicleTypes>
|
||||
<services>
|
||||
<service id="1" type="service">
|
||||
<location>
|
||||
<id>loc</id>
|
||||
</location>
|
||||
<capacity-dimensions>
|
||||
<dimension index="0">1</dimension>
|
||||
</capacity-dimensions>
|
||||
<duration>2.0</duration>
|
||||
<timeWindows>
|
||||
<timeWindow>
|
||||
<start>0.0</start>
|
||||
<end>1.7976931348623157E308</end>
|
||||
</timeWindow>
|
||||
</timeWindows>
|
||||
</service>
|
||||
<service id="2" type="service">
|
||||
<location>
|
||||
<id>loc2</id>
|
||||
</location>
|
||||
<capacity-dimensions>
|
||||
<dimension index="0">1</dimension>
|
||||
</capacity-dimensions>
|
||||
<duration>4.0</duration>
|
||||
<timeWindows>
|
||||
<timeWindow>
|
||||
<start>0.0</start>
|
||||
<end>1.7976931348623157E308</end>
|
||||
</timeWindow>
|
||||
</timeWindows>
|
||||
</service>
|
||||
</services>
|
||||
<solutions>
|
||||
<solution>
|
||||
<cost>10.0</cost>
|
||||
<routes>
|
||||
<route>
|
||||
<driverId>noDriver</driverId>
|
||||
<vehicleId>v1</vehicleId>
|
||||
<start>0.0</start>
|
||||
<act type="service">
|
||||
<serviceId>1</serviceId>
|
||||
<arrTime>0.0</arrTime>
|
||||
<endTime>0.0</endTime>
|
||||
</act>
|
||||
<end>0.0</end>
|
||||
</route>
|
||||
</routes>
|
||||
<unassignedJobs>
|
||||
<job id="2"/>
|
||||
</unassignedJobs>
|
||||
</solution>
|
||||
</solutions>
|
||||
</problem>
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ package com.graphhopper.jsprit.examples;
|
|||
|
||||
import com.graphhopper.jsprit.analysis.toolbox.Plotter;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateId;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateUpdater;
|
||||
|
|
@ -38,6 +37,7 @@ import com.graphhopper.jsprit.core.util.Coordinate;
|
|||
import com.graphhopper.jsprit.core.util.EuclideanDistanceCalculator;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import com.graphhopper.jsprit.core.util.VehicleRoutingTransportCostsMatrix;
|
||||
import com.graphhopper.jsprit.io.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import com.graphhopper.jsprit.analysis.toolbox.GraphStreamViewer;
|
|||
import com.graphhopper.jsprit.analysis.toolbox.GraphStreamViewer.Label;
|
||||
import com.graphhopper.jsprit.analysis.toolbox.Plotter;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateId;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateUpdater;
|
||||
|
|
@ -51,6 +50,7 @@ import com.graphhopper.jsprit.core.reporting.SolutionPrinter;
|
|||
import com.graphhopper.jsprit.core.util.Coordinate;
|
||||
import com.graphhopper.jsprit.core.util.CrowFlyCosts;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import com.graphhopper.jsprit.io.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import com.graphhopper.jsprit.util.Examples;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ package com.graphhopper.jsprit.examples;
|
|||
|
||||
import com.graphhopper.jsprit.analysis.toolbox.GraphStreamViewer;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateId;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateUpdater;
|
||||
|
|
@ -38,6 +37,7 @@ import com.graphhopper.jsprit.core.problem.solution.route.activity.TourActivity;
|
|||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import com.graphhopper.jsprit.core.reporting.SolutionPrinter;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import com.graphhopper.jsprit.io.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package com.graphhopper.jsprit.examples;
|
|||
|
||||
import com.graphhopper.jsprit.analysis.toolbox.Plotter;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
|
|
@ -35,6 +34,7 @@ import com.graphhopper.jsprit.core.problem.vehicle.VehicleTypeImpl;
|
|||
import com.graphhopper.jsprit.core.reporting.SolutionPrinter;
|
||||
import com.graphhopper.jsprit.core.util.Coordinate;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import com.graphhopper.jsprit.io.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import com.graphhopper.jsprit.util.Examples;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package com.graphhopper.jsprit.examples;
|
|||
import com.graphhopper.jsprit.analysis.toolbox.GraphStreamViewer;
|
||||
import com.graphhopper.jsprit.analysis.toolbox.GraphStreamViewer.Label;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
|
|
@ -33,6 +32,7 @@ import com.graphhopper.jsprit.core.problem.vehicle.VehicleType;
|
|||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
import com.graphhopper.jsprit.core.reporting.SolutionPrinter;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import com.graphhopper.jsprit.io.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package com.graphhopper.jsprit.examples;
|
|||
import com.graphhopper.jsprit.analysis.toolbox.Plotter;
|
||||
import com.graphhopper.jsprit.analysis.toolbox.Plotter.Label;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
|
|
@ -35,6 +34,7 @@ import com.graphhopper.jsprit.core.problem.vehicle.VehicleType;
|
|||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
import com.graphhopper.jsprit.core.reporting.SolutionPrinter;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import com.graphhopper.jsprit.io.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import com.graphhopper.jsprit.util.Examples;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ package com.graphhopper.jsprit.examples;
|
|||
|
||||
import com.graphhopper.jsprit.analysis.toolbox.Plotter;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
|
|
@ -36,6 +35,7 @@ import com.graphhopper.jsprit.core.problem.vehicle.VehicleType;
|
|||
import com.graphhopper.jsprit.core.reporting.SolutionPrinter;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import com.graphhopper.jsprit.instance.reader.SolomonReader;
|
||||
import com.graphhopper.jsprit.io.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import com.graphhopper.jsprit.analysis.toolbox.GraphStreamViewer;
|
|||
import com.graphhopper.jsprit.analysis.toolbox.GraphStreamViewer.Label;
|
||||
import com.graphhopper.jsprit.analysis.toolbox.Plotter;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.algorithm.termination.IterationWithoutImprovementTermination;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
|
|
@ -38,6 +37,7 @@ import com.graphhopper.jsprit.core.problem.vehicle.VehicleTypeImpl;
|
|||
import com.graphhopper.jsprit.core.reporting.SolutionPrinter;
|
||||
import com.graphhopper.jsprit.core.util.Coordinate;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import com.graphhopper.jsprit.io.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import com.graphhopper.jsprit.util.Examples;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package com.graphhopper.jsprit.examples;
|
|||
import com.graphhopper.jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener;
|
||||
import com.graphhopper.jsprit.analysis.toolbox.GraphStreamViewer;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import com.graphhopper.jsprit.core.algorithm.selector.SelectBest;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
|
|
@ -28,6 +27,7 @@ import com.graphhopper.jsprit.core.problem.constraint.ServiceDeliveriesFirstCons
|
|||
import com.graphhopper.jsprit.core.problem.io.VrpXMLReader;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.reporting.SolutionPrinter;
|
||||
import com.graphhopper.jsprit.io.algorithm.VehicleRoutingAlgorithmBuilder;
|
||||
import com.graphhopper.jsprit.util.Examples;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package com.graphhopper.jsprit.core.algorithm.io;
|
||||
package com.graphhopper.jsprit.io.algorithm;
|
||||
|
||||
import org.apache.commons.configuration.XMLConfiguration;
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package com.graphhopper.jsprit.core.algorithm.io;
|
||||
package com.graphhopper.jsprit.io.algorithm;
|
||||
|
||||
import com.graphhopper.jsprit.core.util.Resource;
|
||||
import org.apache.commons.configuration.ConfigurationException;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package com.graphhopper.jsprit.core.algorithm.io;
|
||||
package com.graphhopper.jsprit.io.algorithm;
|
||||
|
||||
import com.graphhopper.jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners;
|
||||
import com.graphhopper.jsprit.core.algorithm.recreate.InsertionBuilder;
|
||||
|
|
@ -14,12 +14,11 @@
|
|||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package com.graphhopper.jsprit.core.algorithm.io;
|
||||
package com.graphhopper.jsprit.io.algorithm;
|
||||
|
||||
|
||||
import com.graphhopper.jsprit.core.algorithm.*;
|
||||
import com.graphhopper.jsprit.core.algorithm.acceptor.*;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap.*;
|
||||
import com.graphhopper.jsprit.core.algorithm.listener.AlgorithmEndsListener;
|
||||
import com.graphhopper.jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners.PrioritizedVRAListener;
|
||||
import com.graphhopper.jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners.Priority;
|
||||
|
|
@ -51,6 +50,7 @@ import com.graphhopper.jsprit.core.problem.solution.route.activity.ReverseActivi
|
|||
import com.graphhopper.jsprit.core.problem.solution.route.activity.TourActivity;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.*;
|
||||
import com.graphhopper.jsprit.core.util.ActivityTimeTracker;
|
||||
import com.graphhopper.jsprit.io.algorithm.VehicleRoutingAlgorithms.TypedMap.*;
|
||||
import org.apache.commons.configuration.HierarchicalConfiguration;
|
||||
import org.apache.commons.configuration.XMLConfiguration;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package com.graphhopper.jsprit.core.problem.io;
|
||||
package com.graphhopper.jsprit.io.problem;
|
||||
|
||||
final class Schema {
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package com.graphhopper.jsprit.core.problem.io;
|
||||
package com.graphhopper.jsprit.io.problem;
|
||||
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package com.graphhopper.jsprit.core.problem.io;
|
||||
package com.graphhopper.jsprit.io.problem;
|
||||
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.Skills;
|
||||
15
pom.xml
15
pom.xml
|
|
@ -40,7 +40,7 @@
|
|||
<developers>
|
||||
<developer>
|
||||
<name>Stefan Schroeder</name>
|
||||
<email>stefan.schroeder@jspr.it</email>
|
||||
<email>stefan.schroeder@graphhopper.com</email>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
|
|
@ -77,6 +77,7 @@
|
|||
<module>jsprit-analysis</module>
|
||||
<module>jsprit-examples</module>
|
||||
<module>jsprit-instances</module>
|
||||
<module>jsprit-io</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
|
@ -87,7 +88,7 @@
|
|||
<hamcrest.version>1.3</hamcrest.version>
|
||||
<logger.version>1.7.21</logger.version>
|
||||
<maven.javadoc.failOnError>false</maven.javadoc.failOnError>
|
||||
|
||||
<maven.version>3.0.4</maven.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
|
|
@ -272,16 +273,6 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${logger.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue