1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

Merge branch 'master' into ruin-share

This commit is contained in:
oblonski 2015-01-06 19:34:10 +01:00
commit 5a049d18c6
23 changed files with 355 additions and 137 deletions

View file

@ -205,7 +205,7 @@ public class VehicleRoutingAlgorithm {
SearchStrategy strategy = searchStrategyManager.getRandomStrategy(); SearchStrategy strategy = searchStrategyManager.getRandomStrategy();
DiscoveredSolution discoveredSolution = strategy.run(problem, solutions); DiscoveredSolution discoveredSolution = strategy.run(problem, solutions);
memorizeIfBestEver(discoveredSolution); memorizeIfBestEver(discoveredSolution);
selectedStrategy(strategy.getName(),problem, solutions); selectedStrategy(strategy.getId(),searchStrategyManager,problem, solutions);
if(terminationManager.isPrematureBreak(discoveredSolution)){ if(terminationManager.isPrematureBreak(discoveredSolution)){
logger.info("premature algorithm termination at iteration "+ (i+1)); logger.info("premature algorithm termination at iteration "+ (i+1));
noIterationsThisAlgoIsRunning = (i+1); noIterationsThisAlgoIsRunning = (i+1);
@ -233,8 +233,8 @@ public class VehicleRoutingAlgorithm {
} }
private void selectedStrategy(String name, VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) { private void selectedStrategy(String name, SearchStrategyManager searchStrategyManager, VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) {
algoListeners.selectedStrategy(name,problem, solutions); algoListeners.selectedStrategy(name, searchStrategyManager, problem, solutions);
} }
/** /**

View file

@ -120,7 +120,7 @@ public class ExperimentalSchrimpfAcceptance implements SolutionAcceptor, Iterati
AlgorithmConfig algorithmConfig = new AlgorithmConfig(); AlgorithmConfig algorithmConfig = new AlgorithmConfig();
new AlgorithmConfigXmlReader(algorithmConfig).read(resource); new AlgorithmConfigXmlReader(algorithmConfig).read(resource);
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.createAlgorithm(problem, algorithmConfig); VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.createAlgorithm(problem, algorithmConfig);
vra.setNuOfIterations(nOfRandomWalks); vra.setMaxIterations(nOfRandomWalks);
vra.getAlgorithmListeners().addListener(new IterationEndsListener() { vra.getAlgorithmListeners().addListener(new IterationEndsListener() {
@Override @Override

View file

@ -18,6 +18,7 @@ package jsprit.core.algorithm.listener;
import java.util.Collection; import java.util.Collection;
import jsprit.core.algorithm.SearchStrategyManager;
import jsprit.core.problem.VehicleRoutingProblem; import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.solution.VehicleRoutingProblemSolution; import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
@ -26,6 +27,6 @@ import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
public interface StrategySelectedListener extends VehicleRoutingAlgorithmListener{ public interface StrategySelectedListener extends VehicleRoutingAlgorithmListener{
void informSelectedStrategy(String strategyName, VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions); void informSelectedStrategy(String strategyId, SearchStrategyManager searchStrategyManager, VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions);
} }

View file

@ -23,6 +23,7 @@ import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.TreeSet; import java.util.TreeSet;
import jsprit.core.algorithm.SearchStrategyManager;
import jsprit.core.algorithm.VehicleRoutingAlgorithm; import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.problem.VehicleRoutingProblem; import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.solution.VehicleRoutingProblemSolution; import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
@ -176,10 +177,10 @@ public class VehicleRoutingAlgorithmListeners {
} }
} }
public void selectedStrategy(String name, VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) { public void selectedStrategy(String name, SearchStrategyManager searchStrategyManager, VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) {
for(PrioritizedVRAListener l : algorithmListeners){ for(PrioritizedVRAListener l : algorithmListeners){
if(l.getListener() instanceof StrategySelectedListener){ if(l.getListener() instanceof StrategySelectedListener){
((StrategySelectedListener)l.getListener()).informSelectedStrategy(name, problem, solutions); ((StrategySelectedListener)l.getListener()).informSelectedStrategy(name, searchStrategyManager, problem, solutions);
} }
} }
} }

View file

@ -58,16 +58,8 @@ public class BuildCVRPAlgoFromScratch_IT {
vrp = builder.build(); vrp = builder.build();
final StateManager stateManager = new StateManager(vrp); final StateManager stateManager = new StateManager(vrp);
stateManager.updateLoadStates();
stateManager.updateTimeWindowStates();
stateManager.addStateUpdater(new UpdateVariableCosts(vrp.getActivityCosts(), vrp.getTransportCosts(), stateManager));
ConstraintManager cManager = new ConstraintManager(vrp, stateManager); ConstraintManager cManager = new ConstraintManager(vrp, stateManager);
cManager.addLoadConstraint();
cManager.addTimeWindowConstraint();
VehicleFleetManager fleetManager = new InfiniteFleetManagerFactory(vrp.getVehicles()).createFleetManager(); VehicleFleetManager fleetManager = new InfiniteFleetManagerFactory(vrp.getVehicles()).createFleetManager();
InsertionStrategy bestInsertion = new BestInsertionBuilder(vrp, fleetManager, stateManager, cManager).build(); InsertionStrategy bestInsertion = new BestInsertionBuilder(vrp, fleetManager, stateManager, cManager).build();
@ -94,19 +86,11 @@ public class BuildCVRPAlgoFromScratch_IT {
SearchStrategy radialStrategy = new SearchStrategy("radial", new SelectBest(), new GreedyAcceptance(1), solutionCostCalculator); SearchStrategy radialStrategy = new SearchStrategy("radial", new SelectBest(), new GreedyAcceptance(1), solutionCostCalculator);
RuinAndRecreateModule radialModule = new RuinAndRecreateModule("radialRuin_bestInsertion", bestInsertion, radial); RuinAndRecreateModule radialModule = new RuinAndRecreateModule("radialRuin_bestInsertion", bestInsertion, radial);
radialStrategy.addModule(radialModule); radialStrategy.addModule(radialModule);
SearchStrategyManager strategyManager = new SearchStrategyManager();
strategyManager.addStrategy(radialStrategy, 0.5);
strategyManager.addStrategy(randomStrategy, 0.5);
vra = new VehicleRoutingAlgorithm(vrp, strategyManager);
vra.addListener(stateManager);
vra.addListener(new RemoveEmptyVehicles(fleetManager));
VehicleRoutingProblemSolution iniSolution = new InsertionInitialSolutionFactory(bestInsertion, solutionCostCalculator).createSolution(vrp);
vra.addInitialSolution(iniSolution); vra = new PrettyAlgorithmBuilder(vrp,fleetManager,stateManager,cManager)
.withStrategy(randomStrategy,0.5).withStrategy(radialStrategy,0.5)
.addCoreStateAndConstraintStuff()
.constructInitialSolutionWith(bestInsertion,solutionCostCalculator).build();
vra.setMaxIterations(2000); vra.setMaxIterations(2000);
} }

View file

@ -37,6 +37,7 @@ import jsprit.core.problem.solution.route.VehicleRoute;
import jsprit.core.problem.vehicle.InfiniteFleetManagerFactory; import jsprit.core.problem.vehicle.InfiniteFleetManagerFactory;
import jsprit.core.problem.vehicle.VehicleFleetManager; import jsprit.core.problem.vehicle.VehicleFleetManager;
import jsprit.core.util.Solutions; import jsprit.core.util.Solutions;
import junit.framework.Assert;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.junit.Before; import org.junit.Before;
@ -63,15 +64,11 @@ public class BuildPDVRPAlgoFromScratch_IT {
final StateManager stateManager = new StateManager(vrp); final StateManager stateManager = new StateManager(vrp);
ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager); ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager);
constraintManager.addTimeWindowConstraint();
constraintManager.addLoadConstraint();
VehicleFleetManager fleetManager = new InfiniteFleetManagerFactory(vrp.getVehicles()).createFleetManager(); VehicleFleetManager fleetManager = new InfiniteFleetManagerFactory(vrp.getVehicles()).createFleetManager();
BestInsertionBuilder iBuilder = new BestInsertionBuilder(vrp, fleetManager, stateManager, constraintManager); InsertionStrategy bestInsertion = new BestInsertionBuilder(vrp, fleetManager, stateManager, constraintManager).build();
// iBuilder.setConstraintManager(constraintManger);
InsertionStrategy bestInsertion = iBuilder.build();
RuinStrategy radial = new RadialRuinStrategyFactory( 0.15, new AvgServiceDistance(vrp.getTransportCosts())).createStrategy(vrp); RuinStrategy radial = new RadialRuinStrategyFactory( 0.15, new AvgServiceDistance(vrp.getTransportCosts())).createStrategy(vrp);
RuinStrategy random = new RandomRuinStrategyFactory(0.25).createStrategy(vrp); RuinStrategy random = new RandomRuinStrategyFactory(0.25).createStrategy(vrp);
@ -96,27 +93,26 @@ public class BuildPDVRPAlgoFromScratch_IT {
SearchStrategy radialStrategy = new SearchStrategy("radial", new SelectBest(), new GreedyAcceptance(1), solutionCostCalculator); SearchStrategy radialStrategy = new SearchStrategy("radial", new SelectBest(), new GreedyAcceptance(1), solutionCostCalculator);
RuinAndRecreateModule radialModule = new RuinAndRecreateModule("radialRuin_bestInsertion", bestInsertion, radial); RuinAndRecreateModule radialModule = new RuinAndRecreateModule("radialRuin_bestInsertion", bestInsertion, radial);
radialStrategy.addModule(radialModule); radialStrategy.addModule(radialModule);
SearchStrategyManager strategyManager = new SearchStrategyManager();
strategyManager.addStrategy(radialStrategy, 0.5);
strategyManager.addStrategy(randomStrategy, 0.5);
vra = new VehicleRoutingAlgorithm(vrp, strategyManager);
vra.addListener(stateManager);
vra.addListener(new RemoveEmptyVehicles(fleetManager));
VehicleRoutingProblemSolution iniSolution = new InsertionInitialSolutionFactory(bestInsertion, solutionCostCalculator).createSolution(vrp);
vra.addInitialSolution(iniSolution); vra = new PrettyAlgorithmBuilder(vrp,fleetManager,stateManager,constraintManager)
vra.setNuOfIterations(1000); .addCoreStateAndConstraintStuff().constructInitialSolutionWith(bestInsertion,solutionCostCalculator)
.withStrategy(radialStrategy,0.5).withStrategy(randomStrategy,0.5).build();
vra.setMaxIterations(1000);
vra.setPrematureAlgorithmTermination(new IterationWithoutImprovementTermination(100)); vra.setPrematureAlgorithmTermination(new IterationWithoutImprovementTermination(100));
} }
@Test @Test
public void test(){ public void test(){
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions(); try {
System.out.println(Solutions.bestOf(solutions).getCost()); Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
System.out.println(Solutions.bestOf(solutions).getCost());
Assert.assertTrue(true);
}
catch (Exception e){
Assert.assertTrue(false);
}
} }
} }

View file

@ -102,7 +102,7 @@ public class BuildPDVRPWithShipmentsAlgoFromScratch_IT {
VehicleRoutingProblemSolution iniSolution = new InsertionInitialSolutionFactory(bestInsertion, solutionCostCalculator).createSolution(vrp); VehicleRoutingProblemSolution iniSolution = new InsertionInitialSolutionFactory(bestInsertion, solutionCostCalculator).createSolution(vrp);
vra.addInitialSolution(iniSolution); vra.addInitialSolution(iniSolution);
vra.setNuOfIterations(3); vra.setMaxIterations(3);
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions(); Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
assertTrue(!solutions.isEmpty()); assertTrue(!solutions.isEmpty());
} }

View file

@ -43,7 +43,7 @@ public class FiniteVehicleFleetManagerIdentifiesDistinctVehicle_IT {
VehicleRoutingProblem vrp = vrpBuilder.build(); VehicleRoutingProblem vrp = vrpBuilder.build();
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp); VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
vra.setNuOfIterations(10); vra.setMaxIterations(10);
try{ try{
@SuppressWarnings("unused") @SuppressWarnings("unused")
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions(); Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();

View file

@ -291,7 +291,7 @@ public class InitialRoutesTest {
.setFleetSize(VehicleRoutingProblem.FleetSize.FINITE).addInitialVehicleRoute(iniRoute).build(); .setFleetSize(VehicleRoutingProblem.FleetSize.FINITE).addInitialVehicleRoute(iniRoute).build();
VehicleRoutingAlgorithm vra = new GreedySchrimpfFactory().createAlgorithm(vrp); VehicleRoutingAlgorithm vra = new GreedySchrimpfFactory().createAlgorithm(vrp);
vra.setNuOfIterations(10); vra.setMaxIterations(10);
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions(); Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
@ -304,7 +304,7 @@ public class InitialRoutesTest {
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem_iniRoutes_2.xml"); new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem_iniRoutes_2.xml");
VehicleRoutingAlgorithm vra = new GreedySchrimpfFactory().createAlgorithm(vrpBuilder.build()); VehicleRoutingAlgorithm vra = new GreedySchrimpfFactory().createAlgorithm(vrpBuilder.build());
vra.setNuOfIterations(10); vra.setMaxIterations(10);
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions(); Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();

View file

@ -48,7 +48,7 @@ public class MeetTimeWindowConstraint_IT {
VehicleRoutingProblem vrp = vrpBuilder.build(); VehicleRoutingProblem vrp = vrpBuilder.build();
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp); VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
vra.setNuOfIterations(100); vra.setMaxIterations(100);
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions(); Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
assertEquals(2,Solutions.bestOf(solutions).getRoutes().size()); assertEquals(2,Solutions.bestOf(solutions).getRoutes().size());
@ -61,7 +61,7 @@ public class MeetTimeWindowConstraint_IT {
VehicleRoutingProblem vrp = vrpBuilder.build(); VehicleRoutingProblem vrp = vrpBuilder.build();
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp); VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
vra.setNuOfIterations(100); vra.setMaxIterations(100);
final List<Boolean> testFailed = new ArrayList<Boolean>(); final List<Boolean> testFailed = new ArrayList<Boolean>();
vra.addListener(new JobInsertedListener() { vra.addListener(new JobInsertedListener() {
@ -93,7 +93,7 @@ public class MeetTimeWindowConstraint_IT {
VehicleRoutingProblem vrp = vrpBuilder.build(); VehicleRoutingProblem vrp = vrpBuilder.build();
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp); VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
vra.setNuOfIterations(100); vra.setMaxIterations(100);
final List<Boolean> testFailed = new ArrayList<Boolean>(); final List<Boolean> testFailed = new ArrayList<Boolean>();
vra.addListener(new VehicleSwitchedListener() { vra.addListener(new VehicleSwitchedListener() {
@ -132,7 +132,7 @@ public class MeetTimeWindowConstraint_IT {
VehicleRoutingProblem vrp = vrpBuilder.build(); VehicleRoutingProblem vrp = vrpBuilder.build();
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp); VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
vra.setNuOfIterations(100); vra.setMaxIterations(100);
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions(); Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
assertEquals(2,Solutions.bestOf(solutions).getRoutes().size()); assertEquals(2,Solutions.bestOf(solutions).getRoutes().size());
@ -145,7 +145,7 @@ public class MeetTimeWindowConstraint_IT {
VehicleRoutingProblem vrp = vrpBuilder.build(); VehicleRoutingProblem vrp = vrpBuilder.build();
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp); VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
vra.setNuOfIterations(100); vra.setMaxIterations(100);
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions(); Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
// assertEquals(2,Solutions.bestOf(solutions).getRoutes().size()); // assertEquals(2,Solutions.bestOf(solutions).getRoutes().size());
@ -159,7 +159,7 @@ public class MeetTimeWindowConstraint_IT {
VehicleRoutingProblem vrp = vrpBuilder.build(); VehicleRoutingProblem vrp = vrpBuilder.build();
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp); VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
vra.setNuOfIterations(100); vra.setMaxIterations(100);
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions(); Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
// assertEquals(2,Solutions.bestOf(solutions).getRoutes().size()); // assertEquals(2,Solutions.bestOf(solutions).getRoutes().size());
@ -176,7 +176,7 @@ public class MeetTimeWindowConstraint_IT {
VehicleRoutingProblem vrp = vrpBuilder.build(); VehicleRoutingProblem vrp = vrpBuilder.build();
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/schrimpf_vehicleSwitchNotAllowed.xml"); VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/schrimpf_vehicleSwitchNotAllowed.xml");
vra.setNuOfIterations(100); vra.setMaxIterations(100);
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions(); Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
assertEquals(2,Solutions.bestOf(solutions).getRoutes().size()); assertEquals(2,Solutions.bestOf(solutions).getRoutes().size());
@ -189,7 +189,7 @@ public class MeetTimeWindowConstraint_IT {
VehicleRoutingProblem vrp = vrpBuilder.build(); VehicleRoutingProblem vrp = vrpBuilder.build();
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/schrimpf_vehicleSwitchNotAllowed.xml"); VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/schrimpf_vehicleSwitchNotAllowed.xml");
vra.setNuOfIterations(100); vra.setMaxIterations(100);
final List<Boolean> testFailed = new ArrayList<Boolean>(); final List<Boolean> testFailed = new ArrayList<Boolean>();
vra.addListener(new JobInsertedListener() { vra.addListener(new JobInsertedListener() {
@ -221,7 +221,7 @@ public class MeetTimeWindowConstraint_IT {
VehicleRoutingProblem vrp = vrpBuilder.build(); VehicleRoutingProblem vrp = vrpBuilder.build();
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/schrimpf_vehicleSwitchNotAllowed.xml"); VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/schrimpf_vehicleSwitchNotAllowed.xml");
vra.setNuOfIterations(100); vra.setMaxIterations(100);
final List<Boolean> testFailed = new ArrayList<Boolean>(); final List<Boolean> testFailed = new ArrayList<Boolean>();
vra.addListener(new VehicleSwitchedListener() { vra.addListener(new VehicleSwitchedListener() {
@ -260,7 +260,7 @@ public class MeetTimeWindowConstraint_IT {
VehicleRoutingProblem vrp = vrpBuilder.build(); VehicleRoutingProblem vrp = vrpBuilder.build();
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/schrimpf_vehicleSwitchNotAllowed.xml"); VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/schrimpf_vehicleSwitchNotAllowed.xml");
vra.setNuOfIterations(100); vra.setMaxIterations(100);
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions(); Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
assertEquals(2,Solutions.bestOf(solutions).getRoutes().size()); assertEquals(2,Solutions.bestOf(solutions).getRoutes().size());
@ -273,7 +273,7 @@ public class MeetTimeWindowConstraint_IT {
VehicleRoutingProblem vrp = vrpBuilder.build(); VehicleRoutingProblem vrp = vrpBuilder.build();
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/schrimpf_vehicleSwitchNotAllowed.xml"); VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/schrimpf_vehicleSwitchNotAllowed.xml");
vra.setNuOfIterations(100); vra.setMaxIterations(100);
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions(); Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
assertEquals(2,Solutions.bestOf(solutions).getRoutes().size()); assertEquals(2,Solutions.bestOf(solutions).getRoutes().size());
@ -287,7 +287,7 @@ public class MeetTimeWindowConstraint_IT {
VehicleRoutingProblem vrp = vrpBuilder.build(); VehicleRoutingProblem vrp = vrpBuilder.build();
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/schrimpf_vehicleSwitchNotAllowed.xml"); VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/schrimpf_vehicleSwitchNotAllowed.xml");
vra.setNuOfIterations(100); vra.setMaxIterations(100);
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions(); Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
assertEquals(2,Solutions.bestOf(solutions).getRoutes().size()); assertEquals(2,Solutions.bestOf(solutions).getRoutes().size());

View file

@ -88,7 +88,7 @@ public class SolomonSkills_IT {
constraintManager.addSkillsConstraint(); constraintManager.addSkillsConstraint();
VehicleRoutingAlgorithm vra = vraBuilder.build(); VehicleRoutingAlgorithm vra = vraBuilder.build();
vra.setNuOfIterations(500); vra.setMaxIterations(500);
try { try {
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions(); Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();

View file

@ -24,7 +24,7 @@ public class Solomon_IT {
VehicleRoutingProblem vrp = vrpBuilder.build(); VehicleRoutingProblem vrp = vrpBuilder.build();
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp,"src/test/resources/algorithmConfig.xml"); VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp,"src/test/resources/algorithmConfig.xml");
vra.setNuOfIterations(500); vra.setMaxIterations(500);
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions(); Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
assertEquals(828.94, Solutions.bestOf(solutions).getCost(),0.01); assertEquals(828.94, Solutions.bestOf(solutions).getCost(),0.01);
} }

View file

@ -2,9 +2,24 @@
<problem xmlns="http://www.w3schools.com" <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"> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd">
<problemType> <problemType>
<fleetSize>INFINITE</fleetSize> <fleetSize>FINITE</fleetSize>
</problemType> </problemType>
<vehicles> <vehicles>
<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>
<vehicle> <vehicle>
<id>v1</id> <id>v1</id>
<typeId>vehType</typeId> <typeId>vehType</typeId>
@ -33,58 +48,16 @@
<time>0.0</time> <time>0.0</time>
</costs> </costs>
</type> </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>
</costs>
</type>
</vehicleTypes> </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> </problem>

View file

@ -46,7 +46,7 @@
</module> </module>
</modules> </modules>
<probability>0.2</probability> <probability>0.4</probability>
</searchStrategy> </searchStrategy>
<searchStrategy name="radialRR"> <searchStrategy name="radialRR">
@ -62,7 +62,7 @@
</module> </module>
</modules> </modules>
<probability>0.2</probability> <probability>0.4</probability>
</searchStrategy> </searchStrategy>
<searchStrategy name="smallRadialRR"> <searchStrategy name="smallRadialRR">
@ -77,7 +77,7 @@
</module> </module>
</modules> </modules>
<probability>0.6</probability> <probability>0.2</probability>
</searchStrategy> </searchStrategy>
</searchStrategies> </searchStrategies>

260
jsprit-examples/input/p11 Normal file
View file

@ -0,0 +1,260 @@
2 6 249 5
310 500
310 500
310 500
310 500
310 500
1 -99 -97 0 6 1 5 1 2 4 8 16
2 -59 50 0 72 1 5 1 2 4 8 16
3 0 14 0 93 1 5 1 2 4 8 16
4 -17 -66 0 28 1 5 1 2 4 8 16
5 -69 -19 0 5 1 5 1 2 4 8 16
6 31 12 0 43 1 5 1 2 4 8 16
7 5 -41 0 1 1 5 1 2 4 8 16
8 -12 10 0 36 1 5 1 2 4 8 16
9 -64 70 0 53 1 5 1 2 4 8 16
10 -12 85 0 63 1 5 1 2 4 8 16
11 -18 64 0 25 1 5 1 2 4 8 16
12 -77 -16 0 50 1 5 1 2 4 8 16
13 -53 88 0 57 1 5 1 2 4 8 16
14 83 -24 0 1 1 5 1 2 4 8 16
15 24 41 0 66 1 5 1 2 4 8 16
16 17 21 0 37 1 5 1 2 4 8 16
17 42 96 0 51 1 5 1 2 4 8 16
18 -65 0 0 47 1 5 1 2 4 8 16
19 -47 -26 0 88 1 5 1 2 4 8 16
20 85 36 0 75 1 5 1 2 4 8 16
21 -35 -54 0 48 1 5 1 2 4 8 16
22 54 -21 0 40 1 5 1 2 4 8 16
23 64 -17 0 8 1 5 1 2 4 8 16
24 55 89 0 69 1 5 1 2 4 8 16
25 17 -25 0 93 1 5 1 2 4 8 16
26 -61 66 0 29 1 5 1 2 4 8 16
27 -61 26 0 5 1 5 1 2 4 8 16
28 17 -72 0 53 1 5 1 2 4 8 16
29 79 38 0 8 1 5 1 2 4 8 16
30 -62 -2 0 24 1 5 1 2 4 8 16
31 -90 -68 0 53 1 5 1 2 4 8 16
32 52 66 0 13 1 5 1 2 4 8 16
33 -54 -50 0 47 1 5 1 2 4 8 16
34 8 -84 0 57 1 5 1 2 4 8 16
35 37 -90 0 9 1 5 1 2 4 8 16
36 -83 49 0 74 1 5 1 2 4 8 16
37 35 -1 0 83 1 5 1 2 4 8 16
38 7 59 0 96 1 5 1 2 4 8 16
39 12 48 0 42 1 5 1 2 4 8 16
40 57 95 0 80 1 5 1 2 4 8 16
41 92 28 0 22 1 5 1 2 4 8 16
42 -3 97 0 56 1 5 1 2 4 8 16
43 -7 52 0 43 1 5 1 2 4 8 16
44 42 -15 0 12 1 5 1 2 4 8 16
45 77 -43 0 73 1 5 1 2 4 8 16
46 59 -49 0 32 1 5 1 2 4 8 16
47 25 91 0 8 1 5 1 2 4 8 16
48 69 -19 0 79 1 5 1 2 4 8 16
49 -82 -14 0 79 1 5 1 2 4 8 16
50 74 -70 0 4 1 5 1 2 4 8 16
51 69 59 0 14 1 5 1 2 4 8 16
52 29 33 0 17 1 5 1 2 4 8 16
53 -97 9 0 19 1 5 1 2 4 8 16
54 -58 9 0 44 1 5 1 2 4 8 16
55 28 93 0 5 1 5 1 2 4 8 16
56 7 73 0 37 1 5 1 2 4 8 16
57 -28 73 0 100 1 5 1 2 4 8 16
58 -76 55 0 62 1 5 1 2 4 8 16
59 41 42 0 90 1 5 1 2 4 8 16
60 92 40 0 57 1 5 1 2 4 8 16
61 -84 -29 0 44 1 5 1 2 4 8 16
62 -12 42 0 37 1 5 1 2 4 8 16
63 51 -45 0 80 1 5 1 2 4 8 16
64 -37 46 0 60 1 5 1 2 4 8 16
65 -97 35 0 95 1 5 1 2 4 8 16
66 14 89 0 56 1 5 1 2 4 8 16
67 60 58 0 56 1 5 1 2 4 8 16
68 -63 -75 0 9 1 5 1 2 4 8 16
69 -18 34 0 39 1 5 1 2 4 8 16
70 -46 -82 0 15 1 5 1 2 4 8 16
71 -86 -79 0 4 1 5 1 2 4 8 16
72 -43 -30 0 58 1 5 1 2 4 8 16
73 -44 7 0 73 1 5 1 2 4 8 16
74 -3 -20 0 5 1 5 1 2 4 8 16
75 36 41 0 12 1 5 1 2 4 8 16
76 -30 -94 0 3 1 5 1 2 4 8 16
77 79 -62 0 8 1 5 1 2 4 8 16
78 51 70 0 31 1 5 1 2 4 8 16
79 -61 -26 0 48 1 5 1 2 4 8 16
80 6 94 0 3 1 5 1 2 4 8 16
81 -19 -62 0 52 1 5 1 2 4 8 16
82 -20 51 0 99 1 5 1 2 4 8 16
83 -81 37 0 29 1 5 1 2 4 8 16
84 7 31 0 12 1 5 1 2 4 8 16
85 52 12 0 50 1 5 1 2 4 8 16
86 83 -91 0 98 1 5 1 2 4 8 16
87 -7 -92 0 4 1 5 1 2 4 8 16
88 82 -74 0 56 1 5 1 2 4 8 16
89 -70 85 0 24 1 5 1 2 4 8 16
90 -83 -30 0 33 1 5 1 2 4 8 16
91 71 -61 0 45 1 5 1 2 4 8 16
92 85 11 0 98 1 5 1 2 4 8 16
93 66 -48 0 4 1 5 1 2 4 8 16
94 78 -87 0 36 1 5 1 2 4 8 16
95 9 -79 0 72 1 5 1 2 4 8 16
96 -36 4 0 26 1 5 1 2 4 8 16
97 66 39 0 71 1 5 1 2 4 8 16
98 92 -17 0 84 1 5 1 2 4 8 16
99 -46 -79 0 21 1 5 1 2 4 8 16
100 -30 -63 0 99 1 5 1 2 4 8 16
101 -42 63 0 33 1 5 1 2 4 8 16
102 20 42 0 84 1 5 1 2 4 8 16
103 15 98 0 74 1 5 1 2 4 8 16
104 1 -17 0 93 1 5 1 2 4 8 16
105 64 20 0 25 1 5 1 2 4 8 16
106 -96 85 0 39 1 5 1 2 4 8 16
107 93 -29 0 42 1 5 1 2 4 8 16
108 -40 -84 0 77 1 5 1 2 4 8 16
109 86 35 0 68 1 5 1 2 4 8 16
110 91 36 0 50 1 5 1 2 4 8 16
111 62 -8 0 42 1 5 1 2 4 8 16
112 -24 4 0 71 1 5 1 2 4 8 16
113 11 96 0 85 1 5 1 2 4 8 16
114 -53 62 0 78 1 5 1 2 4 8 16
115 -28 -71 0 64 1 5 1 2 4 8 16
116 7 -4 0 5 1 5 1 2 4 8 16
117 95 -9 0 93 1 5 1 2 4 8 16
118 -3 17 0 18 1 5 1 2 4 8 16
119 53 -90 0 38 1 5 1 2 4 8 16
120 58 -19 0 29 1 5 1 2 4 8 16
121 -83 84 0 81 1 5 1 2 4 8 16
122 -1 49 0 4 1 5 1 2 4 8 16
123 -4 17 0 23 1 5 1 2 4 8 16
124 -82 -3 0 11 1 5 1 2 4 8 16
125 -43 47 0 86 1 5 1 2 4 8 16
126 6 -6 0 2 1 5 1 2 4 8 16
127 70 99 0 31 1 5 1 2 4 8 16
128 68 -29 0 54 1 5 1 2 4 8 16
129 -94 -30 0 87 1 5 1 2 4 8 16
130 -94 -20 0 17 1 5 1 2 4 8 16
131 -21 77 0 81 1 5 1 2 4 8 16
132 64 37 0 72 1 5 1 2 4 8 16
133 -70 -19 0 10 1 5 1 2 4 8 16
134 88 65 0 50 1 5 1 2 4 8 16
135 2 29 0 25 1 5 1 2 4 8 16
136 33 57 0 71 1 5 1 2 4 8 16
137 -70 6 0 85 1 5 1 2 4 8 16
138 -38 -56 0 51 1 5 1 2 4 8 16
139 -80 -95 0 29 1 5 1 2 4 8 16
140 -5 -39 0 55 1 5 1 2 4 8 16
141 8 -22 0 45 1 5 1 2 4 8 16
142 -61 -76 0 100 1 5 1 2 4 8 16
143 76 -22 0 38 1 5 1 2 4 8 16
144 49 -71 0 11 1 5 1 2 4 8 16
145 -30 -68 0 82 1 5 1 2 4 8 16
146 1 34 0 50 1 5 1 2 4 8 16
147 77 79 0 39 1 5 1 2 4 8 16
148 -58 64 0 6 1 5 1 2 4 8 16
149 82 -97 0 87 1 5 1 2 4 8 16
150 -80 55 0 83 1 5 1 2 4 8 16
151 81 -86 0 22 1 5 1 2 4 8 16
152 39 -49 0 24 1 5 1 2 4 8 16
153 -67 72 0 69 1 5 1 2 4 8 16
154 -25 -89 0 97 1 5 1 2 4 8 16
155 -44 -95 0 65 1 5 1 2 4 8 16
156 32 -68 0 97 1 5 1 2 4 8 16
157 -17 49 0 79 1 5 1 2 4 8 16
158 93 49 0 79 1 5 1 2 4 8 16
159 99 81 0 46 1 5 1 2 4 8 16
160 10 -49 0 52 1 5 1 2 4 8 16
161 63 -41 0 39 1 5 1 2 4 8 16
162 38 39 0 94 1 5 1 2 4 8 16
163 -28 39 0 97 1 5 1 2 4 8 16
164 -2 -47 0 18 1 5 1 2 4 8 16
165 38 8 0 3 1 5 1 2 4 8 16
166 -42 -6 0 23 1 5 1 2 4 8 16
167 -67 88 0 19 1 5 1 2 4 8 16
168 19 93 0 40 1 5 1 2 4 8 16
169 40 27 0 49 1 5 1 2 4 8 16
170 -61 56 0 96 1 5 1 2 4 8 16
171 43 33 0 58 1 5 1 2 4 8 16
172 -18 -39 0 15 1 5 1 2 4 8 16
173 -69 19 0 21 1 5 1 2 4 8 16
174 75 -18 0 56 1 5 1 2 4 8 16
175 31 85 0 67 1 5 1 2 4 8 16
176 25 58 0 10 1 5 1 2 4 8 16
177 -16 36 0 36 1 5 1 2 4 8 16
178 91 15 0 84 1 5 1 2 4 8 16
179 60 -39 0 59 1 5 1 2 4 8 16
180 49 -47 0 85 1 5 1 2 4 8 16
181 42 33 0 60 1 5 1 2 4 8 16
182 16 -81 0 33 1 5 1 2 4 8 16
183 -78 53 0 62 1 5 1 2 4 8 16
184 53 -80 0 70 1 5 1 2 4 8 16
185 -46 -26 0 79 1 5 1 2 4 8 16
186 -25 -54 0 98 1 5 1 2 4 8 16
187 69 -46 0 99 1 5 1 2 4 8 16
188 0 -78 0 18 1 5 1 2 4 8 16
189 -84 74 0 55 1 5 1 2 4 8 16
190 -16 16 0 75 1 5 1 2 4 8 16
191 -63 -14 0 94 1 5 1 2 4 8 16
192 51 -77 0 89 1 5 1 2 4 8 16
193 -39 61 0 13 1 5 1 2 4 8 16
194 5 97 0 19 1 5 1 2 4 8 16
195 -55 39 0 19 1 5 1 2 4 8 16
196 70 -14 0 90 1 5 1 2 4 8 16
197 0 95 0 35 1 5 1 2 4 8 16
198 -45 7 0 76 1 5 1 2 4 8 16
199 38 -24 0 3 1 5 1 2 4 8 16
200 50 -37 0 11 1 5 1 2 4 8 16
201 59 71 0 98 1 5 1 2 4 8 16
202 -73 -96 0 92 1 5 1 2 4 8 16
203 -29 72 0 1 1 5 1 2 4 8 16
204 -47 12 0 2 1 5 1 2 4 8 16
205 -88 -61 0 63 1 5 1 2 4 8 16
206 -88 36 0 57 1 5 1 2 4 8 16
207 -46 -3 0 50 1 5 1 2 4 8 16
208 26 -37 0 19 1 5 1 2 4 8 16
209 -39 -67 0 24 1 5 1 2 4 8 16
210 92 27 0 14 1 5 1 2 4 8 16
211 -80 -31 0 18 1 5 1 2 4 8 16
212 93 -50 0 77 1 5 1 2 4 8 16
213 -20 -5 0 28 1 5 1 2 4 8 16
214 -22 73 0 72 1 5 1 2 4 8 16
215 -4 -7 0 49 1 5 1 2 4 8 16
216 54 -48 0 58 1 5 1 2 4 8 16
217 -70 39 0 84 1 5 1 2 4 8 16
218 54 -82 0 58 1 5 1 2 4 8 16
219 29 41 0 41 1 5 1 2 4 8 16
220 -87 51 0 98 1 5 1 2 4 8 16
221 -96 -36 0 77 1 5 1 2 4 8 16
222 49 8 0 57 1 5 1 2 4 8 16
223 -5 54 0 39 1 5 1 2 4 8 16
224 -26 43 0 99 1 5 1 2 4 8 16
225 -11 60 0 83 1 5 1 2 4 8 16
226 40 61 0 54 1 5 1 2 4 8 16
227 82 35 0 86 1 5 1 2 4 8 16
228 -92 12 0 2 1 5 1 2 4 8 16
229 -93 -86 0 14 1 5 1 2 4 8 16
230 -66 63 0 42 1 5 1 2 4 8 16
231 -72 -87 0 14 1 5 1 2 4 8 16
232 -57 -84 0 55 1 5 1 2 4 8 16
233 23 52 0 2 1 5 1 2 4 8 16
234 -56 -62 0 18 1 5 1 2 4 8 16
235 -19 59 0 17 1 5 1 2 4 8 16
236 63 -14 0 22 1 5 1 2 4 8 16
237 -13 38 0 28 1 5 1 2 4 8 16
238 -19 87 0 3 1 5 1 2 4 8 16
239 44 -84 0 96 1 5 1 2 4 8 16
240 98 -17 0 53 1 5 1 2 4 8 16
241 -16 62 0 15 1 5 1 2 4 8 16
242 3 66 0 36 1 5 1 2 4 8 16
243 26 22 0 98 1 5 1 2 4 8 16
244 -38 -81 0 78 1 5 1 2 4 8 16
245 70 -80 0 92 1 5 1 2 4 8 16
246 17 -35 0 65 1 5 1 2 4 8 16
247 96 -83 0 64 1 5 1 2 4 8 16
248 -77 80 0 43 1 5 1 2 4 8 16
249 -14 44 0 50 1 5 1 2 4 8 16
250 70 0 0 0 0 0
251 40 80 0 0 0 0
252 40 -80 0 0 0 0
253 -60 20 0 0 0 0
254 -60 -20 0 0 0 0

View file

@ -158,7 +158,7 @@ public class AdditionalDistanceConstraintExample {
vraBuilder.setStateAndConstraintManager(stateManager,constraintManager); vraBuilder.setStateAndConstraintManager(stateManager,constraintManager);
VehicleRoutingAlgorithm vra = vraBuilder.build(); VehicleRoutingAlgorithm vra = vraBuilder.build();
// vra.setNuOfIterations(250); //v1.3.1 // vra.setMaxIterations(250); //v1.3.1
vra.setMaxIterations(250); //head of development - upcoming release (v1.4) vra.setMaxIterations(250); //head of development - upcoming release (v1.4)
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions(); Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();

View file

@ -265,12 +265,13 @@ public class BicycleMessenger {
constraintManager.addConstraint(new IgnoreMessengerThatCanNeverMeetTimeRequirements(nearestMessengers, routingCosts)); constraintManager.addConstraint(new IgnoreMessengerThatCanNeverMeetTimeRequirements(nearestMessengers, routingCosts));
//create your algorithm //create your algorithm
VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(bicycleMessengerProblem,"input/algorithmConfig_open.xml"); VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(bicycleMessengerProblem,"input/algorithmConfig.xml");
// vraBuilder.setNuOfThreads(2); // vraBuilder.setNuOfThreads(2);
vraBuilder.addDefaultCostCalculators(); vraBuilder.addDefaultCostCalculators();
vraBuilder.setStateAndConstraintManager(stateManager, constraintManager); vraBuilder.setStateAndConstraintManager(stateManager, constraintManager);
vraBuilder.setNuOfThreads(10);
VehicleRoutingAlgorithm algorithm = vraBuilder.build(); VehicleRoutingAlgorithm algorithm = vraBuilder.build();
algorithm.setMaxIterations(5000); algorithm.setMaxIterations(10000);
// VariationCoefficientTermination prematureAlgorithmTermination = new VariationCoefficientTermination(200, 0.001); // VariationCoefficientTermination prematureAlgorithmTermination = new VariationCoefficientTermination(200, 0.001);
// algorithm.setPrematureAlgorithmTermination(prematureAlgorithmTermination); // algorithm.setPrematureAlgorithmTermination(prematureAlgorithmTermination);
// algorithm.addListener(prematureAlgorithmTermination); // algorithm.addListener(prematureAlgorithmTermination);

View file

@ -23,6 +23,7 @@ import jsprit.analysis.toolbox.GraphStreamViewer;
import jsprit.analysis.toolbox.Plotter; import jsprit.analysis.toolbox.Plotter;
import jsprit.core.algorithm.VehicleRoutingAlgorithm; import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.box.GreedySchrimpfFactory; import jsprit.core.algorithm.box.GreedySchrimpfFactory;
import jsprit.core.problem.Location;
import jsprit.core.problem.VehicleRoutingProblem; import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.job.Service; import jsprit.core.problem.job.Service;
import jsprit.core.problem.solution.VehicleRoutingProblemSolution; import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
@ -59,14 +60,15 @@ public class CircleExample {
} }
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
VehicleImpl v = VehicleImpl.Builder.newInstance("v").setStartLocationCoordinate(Coordinate.newInstance(0,0)).build(); VehicleImpl v = VehicleImpl.Builder.newInstance("v")
.setStartLocation(Location.Builder.newInstance().setCoordinate(Coordinate.newInstance(0, 0)).build()).build();
vrpBuilder.addVehicle(v); vrpBuilder.addVehicle(v);
double step = 2*Math.PI/50.; double step = 2*Math.PI/50.;
Collection<Coordinate> circle = createCoordinates(0,0,20,step); Collection<Coordinate> circle = createCoordinates(0,0,20,step);
int id = 1; int id = 1;
for(Coordinate c : circle){ for(Coordinate c : circle){
Service s = Service.Builder.newInstance(Integer.toString(id)).setCoord(c).build(); Service s = Service.Builder.newInstance(Integer.toString(id)).setLocation(Location.Builder.newInstance().setCoordinate(c).build()).build();
vrpBuilder.addJob(s); vrpBuilder.addJob(s);
id++; id++;
} }

View file

@ -124,7 +124,7 @@ public class EnRoutePickupAndDeliveryWithMultipleDepotsAndOpenRoutesExample {
* get the algorithm out-of-the-box. * get the algorithm out-of-the-box.
*/ */
VehicleRoutingAlgorithm algorithm = VehicleRoutingAlgorithms.readAndCreateAlgorithm(problem, "input/algorithmConfig.xml"); VehicleRoutingAlgorithm algorithm = VehicleRoutingAlgorithms.readAndCreateAlgorithm(problem, "input/algorithmConfig.xml");
// algorithm.setNuOfIterations(30000); // algorithm.setMaxIterations(30000);
/* /*
* and search a solution * and search a solution
*/ */

View file

@ -171,7 +171,7 @@ public class EnRoutePickupAndDeliveryWithMultipleDepotsAndVehicleAccessConstrain
VehicleRoutingAlgorithm algorithm = vraBuilder.build(); VehicleRoutingAlgorithm algorithm = vraBuilder.build();
algorithm.setPrematureAlgorithmTermination(new IterationWithoutImprovementTermination(100)); algorithm.setPrematureAlgorithmTermination(new IterationWithoutImprovementTermination(100));
// algorithm.setNuOfIterations(30000); // algorithm.setMaxIterations(30000);
/* /*
* and search a solution * and search a solution
*/ */

View file

@ -197,7 +197,7 @@ public class MultipleProductsWithLoadConstraintExample {
vraBuilder.setStateAndConstraintManager(stateManager,constraintManager); vraBuilder.setStateAndConstraintManager(stateManager,constraintManager);
VehicleRoutingAlgorithm vra = vraBuilder.build(); VehicleRoutingAlgorithm vra = vraBuilder.build();
// vra.setNuOfIterations(100); //1.3.2-SNAPSHOT // vra.setMaxIterations(100); //1.3.2-SNAPSHOT
// vra.setMaxIterations(100); // vra.setMaxIterations(100);
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions(); Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();

View file

@ -91,7 +91,7 @@ public class SolomonWithSkillsExample {
constraintManager.addSkillsConstraint(); constraintManager.addSkillsConstraint();
VehicleRoutingAlgorithm vra = vraBuilder.build(); VehicleRoutingAlgorithm vra = vraBuilder.build();
// vra.setNuOfIterations(500); // vra.setMaxIterations(500);
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions(); Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();

View file

@ -339,7 +339,7 @@ package jsprit.instance.reader;
// bestInsertion); // bestInsertion);
// postOpt.setFleetManager(vehicleFleetManager); // postOpt.setFleetManager(vehicleFleetManager);
// postOpt.setVehicleRouteFactory(new VehicleRouteFactoryImpl(depotId)); // postOpt.setVehicleRouteFactory(new VehicleRouteFactoryImpl(depotId));
// postOpt.setNuOfIterations(2000); // postOpt.setMaxIterations(2000);
// postOpt.setShareOfJobsToRuin(0.18); // postOpt.setShareOfJobsToRuin(0.18);
//// smallNeighborHoodSearch.addModule(postOpt); //// smallNeighborHoodSearch.addModule(postOpt);
// //
@ -350,7 +350,7 @@ package jsprit.instance.reader;
//// bestInsertion); //// bestInsertion);
//// postOpt2.setFleetManager(vehicleFleetManager); //// postOpt2.setFleetManager(vehicleFleetManager);
//// postOpt2.setVehicleRouteFactory(new VehicleRouteFactoryImpl(depotId)); //// postOpt2.setVehicleRouteFactory(new VehicleRouteFactoryImpl(depotId));
//// postOpt2.setNuOfIterations(2000); //// postOpt2.setMaxIterations(2000);
//// postOpt2.setShareOfJobsToRuin(0.1); //// postOpt2.setShareOfJobsToRuin(0.1);
//// strat2.addModule(postOpt2); //// strat2.addModule(postOpt2);
// //
@ -370,7 +370,7 @@ package jsprit.instance.reader;
//// strategyManager.addStrategy(strat2, 0.3); //// strategyManager.addStrategy(strat2, 0.3);
// //
// metaAlgorithm.setSearchStrategyManager(strategyManager); // metaAlgorithm.setSearchStrategyManager(strategyManager);
// metaAlgorithm.setNuOfIterations(20); // metaAlgorithm.setMaxIterations(20);
// VehicleRoutingProblem.SOLUTION_MEMORY = 4; // VehicleRoutingProblem.SOLUTION_MEMORY = 4;
// //
// //