mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
get rid of xmlReader
This commit is contained in:
parent
2d0274b441
commit
c7a5727b0e
62 changed files with 1796 additions and 1681 deletions
|
|
@ -51,6 +51,9 @@ public class GreedySchrimpfFactory {
|
|||
}
|
||||
|
||||
public Jsprit.Builder createGreedyAlgorithmBuilder(VehicleRoutingProblem vrp) {
|
||||
int radialShare = (int) (vrp.getJobs().size() * 0.3);
|
||||
int randomShare = (int) (vrp.getJobs().size() * 0.5);
|
||||
|
||||
Jsprit.Builder builder = Jsprit.Builder.newInstance(vrp);
|
||||
builder.setProperty(Jsprit.Parameter.THRESHOLD_ALPHA,"0.0");
|
||||
builder.setProperty(Jsprit.Strategy.RADIAL_BEST, "0.5");
|
||||
|
|
@ -61,10 +64,10 @@ public class GreedySchrimpfFactory {
|
|||
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));
|
||||
builder.setProperty(Jsprit.Parameter.RADIAL_MIN_SHARE, String.valueOf(radialShare));
|
||||
builder.setProperty(Jsprit.Parameter.RADIAL_MAX_SHARE, String.valueOf(radialShare));
|
||||
builder.setProperty(Jsprit.Parameter.RANDOM_BEST_MIN_SHARE, String.valueOf(randomShare));
|
||||
builder.setProperty(Jsprit.Parameter.RANDOM_BEST_MAX_SHARE, String.valueOf(randomShare));
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ public class SchrimpfFactory {
|
|||
public VehicleRoutingAlgorithm createAlgorithm(VehicleRoutingProblem vrp) {
|
||||
//TODO determine alpha threshold
|
||||
|
||||
int radialShare = (int) (vrp.getJobs().size() * 0.3);
|
||||
int randomShare = (int) (vrp.getJobs().size() * 0.5);
|
||||
Jsprit.Builder builder = Jsprit.Builder.newInstance(vrp);
|
||||
builder.setProperty(Jsprit.Parameter.THRESHOLD_ALPHA,"0.0");
|
||||
builder.setProperty(Jsprit.Strategy.RADIAL_BEST, "0.5");
|
||||
|
|
@ -59,10 +61,10 @@ public class SchrimpfFactory {
|
|||
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));
|
||||
builder.setProperty(Jsprit.Parameter.RADIAL_MIN_SHARE, String.valueOf(radialShare));
|
||||
builder.setProperty(Jsprit.Parameter.RADIAL_MAX_SHARE, String.valueOf(radialShare));
|
||||
builder.setProperty(Jsprit.Parameter.RANDOM_BEST_MIN_SHARE, String.valueOf(randomShare));
|
||||
builder.setProperty(Jsprit.Parameter.RANDOM_BEST_MAX_SHARE, String.valueOf(randomShare));
|
||||
return builder.buildAlgorithm();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,12 +30,12 @@ import com.graphhopper.jsprit.core.algorithm.state.InternalStates;
|
|||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.constraint.ConstraintManager;
|
||||
import com.graphhopper.jsprit.core.problem.io.VrpXMLReader;
|
||||
import com.graphhopper.jsprit.core.problem.solution.SolutionCostCalculator;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.InfiniteFleetManagerFactory;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleFleetManager;
|
||||
import com.graphhopper.jsprit.core.util.ChristofidesReader;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
|
@ -55,7 +55,7 @@ public class BuildCVRPAlgoFromScratch_IT {
|
|||
@Before
|
||||
public void setup() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder).read("src/test/resources/vrpnc1-jsprit.xml");
|
||||
new ChristofidesReader(builder).read(getClass().getResourceAsStream("vrpnc1.txt"));
|
||||
vrp = builder.build();
|
||||
|
||||
final StateManager stateManager = new StateManager(vrp);
|
||||
|
|
|
|||
|
|
@ -1,118 +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.IntegrationTest;
|
||||
import com.graphhopper.jsprit.core.algorithm.acceptor.GreedyAcceptance;
|
||||
import com.graphhopper.jsprit.core.algorithm.module.RuinAndRecreateModule;
|
||||
import com.graphhopper.jsprit.core.algorithm.recreate.BestInsertionBuilder;
|
||||
import com.graphhopper.jsprit.core.algorithm.recreate.InsertionStrategy;
|
||||
import com.graphhopper.jsprit.core.algorithm.ruin.RadialRuinStrategyFactory;
|
||||
import com.graphhopper.jsprit.core.algorithm.ruin.RandomRuinStrategyFactory;
|
||||
import com.graphhopper.jsprit.core.algorithm.ruin.RuinStrategy;
|
||||
import com.graphhopper.jsprit.core.algorithm.ruin.distance.AvgServiceDistance;
|
||||
import com.graphhopper.jsprit.core.algorithm.selector.SelectBest;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.InternalStates;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.algorithm.termination.IterationWithoutImprovementTermination;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.constraint.ConstraintManager;
|
||||
import com.graphhopper.jsprit.core.problem.io.VrpXMLReader;
|
||||
import com.graphhopper.jsprit.core.problem.solution.SolutionCostCalculator;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.InfiniteFleetManagerFactory;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleFleetManager;
|
||||
import junit.framework.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
public class BuildPDVRPAlgoFromScratch_IT {
|
||||
|
||||
VehicleRoutingProblem vrp;
|
||||
|
||||
VehicleRoutingAlgorithm vra;
|
||||
|
||||
static Logger log = LoggerFactory.getLogger(BuildPDVRPAlgoFromScratch_IT.class);
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder).read("src/test/resources/pd_solomon_r101.xml");
|
||||
vrp = builder.build();
|
||||
|
||||
final StateManager stateManager = new StateManager(vrp);
|
||||
|
||||
ConstraintManager constraintManager = new ConstraintManager(vrp, stateManager);
|
||||
|
||||
VehicleFleetManager fleetManager = new InfiniteFleetManagerFactory(vrp.getVehicles()).createFleetManager();
|
||||
|
||||
InsertionStrategy bestInsertion = new BestInsertionBuilder(vrp, fleetManager, stateManager, constraintManager).build();
|
||||
|
||||
RuinStrategy radial = new RadialRuinStrategyFactory(0.15, new AvgServiceDistance(vrp.getTransportCosts())).createStrategy(vrp);
|
||||
RuinStrategy random = new RandomRuinStrategyFactory(0.25).createStrategy(vrp);
|
||||
|
||||
SolutionCostCalculator solutionCostCalculator = new SolutionCostCalculator() {
|
||||
|
||||
@Override
|
||||
public double getCosts(VehicleRoutingProblemSolution solution) {
|
||||
double costs = 0.0;
|
||||
for (VehicleRoute route : solution.getRoutes()) {
|
||||
Double cost_of_route = stateManager.getRouteState(route, InternalStates.COSTS, Double.class);
|
||||
if (cost_of_route == null) cost_of_route = 0.;
|
||||
costs += cost_of_route;
|
||||
}
|
||||
return costs;
|
||||
}
|
||||
};
|
||||
|
||||
SearchStrategy randomStrategy = new SearchStrategy("random", new SelectBest(), new GreedyAcceptance(1), solutionCostCalculator);
|
||||
RuinAndRecreateModule randomModule = new RuinAndRecreateModule("randomRuin_bestInsertion", bestInsertion, random);
|
||||
randomStrategy.addModule(randomModule);
|
||||
|
||||
SearchStrategy radialStrategy = new SearchStrategy("radial", new SelectBest(), new GreedyAcceptance(1), solutionCostCalculator);
|
||||
RuinAndRecreateModule radialModule = new RuinAndRecreateModule("radialRuin_bestInsertion", bestInsertion, radial);
|
||||
radialStrategy.addModule(radialModule);
|
||||
|
||||
vra = new PrettyAlgorithmBuilder(vrp, fleetManager, stateManager, constraintManager)
|
||||
.addCoreStateAndConstraintStuff().constructInitialSolutionWith(bestInsertion, solutionCostCalculator)
|
||||
.withStrategy(radialStrategy, 0.5).withStrategy(randomStrategy, 0.5).build();
|
||||
|
||||
vra.setMaxIterations(1000);
|
||||
vra.setPrematureAlgorithmTermination(new IterationWithoutImprovementTermination(100));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Category(IntegrationTest.class)
|
||||
public void test() {
|
||||
try {
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
Assert.assertTrue(true);
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,114 +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.IntegrationTest;
|
||||
import com.graphhopper.jsprit.core.algorithm.acceptor.GreedyAcceptance;
|
||||
import com.graphhopper.jsprit.core.algorithm.module.RuinAndRecreateModule;
|
||||
import com.graphhopper.jsprit.core.algorithm.recreate.BestInsertionBuilder;
|
||||
import com.graphhopper.jsprit.core.algorithm.recreate.InsertionStrategy;
|
||||
import com.graphhopper.jsprit.core.algorithm.ruin.RadialRuinStrategyFactory;
|
||||
import com.graphhopper.jsprit.core.algorithm.ruin.RandomRuinStrategyFactory;
|
||||
import com.graphhopper.jsprit.core.algorithm.ruin.RuinStrategy;
|
||||
import com.graphhopper.jsprit.core.algorithm.ruin.distance.AvgServiceAndShipmentDistance;
|
||||
import com.graphhopper.jsprit.core.algorithm.selector.SelectBest;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.InternalStates;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.UpdateVariableCosts;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.constraint.ConstraintManager;
|
||||
import com.graphhopper.jsprit.core.problem.io.VrpXMLReader;
|
||||
import com.graphhopper.jsprit.core.problem.solution.SolutionCostCalculator;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.InfiniteFleetManagerFactory;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleFleetManager;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
||||
public class BuildPDVRPWithShipmentsAlgoFromScratch_IT {
|
||||
|
||||
@Test
|
||||
@Category(IntegrationTest.class)
|
||||
public void test() {
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder).read("src/test/resources/pdp.xml");
|
||||
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
|
||||
final StateManager stateManager = new StateManager(vrp);
|
||||
stateManager.updateLoadStates();
|
||||
// stateManager.updateTimeWindowStates();
|
||||
stateManager.addStateUpdater(new UpdateVariableCosts(vrp.getActivityCosts(), vrp.getTransportCosts(), stateManager));
|
||||
|
||||
ConstraintManager constraintManager = new ConstraintManager(vrp, stateManager);
|
||||
// constraintManager.addTimeWindowConstraint();
|
||||
constraintManager.addLoadConstraint();
|
||||
|
||||
VehicleFleetManager fleetManager = new InfiniteFleetManagerFactory(vrp.getVehicles()).createFleetManager();
|
||||
|
||||
BestInsertionBuilder bestIBuilder = new BestInsertionBuilder(vrp, fleetManager, stateManager, constraintManager);
|
||||
InsertionStrategy bestInsertion = bestIBuilder.build();
|
||||
|
||||
|
||||
RuinStrategy radial = new RadialRuinStrategyFactory(0.3, new AvgServiceAndShipmentDistance(vrp.getTransportCosts())).createStrategy(vrp);
|
||||
RuinStrategy random = new RandomRuinStrategyFactory(0.5).createStrategy(vrp);
|
||||
|
||||
|
||||
SolutionCostCalculator solutionCostCalculator = new SolutionCostCalculator() {
|
||||
|
||||
@Override
|
||||
public double getCosts(VehicleRoutingProblemSolution solution) {
|
||||
double costs = 0.0;
|
||||
for (VehicleRoute route : solution.getRoutes()) {
|
||||
costs += stateManager.getRouteState(route, InternalStates.COSTS, Double.class);
|
||||
}
|
||||
return costs;
|
||||
}
|
||||
};
|
||||
|
||||
SearchStrategy randomStrategy = new SearchStrategy("random", new SelectBest(), new GreedyAcceptance(1), solutionCostCalculator);
|
||||
RuinAndRecreateModule randomModule = new RuinAndRecreateModule("randomRuin_bestInsertion", bestInsertion, random);
|
||||
randomStrategy.addModule(randomModule);
|
||||
|
||||
SearchStrategy radialStrategy = new SearchStrategy("radial", new SelectBest(), new GreedyAcceptance(1), solutionCostCalculator);
|
||||
RuinAndRecreateModule radialModule = new RuinAndRecreateModule("radialRuin_bestInsertion", bestInsertion, radial);
|
||||
radialStrategy.addModule(radialModule);
|
||||
|
||||
SearchStrategyManager strategyManager = new SearchStrategyManager();
|
||||
strategyManager.addStrategy(radialStrategy, 0.5);
|
||||
strategyManager.addStrategy(randomStrategy, 0.5);
|
||||
|
||||
VehicleRoutingAlgorithm 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.setMaxIterations(3);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
assertTrue(!solutions.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,64 +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.IntegrationTest;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.io.VrpXMLReader;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import junit.framework.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class CVRPwithDeliveriesAndDifferentInsertionStrategies_IT {
|
||||
|
||||
@Test
|
||||
@Category(IntegrationTest.class)
|
||||
public void whenWithTwoInsertionStrategiesWhereOnleOneIsInAlgo_itShouldWork() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfig_greedyWithRegret.xml");
|
||||
vra.setMaxIterations(10);
|
||||
try {
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
Assert.assertTrue(true);
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Category(IntegrationTest.class)
|
||||
public void whenWithTwoInsertionStrategiesWhereBothAreInAlgo_itShouldWork() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfig_greedyWithRegret_v2.xml");
|
||||
vra.setMaxIterations(10);
|
||||
try {
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
Assert.assertTrue(true);
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -18,10 +18,10 @@ package com.graphhopper.jsprit.core.algorithm;
|
|||
|
||||
import com.graphhopper.jsprit.core.IntegrationTest;
|
||||
import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.io.VrpXMLReader;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.util.ChristofidesReader;
|
||||
import com.graphhopper.jsprit.core.util.JobType;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
|
@ -32,23 +32,11 @@ import static org.junit.Assert.assertEquals;
|
|||
|
||||
public class CVRPwithDeliveries_IT {
|
||||
|
||||
@Test
|
||||
@Category(IntegrationTest.class)
|
||||
public void whenSolvingVRPNC1withDeliveries_solutionsMustNoBeWorseThan5PercentOfBestKnownSolution() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfig.xml");
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
assertEquals(530.0, Solutions.bestOf(solutions).getCost(), 50.0);
|
||||
assertEquals(5, Solutions.bestOf(solutions).getRoutes().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Category(IntegrationTest.class)
|
||||
public void whenSolvingVRPNC1withDeliveriesWithJsprit_solutionsMustNoBeWorseThan5PercentOfBestKnownSolution() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml");
|
||||
new ChristofidesReader(vrpBuilder).setJobType(JobType.DELIVERY).read(getClass().getResourceAsStream("vrpnc1.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
|
|
|||
|
|
@ -17,20 +17,17 @@
|
|||
package com.graphhopper.jsprit.core.algorithm;
|
||||
|
||||
import com.graphhopper.jsprit.core.IntegrationTest;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||
import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
||||
import com.graphhopper.jsprit.core.analysis.SolutionAnalyser;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.cost.TransportDistance;
|
||||
import com.graphhopper.jsprit.core.problem.io.VrpXMLReader;
|
||||
import com.graphhopper.jsprit.core.problem.job.Job;
|
||||
import com.graphhopper.jsprit.core.problem.job.Service;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import com.graphhopper.jsprit.core.util.EuclideanDistanceCalculator;
|
||||
import com.graphhopper.jsprit.core.util.FastVehicleRoutingTransportCostsMatrix;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import com.graphhopper.jsprit.core.util.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
|
@ -50,10 +47,10 @@ public class CVRPwithMatrix_IT {
|
|||
@Category(IntegrationTest.class)
|
||||
public void whenReturnToDepot_itShouldWorkWithMatrix() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml");
|
||||
new ChristofidesReader(vrpBuilder).setJobType(JobType.DELIVERY).read(getClass().getResourceAsStream("vrpnc1.txt"));
|
||||
VehicleRoutingProblem vrp_ = vrpBuilder.build();
|
||||
VehicleRoutingProblem vrp = createVrpWithLocationIndecesAndMatrix(vrp_, true);
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfig.xml");
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.FAST_REGRET,"true").buildAlgorithm();
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
Assert.assertEquals(530.0, Solutions.bestOf(solutions).getCost(), 50.0);
|
||||
assertEquals(5, Solutions.bestOf(solutions).getRoutes().size());
|
||||
|
|
@ -63,10 +60,10 @@ public class CVRPwithMatrix_IT {
|
|||
@Category(IntegrationTest.class)
|
||||
public void whenNotReturnToDepot_itShouldWorkWithMatrix() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml");
|
||||
new ChristofidesReader(vrpBuilder).setJobType(JobType.DELIVERY).read(getClass().getResourceAsStream("vrpnc1.txt"));
|
||||
VehicleRoutingProblem vrp_ = vrpBuilder.build();
|
||||
VehicleRoutingProblem vrp = createVrpWithLocationIndecesAndMatrix(vrp_, false);
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfig.xml");
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.FAST_REGRET,"true").buildAlgorithm();
|
||||
try {
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
assertTrue(true);
|
||||
|
|
@ -79,10 +76,10 @@ public class CVRPwithMatrix_IT {
|
|||
@Category(IntegrationTest.class)
|
||||
public void whenCalcTimeWithSolutionAnalyser_itShouldWork() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-deliveries.xml");
|
||||
new ChristofidesReader(vrpBuilder).setJobType(JobType.DELIVERY).read(getClass().getResourceAsStream("vrpnc1.txt"));
|
||||
VehicleRoutingProblem vrp_ = vrpBuilder.build();
|
||||
final VehicleRoutingProblem vrp = createVrpWithLocationIndecesAndMatrix(vrp_, false);
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfig.xml");
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.FAST_REGRET,"true").buildAlgorithm();
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
SolutionAnalyser sa = new SolutionAnalyser(vrp, Solutions.bestOf(solutions), new TransportDistance() {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@ package com.graphhopper.jsprit.core.algorithm;
|
|||
|
||||
import com.graphhopper.jsprit.core.IntegrationTest;
|
||||
import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.io.VrpXMLReader;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.util.ChristofidesReader;
|
||||
import com.graphhopper.jsprit.core.util.JobType;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
|
@ -36,22 +36,9 @@ public class CVRPwithPickups_IT {
|
|||
@Category(IntegrationTest.class)
|
||||
public void whenSolvingVRPNC1WithPickups_solutionsMustNoBeWorseThan5PercentOfBestKnownSolution() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-pickups.xml");
|
||||
new ChristofidesReader(vrpBuilder).setJobType(JobType.PICKUP).read(getClass().getResourceAsStream("vrpnc1.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfig.xml");
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
assertEquals(530.0, Solutions.bestOf(solutions).getCost(), 50.0);
|
||||
assertEquals(5, Solutions.bestOf(solutions).getRoutes().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Category(IntegrationTest.class)
|
||||
public void whenSolvingVRPNC1WithPickupsWithJsprit_solutionsMustNoBeWorseThan5PercentOfBestKnownSolution() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/vrpnc1-jsprit-with-pickups.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
|
||||
vra.setMaxIterations(1000);
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.FAST_REGRET,"true").buildAlgorithm();
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
assertEquals(530.0, Solutions.bestOf(solutions).getCost(), 50.0);
|
||||
assertEquals(5, Solutions.bestOf(solutions).getRoutes().size());
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
package com.graphhopper.jsprit.core.algorithm;
|
||||
|
||||
|
||||
import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
||||
import com.graphhopper.jsprit.core.algorithm.state.StateManager;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
|
|
@ -28,59 +29,28 @@ 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.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class DeactivateTimeWindowsTest {
|
||||
|
||||
@Test
|
||||
public void activityTimesShouldIgnoreTimeWindows() {
|
||||
VehicleRoutingProblem vrp;
|
||||
|
||||
@Before
|
||||
public void doBefore(){
|
||||
Service service = Service.Builder.newInstance("s").setLocation(Location.newInstance(20, 0))
|
||||
.setTimeWindow(TimeWindow.newInstance(40, 50)).build();
|
||||
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(0, 0)).build();
|
||||
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addJob(service).addVehicle(vehicle).build();
|
||||
VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(vrp, "src/test/resources/algorithmConfig.xml");
|
||||
vraBuilder.addDefaultCostCalculators();
|
||||
VehicleRoutingAlgorithm vra = vraBuilder.build(); //this should ignore any constraints
|
||||
vra.setMaxIterations(10);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
vrp = VehicleRoutingProblem.Builder.newInstance().addJob(service).addVehicle(vehicle).build();
|
||||
|
||||
VehicleRoute route = Solutions.bestOf(solutions).getRoutes().iterator().next();
|
||||
Assert.assertEquals(20., route.getActivities().get(0).getEndTime(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenNotActivatingViaStateManager_activityTimesShouldConsiderTimeWindows() {
|
||||
Service service = Service.Builder.newInstance("s").setLocation(Location.newInstance(20, 0))
|
||||
.setTimeWindow(TimeWindow.newInstance(40, 50)).build();
|
||||
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(0, 0)).build();
|
||||
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addJob(service).addVehicle(vehicle).build();
|
||||
VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(vrp, "src/test/resources/algorithmConfig.xml");
|
||||
vraBuilder.addDefaultCostCalculators();
|
||||
StateManager stateManager = new StateManager(vrp);
|
||||
ConstraintManager constraintManager = new ConstraintManager(vrp, stateManager);
|
||||
vraBuilder.setStateAndConstraintManager(stateManager, constraintManager);
|
||||
VehicleRoutingAlgorithm vra = vraBuilder.build(); //this should ignore any constraints
|
||||
vra.setMaxIterations(10);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
VehicleRoute route = Solutions.bestOf(solutions).getRoutes().iterator().next();
|
||||
Assert.assertEquals(20., route.getActivities().get(0).getEndTime(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void activityTimesShouldConsiderTimeWindows() {
|
||||
Service service = Service.Builder.newInstance("s").setLocation(Location.newInstance(20, 0))
|
||||
.setTimeWindow(TimeWindow.newInstance(40, 50)).build();
|
||||
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(0, 0)).build();
|
||||
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addJob(service).addVehicle(vehicle).build();
|
||||
VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(vrp, "src/test/resources/algorithmConfig.xml");
|
||||
vraBuilder.addCoreConstraints();
|
||||
vraBuilder.addDefaultCostCalculators();
|
||||
VehicleRoutingAlgorithm vra = vraBuilder.build(); //this should ignore any constraints
|
||||
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp); //this should ignore any constraints
|
||||
vra.setMaxIterations(10);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
|
|
@ -90,18 +60,13 @@ public class DeactivateTimeWindowsTest {
|
|||
|
||||
@Test
|
||||
public void whenActivatingViaStateManager_activityTimesShouldConsiderTimeWindows() {
|
||||
Service service = Service.Builder.newInstance("s").setLocation(Location.newInstance(20, 0))
|
||||
.setTimeWindow(TimeWindow.newInstance(40, 50)).build();
|
||||
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(0, 0)).build();
|
||||
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addJob(service).addVehicle(vehicle).build();
|
||||
VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(vrp, "src/test/resources/algorithmConfig.xml");
|
||||
vraBuilder.addDefaultCostCalculators();
|
||||
StateManager stateManager = new StateManager(vrp);
|
||||
stateManager.updateTimeWindowStates();
|
||||
ConstraintManager constraintManager = new ConstraintManager(vrp, stateManager);
|
||||
constraintManager.addTimeWindowConstraint();
|
||||
vraBuilder.setStateAndConstraintManager(stateManager, constraintManager);
|
||||
VehicleRoutingAlgorithm vra = vraBuilder.build(); //this should ignore any constraints
|
||||
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).addCoreStateAndConstraintStuff(true)
|
||||
.setStateAndConstraintManager(stateManager,constraintManager).buildAlgorithm();
|
||||
vra.setMaxIterations(10);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,80 +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/>.
|
||||
*
|
||||
* Contributors:
|
||||
* Stefan Schroeder - initial API and implementation
|
||||
******************************************************************************/
|
||||
package com.graphhopper.jsprit.core.algorithm;
|
||||
|
||||
import com.graphhopper.jsprit.core.IntegrationTest;
|
||||
import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
||||
import com.graphhopper.jsprit.core.algorithm.box.SchrimpfFactory;
|
||||
import com.graphhopper.jsprit.core.algorithm.recreate.NoSolutionFoundException;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.io.VrpXMLReader;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class FiniteVehicleFleetManagerIdentifiesDistinctVehicle_IT {
|
||||
|
||||
@Test
|
||||
@Category(IntegrationTest.class)
|
||||
public void whenEmployingVehicleWhereOnlyOneDistinctVehicleCanServeAParticularJob_algorithmShouldFoundDistinctSolution() {
|
||||
final List<Boolean> testFailed = new ArrayList<Boolean>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/biggerProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
|
||||
vra.setMaxIterations(10);
|
||||
try {
|
||||
@SuppressWarnings("unused")
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
} catch (NoSolutionFoundException e) {
|
||||
testFailed.add(true);
|
||||
}
|
||||
}
|
||||
assertTrue(testFailed.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenEmployingVehicleWhereOnlyOneDistinctVehicleCanServeAParticularJobWith_jspritAlgorithmShouldFoundDistinctSolution() {
|
||||
final List<Boolean> testFailed = new ArrayList<Boolean>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/biggerProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
|
||||
vra.setMaxIterations(10);
|
||||
try {
|
||||
@SuppressWarnings("unused")
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
} catch (NoSolutionFoundException e) {
|
||||
testFailed.add(true);
|
||||
}
|
||||
}
|
||||
assertTrue(testFailed.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -40,7 +40,6 @@ import com.graphhopper.jsprit.core.problem.solution.route.activity.TourActivity;
|
|||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl;
|
||||
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.Coordinate;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import org.junit.Before;
|
||||
|
|
@ -61,7 +60,7 @@ public class InitialRoutesTest {
|
|||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
VehicleImpl v = VehicleImpl.Builder.newInstance("veh1").setStartLocation(Location.newInstance(0,0)).setLatestArrival(48600).build();
|
||||
Service s1 = Service.Builder.newInstance("s1").setLocation(Location.newInstance(1000,0)).build();
|
||||
Service s2 = Service.Builder.newInstance("s1").setLocation(Location.newInstance(1000,1000)).build();
|
||||
Service s2 = Service.Builder.newInstance("s2").setLocation(Location.newInstance(1000,1000)).build();
|
||||
builder.addVehicle(v).addJob(s1).addJob(s2);
|
||||
initialRoute = VehicleRoute.Builder.newInstance(v).addService(s1).build();
|
||||
builder.addInitialVehicleRoute(initialRoute);
|
||||
|
|
@ -77,26 +76,6 @@ public class InitialRoutesTest {
|
|||
assertEquals(2, solution.getRoutes().iterator().next().getTourActivities().getJobs().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSolvingProblem2_nuJobsInSolutionShouldBe4() {
|
||||
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem_inclShipments_iniRoutes.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
VehicleRoutingProblemSolution solution = Solutions.bestOf(solutions);
|
||||
|
||||
SolutionPrinter.print(vrp, solution, SolutionPrinter.Print.VERBOSE);
|
||||
|
||||
int jobsInSolution = 0;
|
||||
for (VehicleRoute r : solution.getRoutes()) {
|
||||
jobsInSolution += r.getTourActivities().jobSize();
|
||||
}
|
||||
assertEquals(4, jobsInSolution);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSolving_nuActsShouldBe2() {
|
||||
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
|
||||
|
|
@ -105,30 +84,12 @@ public class InitialRoutesTest {
|
|||
assertEquals(2, solution.getRoutes().iterator().next().getActivities().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSolvingProblem2_nuActsShouldBe6() {
|
||||
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem_inclShipments_iniRoutes.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
VehicleRoutingProblemSolution solution = Solutions.bestOf(solutions);
|
||||
|
||||
int nuActs = 0;
|
||||
for (VehicleRoute r : solution.getRoutes()) {
|
||||
nuActs += r.getActivities().size();
|
||||
}
|
||||
assertEquals(6, nuActs);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSolving_deliverService1_shouldBeInRoute() {
|
||||
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
VehicleRoutingProblemSolution solution = Solutions.bestOf(solutions);
|
||||
Job job = getInitialJob("1", vrp);
|
||||
Job job = getInitialJob("s1", vrp);
|
||||
assertTrue(hasActivityIn(solution, "veh1", job));
|
||||
}
|
||||
|
||||
|
|
@ -141,63 +102,6 @@ public class InitialRoutesTest {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSolvingWithJsprit_deliverService1_shouldBeInRoute() {
|
||||
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem_iniRoutes_3.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
VehicleRoutingProblemSolution solution = Solutions.bestOf(solutions);
|
||||
|
||||
SolutionPrinter.print(vrp, solution, SolutionPrinter.Print.VERBOSE);
|
||||
|
||||
Job job = getInitialJob("1", vrp);
|
||||
assertTrue(hasActivityIn(solution, "veh1", job));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSolvingProblem2With_deliverServices_and_allShipmentActs_shouldBeInRoute() {
|
||||
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem_inclShipments_iniRoutes.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
VehicleRoutingProblemSolution solution = Solutions.bestOf(solutions);
|
||||
|
||||
assertTrue(hasActivityIn(solution.getRoutes(), "1"));
|
||||
assertTrue(hasActivityIn(solution.getRoutes(), "2"));
|
||||
assertTrue(hasActivityIn(solution.getRoutes(), "3"));
|
||||
assertTrue(hasActivityIn(solution.getRoutes(), "4"));
|
||||
|
||||
assertTrue(hasActivityIn(solution, "veh1", getInitialJob("1", vrp)));
|
||||
assertTrue(hasActivityIn(solution, "veh2", getInitialJob("3", vrp)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSolvingProblem2WithJsprit_deliverServices_and_allShipmentActs_shouldBeInRoute() {
|
||||
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem_inclShipments_iniRoutes.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
VehicleRoutingProblemSolution solution = Solutions.bestOf(solutions);
|
||||
|
||||
assertTrue(hasActivityIn(solution.getRoutes(), "1"));
|
||||
assertTrue(hasActivityIn(solution.getRoutes(), "2"));
|
||||
assertTrue(hasActivityIn(solution.getRoutes(), "3"));
|
||||
assertTrue(hasActivityIn(solution.getRoutes(), "4"));
|
||||
|
||||
assertTrue(hasActivityIn(solution, "veh1", getInitialJob("1", vrp)));
|
||||
assertTrue(hasActivityIn(solution, "veh2", getInitialJob("3", vrp)));
|
||||
}
|
||||
|
||||
private boolean hasActivityIn(Collection<VehicleRoute> routes, String jobId) {
|
||||
boolean isInRoute = false;
|
||||
for (VehicleRoute route : routes) {
|
||||
|
|
@ -239,7 +143,7 @@ public class InitialRoutesTest {
|
|||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
VehicleRoutingProblemSolution solution = Solutions.bestOf(solutions);
|
||||
|
||||
assertTrue(hasActivityIn(solution.getRoutes().iterator().next(), "2"));
|
||||
assertTrue(hasActivityIn(solution.getRoutes().iterator().next(), "s2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -276,19 +180,6 @@ public class InitialRoutesTest {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingProblemFromFile_maxCapacityShouldNotBeExceeded() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem_iniRoutes_2.xml");
|
||||
VehicleRoutingAlgorithm vra = new GreedySchrimpfFactory().createAlgorithm(vrpBuilder.build());
|
||||
vra.setMaxIterations(10);
|
||||
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
assertFalse(secondActIsPickup(solutions));
|
||||
|
||||
}
|
||||
|
||||
private boolean secondActIsPickup(Collection<VehicleRoutingProblemSolution> solutions) {
|
||||
VehicleRoutingProblemSolution solution = Solutions.bestOf(solutions);
|
||||
TourActivity secondAct = solution.getRoutes().iterator().next().getActivities().get(1);
|
||||
|
|
|
|||
|
|
@ -18,27 +18,30 @@
|
|||
******************************************************************************/
|
||||
package com.graphhopper.jsprit.core.algorithm;
|
||||
|
||||
import com.graphhopper.jsprit.core.algorithm.box.GreedySchrimpfFactory;
|
||||
import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
||||
import com.graphhopper.jsprit.core.algorithm.box.SchrimpfFactory;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||
import com.graphhopper.jsprit.core.algorithm.recreate.listener.JobInsertedListener;
|
||||
import com.graphhopper.jsprit.core.algorithm.recreate.listener.VehicleSwitchedListener;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
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.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.VehicleRoute;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleType;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
import com.graphhopper.jsprit.core.util.FastVehicleRoutingTransportCostsMatrix;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
|
@ -48,26 +51,35 @@ import static org.junit.Assert.assertTrue;
|
|||
|
||||
public class MeetTimeWindowConstraint_IT {
|
||||
|
||||
VehicleRoutingProblem vrp;
|
||||
|
||||
@Before
|
||||
public void doBefore(){
|
||||
VehicleType type1 = VehicleTypeImpl.Builder.newInstance("5").build();
|
||||
VehicleType type2 = VehicleTypeImpl.Builder.newInstance("3.5").build();
|
||||
VehicleImpl vehicle1 = VehicleImpl.Builder.newInstance("21").setStartLocation(Location.newInstance(0,0))
|
||||
.setEarliestStart(14400).setLatestArrival(46800).setType(type1).build();
|
||||
VehicleImpl vehicle2 = VehicleImpl.Builder.newInstance("19").setStartLocation(Location.newInstance(0,0))
|
||||
.setEarliestStart(39600).setLatestArrival(64800).setType(type2).build();
|
||||
Service service1 = Service.Builder.newInstance("2").setLocation(Location.newInstance(2000, 0))
|
||||
.setTimeWindow(TimeWindow.newInstance(54000,54000)).build();
|
||||
Service service2 = Service.Builder.newInstance("1").setLocation(Location.newInstance(1000, 1000))
|
||||
.setTimeWindow(TimeWindow.newInstance(19800,21600)).build();
|
||||
vrp = VehicleRoutingProblem.Builder.newInstance().addVehicle(vehicle1).addVehicle(vehicle2)
|
||||
.addJob(service1).addJob(service2).setFleetSize(VehicleRoutingProblem.FleetSize.FINITE).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_nRoutesShouldBeCorrect() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
|
||||
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
|
||||
vra.setMaxIterations(100);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
Assert.assertEquals(2, Solutions.bestOf(solutions).getRoutes().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_certainJobsCanNeverBeAssignedToCertainVehicles() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
|
||||
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
|
||||
vra.setMaxIterations(100);
|
||||
final List<Boolean> testFailed = new ArrayList<Boolean>();
|
||||
vra.addListener(new JobInsertedListener() {
|
||||
|
|
@ -89,17 +101,12 @@ public class MeetTimeWindowConstraint_IT {
|
|||
});
|
||||
@SuppressWarnings("unused")
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
assertTrue(testFailed.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_certainVehiclesCanNeverBeAssignedToCertainRoutes() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
|
||||
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
|
||||
vra.setMaxIterations(100);
|
||||
final List<Boolean> testFailed = new ArrayList<Boolean>();
|
||||
vra.addListener(new VehicleSwitchedListener() {
|
||||
|
|
@ -133,11 +140,7 @@ public class MeetTimeWindowConstraint_IT {
|
|||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_job2CanNeverBeInVehicle21() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
|
||||
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
|
||||
vra.setMaxIterations(100);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
|
|
@ -146,40 +149,24 @@ public class MeetTimeWindowConstraint_IT {
|
|||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_job1ShouldBeAssignedCorrectly() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
|
||||
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
|
||||
vra.setMaxIterations(100);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
// assertEquals(2,Solutions.bestOf(solutions).getRoutes().size());
|
||||
assertTrue(containsJob(vrp.getJobs().get("1"), getRoute("21", Solutions.bestOf(solutions))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_job2ShouldBeAssignedCorrectly() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
|
||||
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
|
||||
vra.setMaxIterations(100);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
// assertEquals(2,Solutions.bestOf(solutions).getRoutes().size());
|
||||
assertTrue(containsJob(vrp.getJobs().get("2"), getRoute("19", Solutions.bestOf(solutions))));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_and_vehicleSwitchIsNotAllowed_nRoutesShouldBeCorrect() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/schrimpf_vehicleSwitchNotAllowed.xml");
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.VEHICLE_SWITCH,"false").buildAlgorithm();
|
||||
vra.setMaxIterations(100);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
|
|
@ -188,11 +175,7 @@ public class MeetTimeWindowConstraint_IT {
|
|||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_and_vehicleSwitchIsNotAllowed_certainJobsCanNeverBeAssignedToCertainVehicles() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/schrimpf_vehicleSwitchNotAllowed.xml");
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.VEHICLE_SWITCH,"false").buildAlgorithm();
|
||||
vra.setMaxIterations(100);
|
||||
final List<Boolean> testFailed = new ArrayList<Boolean>();
|
||||
vra.addListener(new JobInsertedListener() {
|
||||
|
|
@ -220,11 +203,7 @@ public class MeetTimeWindowConstraint_IT {
|
|||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_and_vehicleSwitchIsNotAllowed_certainVehiclesCanNeverBeAssignedToCertainRoutes() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/schrimpf_vehicleSwitchNotAllowed.xml");
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.VEHICLE_SWITCH,"false").buildAlgorithm();
|
||||
vra.setMaxIterations(100);
|
||||
final List<Boolean> testFailed = new ArrayList<Boolean>();
|
||||
vra.addListener(new VehicleSwitchedListener() {
|
||||
|
|
@ -258,11 +237,7 @@ public class MeetTimeWindowConstraint_IT {
|
|||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_and_vehicleSwitchIsNotAllowed_job2CanNeverBeInVehicle21() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/schrimpf_vehicleSwitchNotAllowed.xml");
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.VEHICLE_SWITCH,"false").buildAlgorithm();
|
||||
vra.setMaxIterations(100);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
|
|
@ -271,11 +246,7 @@ public class MeetTimeWindowConstraint_IT {
|
|||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_and_vehicleSwitchIsNotAllowed_job1ShouldBeAssignedCorrectly() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/schrimpf_vehicleSwitchNotAllowed.xml");
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.VEHICLE_SWITCH,"false").buildAlgorithm();
|
||||
vra.setMaxIterations(100);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
|
|
@ -285,261 +256,7 @@ public class MeetTimeWindowConstraint_IT {
|
|||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_and_vehicleSwitchIsNotAllowed_job2ShouldBeAssignedCorrectly() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/schrimpf_vehicleSwitchNotAllowed.xml");
|
||||
vra.setMaxIterations(100);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
assertEquals(2, Solutions.bestOf(solutions).getRoutes().size());
|
||||
assertTrue(containsJob(vrp.getJobs().get("2"), getRoute("19", Solutions.bestOf(solutions))));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_jsprit_nRoutesShouldBeCorrect() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
|
||||
vra.setMaxIterations(100);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
assertEquals(2, Solutions.bestOf(solutions).getRoutes().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_jsprit_certainJobsCanNeverBeAssignedToCertainVehicles() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
|
||||
vra.setMaxIterations(100);
|
||||
final List<Boolean> testFailed = new ArrayList<Boolean>();
|
||||
vra.addListener(new JobInsertedListener() {
|
||||
|
||||
@Override
|
||||
public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) {
|
||||
if (job2insert.getId().equals("1")) {
|
||||
if (inRoute.getVehicle().getId().equals("19")) {
|
||||
testFailed.add(true);
|
||||
}
|
||||
}
|
||||
if (job2insert.getId().equals("2")) {
|
||||
if (inRoute.getVehicle().getId().equals("21")) {
|
||||
testFailed.add(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
@SuppressWarnings("unused")
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
assertTrue(testFailed.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_jsprit_certainVehiclesCanNeverBeAssignedToCertainRoutes() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
|
||||
vra.setMaxIterations(100);
|
||||
final List<Boolean> testFailed = new ArrayList<Boolean>();
|
||||
vra.addListener(new VehicleSwitchedListener() {
|
||||
|
||||
@Override
|
||||
public void vehicleSwitched(VehicleRoute vehicleRoute, Vehicle oldVehicle, Vehicle newVehicle) {
|
||||
if (oldVehicle == null) return;
|
||||
if (oldVehicle.getId().equals("21") && newVehicle.getId().equals("19")) {
|
||||
for (Job j : vehicleRoute.getTourActivities().getJobs()) {
|
||||
if (j.getId().equals("1")) {
|
||||
testFailed.add(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (oldVehicle.getId().equals("19") && newVehicle.getId().equals("21")) {
|
||||
for (Job j : vehicleRoute.getTourActivities().getJobs()) {
|
||||
if (j.getId().equals("2")) {
|
||||
testFailed.add(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
assertTrue(testFailed.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_jsprit_job2CanNeverBeInVehicle21() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
|
||||
vra.setMaxIterations(100);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
assertEquals(2, Solutions.bestOf(solutions).getRoutes().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_jsprit_job1ShouldBeAssignedCorrectly() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
|
||||
vra.setMaxIterations(100);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
// assertEquals(2,Solutions.bestOf(solutions).getRoutes().size());
|
||||
assertTrue(containsJob(vrp.getJobs().get("1"), getRoute("21", Solutions.bestOf(solutions))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_jsprit_job2ShouldBeAssignedCorrectly() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
|
||||
vra.setMaxIterations(100);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
// assertEquals(2,Solutions.bestOf(solutions).getRoutes().size());
|
||||
assertTrue(containsJob(vrp.getJobs().get("2"), getRoute("19", Solutions.bestOf(solutions))));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_jsprit_and_vehicleSwitchIsNotAllowed_nRoutesShouldBeCorrect() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.VEHICLE_SWITCH, "false").buildAlgorithm();
|
||||
vra.setMaxIterations(100);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
assertEquals(2, Solutions.bestOf(solutions).getRoutes().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_and_vehicleSwitchIsNotAllowed_jsprit_certainJobsCanNeverBeAssignedToCertainVehicles() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.VEHICLE_SWITCH, "false").buildAlgorithm();
|
||||
vra.setMaxIterations(100);
|
||||
final List<Boolean> testFailed = new ArrayList<Boolean>();
|
||||
vra.addListener(new JobInsertedListener() {
|
||||
|
||||
@Override
|
||||
public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) {
|
||||
if (job2insert.getId().equals("1")) {
|
||||
if (inRoute.getVehicle().getId().equals("19")) {
|
||||
testFailed.add(true);
|
||||
}
|
||||
}
|
||||
if (job2insert.getId().equals("2")) {
|
||||
if (inRoute.getVehicle().getId().equals("21")) {
|
||||
testFailed.add(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
@SuppressWarnings("unused")
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
assertTrue(testFailed.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_and_vehicleSwitchIsNotAllowed_jsprit_certainVehiclesCanNeverBeAssignedToCertainRoutes() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.VEHICLE_SWITCH, "false").buildAlgorithm();
|
||||
vra.setMaxIterations(100);
|
||||
final List<Boolean> testFailed = new ArrayList<Boolean>();
|
||||
vra.addListener(new VehicleSwitchedListener() {
|
||||
|
||||
@Override
|
||||
public void vehicleSwitched(VehicleRoute vehicleRoute, Vehicle oldVehicle, Vehicle newVehicle) {
|
||||
if (oldVehicle == null) return;
|
||||
if (oldVehicle.getId().equals("21") && newVehicle.getId().equals("19")) {
|
||||
for (Job j : vehicleRoute.getTourActivities().getJobs()) {
|
||||
if (j.getId().equals("1")) {
|
||||
testFailed.add(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (oldVehicle.getId().equals("19") && newVehicle.getId().equals("21")) {
|
||||
for (Job j : vehicleRoute.getTourActivities().getJobs()) {
|
||||
if (j.getId().equals("2")) {
|
||||
testFailed.add(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
assertTrue(testFailed.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_and_vehicleSwitchIsNotAllowed_jsprit_job2CanNeverBeInVehicle21() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.VEHICLE_SWITCH, "false").buildAlgorithm();
|
||||
vra.setMaxIterations(100);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
assertEquals(2, Solutions.bestOf(solutions).getRoutes().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_and_vehicleSwitchIsNotAllowed_jsprit_job1ShouldBeAssignedCorrectly() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.VEHICLE_SWITCH, "false").buildAlgorithm();
|
||||
vra.setMaxIterations(100);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
assertEquals(2, Solutions.bestOf(solutions).getRoutes().size());
|
||||
assertTrue(containsJob(vrp.getJobs().get("1"), getRoute("21", Solutions.bestOf(solutions))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenEmployingVehicleWithDifferentWorkingShifts_and_vehicleSwitchIsNotAllowed_jsprit_job2ShouldBeAssignedCorrectly() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.VEHICLE_SWITCH, "false").buildAlgorithm();
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.VEHICLE_SWITCH,"false").buildAlgorithm();
|
||||
vra.setMaxIterations(100);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
|
|
@ -549,12 +266,8 @@ public class MeetTimeWindowConstraint_IT {
|
|||
|
||||
@Test
|
||||
public void whenUsingJsprit_driverTimesShouldBeMet() throws IOException {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/twbug.xml");
|
||||
final FastVehicleRoutingTransportCostsMatrix matrix = createMatrix();
|
||||
vrpBuilder.setRoutingCost(matrix);
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
VehicleRoutingAlgorithm algorithm = Jsprit.Builder.newInstance(vrp).buildAlgorithm();
|
||||
VehicleRoutingProblem vrp = createTWBugProblem();
|
||||
VehicleRoutingAlgorithm algorithm = Jsprit.createAlgorithm(vrp);
|
||||
algorithm.setMaxIterations(1000);
|
||||
VehicleRoutingProblemSolution solution = Solutions.bestOf(algorithm.searchSolutions());
|
||||
for (VehicleRoute r : solution.getRoutes()) {
|
||||
|
|
@ -563,41 +276,8 @@ public class MeetTimeWindowConstraint_IT {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingSchrimpf_driverTimesShouldBeMet() throws IOException {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/twbug.xml");
|
||||
final FastVehicleRoutingTransportCostsMatrix matrix = createMatrix();
|
||||
vrpBuilder.setRoutingCost(matrix);
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
VehicleRoutingAlgorithm algorithm = new SchrimpfFactory().createAlgorithm(vrp);
|
||||
algorithm.setMaxIterations(1000);
|
||||
VehicleRoutingProblemSolution solution = Solutions.bestOf(algorithm.searchSolutions());
|
||||
for (VehicleRoute r : solution.getRoutes()) {
|
||||
assertTrue(r.getVehicle().getEarliestDeparture() <= r.getDepartureTime());
|
||||
assertTrue(r.getVehicle().getLatestArrival() >= r.getEnd().getArrTime());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingGreedySchrimpf_driverTimesShouldBeMet() throws IOException {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/twbug.xml");
|
||||
final FastVehicleRoutingTransportCostsMatrix matrix = createMatrix();
|
||||
vrpBuilder.setRoutingCost(matrix);
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
VehicleRoutingAlgorithm algorithm = new GreedySchrimpfFactory().createAlgorithm(vrp);
|
||||
algorithm.setMaxIterations(1000);
|
||||
VehicleRoutingProblemSolution solution = Solutions.bestOf(algorithm.searchSolutions());
|
||||
for (VehicleRoute r : solution.getRoutes()) {
|
||||
assertTrue(r.getVehicle().getEarliestDeparture() <= r.getDepartureTime());
|
||||
assertTrue(r.getVehicle().getLatestArrival() >= r.getEnd().getArrTime());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private FastVehicleRoutingTransportCostsMatrix createMatrix() throws IOException {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(new File("src/test/resources/matrix.txt")));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("matrix.txt")));
|
||||
String line;
|
||||
FastVehicleRoutingTransportCostsMatrix.Builder builder = FastVehicleRoutingTransportCostsMatrix.Builder.newInstance(11, false);
|
||||
while ((line = reader.readLine()) != null) {
|
||||
|
|
@ -628,4 +308,75 @@ public class MeetTimeWindowConstraint_IT {
|
|||
return null;
|
||||
}
|
||||
|
||||
private VehicleRoutingProblem createTWBugProblem() throws IOException {
|
||||
VehicleType type = VehicleTypeImpl.Builder.newInstance("type").addCapacityDimension(0,20)
|
||||
.setCostPerTransportTime(1.).setCostPerDistance(0).build();
|
||||
VehicleImpl v0 = VehicleImpl.Builder.newInstance("vehicle0").setStartLocation(Location.newInstance(0))
|
||||
.setEarliestStart(60).setLatestArrival(18060).setType(type).build();
|
||||
VehicleImpl v1 = VehicleImpl.Builder.newInstance("vehicle1").setStartLocation(Location.newInstance(0))
|
||||
.setEarliestStart(60).setLatestArrival(18060).setType(type).build();
|
||||
VehicleImpl v2 = VehicleImpl.Builder.newInstance("vehicle2").setStartLocation(Location.newInstance(0))
|
||||
.setEarliestStart(7200).setLatestArrival(36060).setType(type).build();
|
||||
VehicleImpl v3 = VehicleImpl.Builder.newInstance("vehicle3").setStartLocation(Location.newInstance(0))
|
||||
.setEarliestStart(36000).setLatestArrival(54060).setType(type).build();
|
||||
VehicleImpl v4 = VehicleImpl.Builder.newInstance("vehicle4").setStartLocation(Location.newInstance(0))
|
||||
.setEarliestStart(36000).setLatestArrival(54060).setType(type).build();
|
||||
|
||||
Service s1 = Service.Builder.newInstance("1").setLocation(Location.Builder.newInstance().setIndex(1).setId("js0").build())
|
||||
.setServiceTime(600).setTimeWindow(TimeWindow.newInstance(0,1800)).addSizeDimension(0,1).build();
|
||||
Service s2 = Service.Builder.newInstance("2").setLocation(Location.Builder.newInstance().setIndex(2).setId("js2").build())
|
||||
.setServiceTime(600).setTimeWindow(TimeWindow.newInstance(5400, 7200)).addSizeDimension(0, 2).build();
|
||||
Service s3 = Service.Builder.newInstance("3").setLocation(Location.Builder.newInstance().setIndex(3).setId("js5").build())
|
||||
.setServiceTime(1800).setTimeWindow(TimeWindow.newInstance(17100, 18000)).addSizeDimension(0, 10).build();
|
||||
Service s4 = Service.Builder.newInstance("4").setLocation(Location.Builder.newInstance().setIndex(4).setId("js4").build())
|
||||
.setServiceTime(900).addSizeDimension(0, 2).build();
|
||||
Service s5 = Service.Builder.newInstance("5").setLocation(Location.Builder.newInstance().setIndex(5).setId("js8").build())
|
||||
.setServiceTime(600).addSizeDimension(0, 4).build();
|
||||
Service s6 = Service.Builder.newInstance("6").setLocation(Location.Builder.newInstance().setIndex(6).setId("js10").build())
|
||||
.setServiceTime(1500).setTimeWindow(TimeWindow.newInstance(29700,32400)).addSizeDimension(0, 10).build();
|
||||
Service s7 = Service.Builder.newInstance("7").setLocation(Location.Builder.newInstance().setIndex(7).setId("jsp3").build())
|
||||
.setServiceTime(5594).build();
|
||||
|
||||
Shipment shipment1 = Shipment.Builder.newInstance("shipment1")
|
||||
.setPickupServiceTime(900)
|
||||
.setPickupLocation(Location.Builder.newInstance().setId("jsp1").setIndex(1).build())
|
||||
.setDeliveryLocation(Location.Builder.newInstance().setId("jsd1").setIndex(8).build())
|
||||
.setDeliveryServiceTime(900).build();
|
||||
|
||||
Shipment shipment2 = Shipment.Builder.newInstance("shipment2")
|
||||
.setPickupLocation(Location.Builder.newInstance().setId("jsp4").setIndex(9).build())
|
||||
.setPickupServiceTime(1200)
|
||||
.addPickupTimeWindow(21600,23400)
|
||||
.setDeliveryLocation(Location.Builder.newInstance().setId("jsd4").setIndex(8).build())
|
||||
.setDeliveryServiceTime(900)
|
||||
.addDeliveryTimeWindow(25200,27000)
|
||||
.build();
|
||||
|
||||
Shipment shipment3 = Shipment.Builder.newInstance("shipment3")
|
||||
.setPickupLocation(Location.Builder.newInstance().setId("jsp7").setIndex(9).build())
|
||||
.setPickupServiceTime(1200)
|
||||
.addPickupTimeWindow(37800,41400)
|
||||
.setDeliveryLocation(Location.Builder.newInstance().setId("jsd7").setIndex(8).build())
|
||||
.setDeliveryServiceTime(1800)
|
||||
.addDeliveryTimeWindow(43200,45900)
|
||||
.build();
|
||||
|
||||
Shipment shipment4 = Shipment.Builder.newInstance("shipment4")
|
||||
.setPickupLocation(Location.Builder.newInstance().setId("jsp9").setIndex(10).build())
|
||||
.setPickupServiceTime(300)
|
||||
.addPickupTimeWindow(45000,48600)
|
||||
.setDeliveryLocation(Location.Builder.newInstance().setId("jsd9").setIndex(8).build())
|
||||
.setDeliveryServiceTime(300)
|
||||
.addDeliveryTimeWindow(50400,52200)
|
||||
.build();
|
||||
|
||||
FastVehicleRoutingTransportCostsMatrix matrix = createMatrix();
|
||||
return VehicleRoutingProblem.Builder.newInstance().setFleetSize(VehicleRoutingProblem.FleetSize.FINITE)
|
||||
.addJob(s1).addJob(s2).addJob(s3).addJob(s4).addJob(s5).addJob(s6).addJob(s7)
|
||||
.addJob(shipment1).addJob(shipment2).addJob(shipment3).addJob(shipment4)
|
||||
.addVehicle(v0).addVehicle(v1).addVehicle(v2).addVehicle(v3).addVehicle(v4)
|
||||
.setRoutingCost(matrix).build();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,9 @@ package com.graphhopper.jsprit.core.algorithm;
|
|||
|
||||
import com.graphhopper.jsprit.core.IntegrationTest;
|
||||
import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.io.VrpXMLReader;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.util.LiLimReader;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
|
@ -38,22 +37,9 @@ public class PickupsAndDeliveries_IT {
|
|||
@Category(IntegrationTest.class)
|
||||
public void whenSolvingLR101InstanceOfLiLim_solutionsMustNoBeWorseThan5PercentOfBestKnownSolution() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/lilim_lr101.xml");
|
||||
new LiLimReader(vrpBuilder).read(getClass().getResourceAsStream("lr101.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/lilim_algorithmConfig.xml");
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
assertEquals(1650.8, Solutions.bestOf(solutions).getCost(), 80.);
|
||||
assertEquals(19, Solutions.bestOf(solutions).getRoutes().size(), 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Category(IntegrationTest.class)
|
||||
public void whenSolvingLR101InstanceOfLiLim_withJsprit_solutionsMustNoBeWorseThan5PercentOfBestKnownSolution() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/lilim_lr101.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
|
||||
vra.setMaxIterations(1000);
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.FAST_REGRET,"true").buildAlgorithm();
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
assertEquals(1650.8, Solutions.bestOf(solutions).getCost(), 80.);
|
||||
assertEquals(19, Solutions.bestOf(solutions).getRoutes().size(), 1);
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
package com.graphhopper.jsprit.core.algorithm;
|
||||
|
||||
import com.graphhopper.jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.io.VrpXMLReader;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class SelectRandomlyTest {
|
||||
|
||||
@Test
|
||||
public void loadAnAlgorithmWithSelectRandomly() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/simpleProblem.xml");
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
try {
|
||||
VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfig_selectRandomly.xml");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
fail("Should be able to load an algorithm that uses <selector name=\"selectRandomly\"/>: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ public class SolomonSkills_IT {
|
|||
@Category(IntegrationTest.class)
|
||||
public void itShouldMakeCorrectAssignmentAccordingToSkills() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new SolomonReader(vrpBuilder).read("src/test/resources/C101.txt");
|
||||
new SolomonReader(vrpBuilder).read(getClass().getResourceAsStream("C101.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
//y >= 50 skill1 otherwise skill2
|
||||
|
|
@ -78,7 +78,7 @@ public class SolomonSkills_IT {
|
|||
skillProblemBuilder.setFleetSize(VehicleRoutingProblem.FleetSize.FINITE);
|
||||
VehicleRoutingProblem skillProblem = skillProblemBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(skillProblem);
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(skillProblem).setProperty(Jsprit.Parameter.FAST_REGRET,"true").buildAlgorithm();
|
||||
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
VehicleRoutingProblemSolution solution = Solutions.bestOf(solutions);
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ package com.graphhopper.jsprit.core.algorithm;
|
|||
import com.graphhopper.jsprit.core.IntegrationTest;
|
||||
import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.io.VrpXMLReader;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.util.SolomonReader;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
|
@ -21,14 +21,10 @@ public class Solomon_IT {
|
|||
@Category(IntegrationTest.class)
|
||||
public void itShouldFindTheBestKnownSolution() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(vrpBuilder).read("src/test/resources/solomon_c101.xml");
|
||||
new SolomonReader(vrpBuilder).read(getClass().getResourceAsStream("C101.txt"));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp)
|
||||
// .setProperty(Jsprit.Parameter.THREADS,"3")
|
||||
// .setProperty(Jsprit.Parameter.FAST_REGRET,"true")
|
||||
.buildAlgorithm();
|
||||
// VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfig.xml");
|
||||
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.FAST_REGRET,"true").buildAlgorithm();
|
||||
vra.setMaxIterations(2000);
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
Assert.assertEquals(828.94, Solutions.bestOf(solutions).getCost(), 0.01);
|
||||
|
|
|
|||
|
|
@ -1,95 +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.recreate;
|
||||
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
||||
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||
import com.graphhopper.jsprit.core.problem.driver.Driver;
|
||||
import com.graphhopper.jsprit.core.problem.job.Service;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
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.core.util.TestUtils;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
||||
public class CalcWithTimeSchedulingTest {
|
||||
|
||||
|
||||
public void timeScheduler() {
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("myVehicle").setEarliestStart(0.0).setLatestArrival(100.0).
|
||||
setStartLocation(TestUtils.loc("0,0", Coordinate.newInstance(0, 0)))
|
||||
.setType(VehicleTypeImpl.Builder.newInstance("myType").addCapacityDimension(0, 20).setCostPerDistance(1.0).build()).build();
|
||||
vrpBuilder.addVehicle(vehicle);
|
||||
vrpBuilder.addJob(Service.Builder.newInstance("myService").addSizeDimension(0, 2)
|
||||
.setLocation(TestUtils.loc("0,20", Coordinate.newInstance(0, 20))).build());
|
||||
vrpBuilder.setFleetSize(FleetSize.INFINITE);
|
||||
vrpBuilder.setRoutingCost(getTpCosts(new CrowFlyCosts(vrpBuilder.getLocations())));
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/testConfig.xml");
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
VehicleRoutingProblemSolution sol = Solutions.bestOf(solutions);
|
||||
assertEquals(40.0, sol.getCost(), 0.01);
|
||||
assertEquals(1, sol.getRoutes().size());
|
||||
VehicleRoute route = sol.getRoutes().iterator().next();
|
||||
assertEquals(50.0, route.getStart().getEndTime(), 0.01);
|
||||
}
|
||||
|
||||
private VehicleRoutingTransportCosts getTpCosts(final VehicleRoutingTransportCosts baseCosts) {
|
||||
return new VehicleRoutingTransportCosts() {
|
||||
|
||||
@Override
|
||||
public double getBackwardTransportCost(Location from, Location to, double arrivalTime, Driver driver, Vehicle vehicle) {
|
||||
return getTransportCost(from, to, arrivalTime, driver, vehicle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTransportCost(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) {
|
||||
if (departureTime < 50) {
|
||||
return baseCosts.getTransportCost(from, to, departureTime, driver, vehicle) * 2.0;
|
||||
}
|
||||
return baseCosts.getTransportCost(from, to, departureTime, driver, vehicle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBackwardTransportTime(Location from, Location to, double arrivalTime, Driver driver, Vehicle vehicle) {
|
||||
return getTransportTime(from, to, arrivalTime, driver, vehicle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTransportTime(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) {
|
||||
return getTransportCost(from, to, departureTime, driver, vehicle);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,249 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2013 Stefan Schroeder
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package com.graphhopper.jsprit.core.algorithm.recreate;
|
||||
|
||||
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import com.graphhopper.jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.cost.VehicleRoutingActivityCosts;
|
||||
import com.graphhopper.jsprit.core.problem.driver.Driver;
|
||||
import com.graphhopper.jsprit.core.problem.job.Service;
|
||||
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.TourActivity;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.Vehicle;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
import com.graphhopper.jsprit.core.util.Coordinate;
|
||||
import com.graphhopper.jsprit.core.util.Solutions;
|
||||
import com.graphhopper.jsprit.core.util.TestUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@Ignore
|
||||
public class TestDepartureTimeOpt {
|
||||
|
||||
@Test
|
||||
public void whenSettingOneCustWithTWAnd_NO_DepTimeChoice_totalCostsShouldBe50() {
|
||||
TimeWindow timeWindow = TimeWindow.newInstance(40, 45);
|
||||
Service service = Service.Builder.newInstance("s").setLocation(TestUtils.loc("servLoc", Coordinate.newInstance(0, 10))).setTimeWindow(timeWindow).build();
|
||||
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(TestUtils.loc("vehLoc", Coordinate.newInstance(0, 0)))
|
||||
.setType(VehicleTypeImpl.Builder.newInstance("vType").build()).build();
|
||||
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
vrpBuilder.setActivityCosts(new VehicleRoutingActivityCosts() {
|
||||
|
||||
@Override
|
||||
public double getActivityCost(TourActivity tourAct, double arrivalTime, Driver driver, Vehicle vehicle) {
|
||||
double waiting = Math.max(0, tourAct.getTheoreticalEarliestOperationStartTime() - arrivalTime) * 1;
|
||||
double late = Math.max(0, arrivalTime - tourAct.getTheoreticalLatestOperationStartTime()) * 100;
|
||||
return waiting + late;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getActivityDuration(TourActivity tourAct, double arrivalTime, Driver driver, Vehicle vehicle) {
|
||||
return tourAct.getOperationTime();
|
||||
}
|
||||
|
||||
});
|
||||
VehicleRoutingProblem vrp = vrpBuilder.addJob(service).addVehicle(vehicle).build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfig.xml");
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
Assert.assertEquals(20.0 + 30.0, Solutions.bestOf(solutions).getCost(), 0.1);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSettingOneCustWithTWAnd_NO_DepTimeChoice_depTimeShouldBe0() {
|
||||
TimeWindow timeWindow = TimeWindow.newInstance(40, 45);
|
||||
Service service = Service.Builder.newInstance("s")
|
||||
.setLocation(TestUtils.loc("servLoc", Coordinate.newInstance(0, 10))).setTimeWindow(timeWindow).build();
|
||||
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.Builder.newInstance().setId("vehLoc").setCoordinate(Coordinate.newInstance(0, 0)).build())
|
||||
.setType(VehicleTypeImpl.Builder.newInstance("vType").build()).build();
|
||||
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
vrpBuilder.setActivityCosts(new VehicleRoutingActivityCosts() {
|
||||
|
||||
@Override
|
||||
public double getActivityCost(TourActivity tourAct, double arrivalTime, Driver driver, Vehicle vehicle) {
|
||||
double waiting = Math.max(0, tourAct.getTheoreticalEarliestOperationStartTime() - arrivalTime) * 1;
|
||||
double late = Math.max(0, arrivalTime - tourAct.getTheoreticalLatestOperationStartTime()) * 100;
|
||||
return waiting + late;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getActivityDuration(TourActivity tourAct, double arrivalTime, Driver driver, Vehicle vehicle) {
|
||||
return tourAct.getOperationTime();
|
||||
}
|
||||
|
||||
});
|
||||
VehicleRoutingProblem vrp = vrpBuilder.addJob(service).addVehicle(vehicle).build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfig.xml");
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
Assert.assertEquals(0.0, Solutions.bestOf(solutions).getRoutes().iterator().next().getStart().getEndTime(), 0.1);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSettingOneCustWithTWAndDepTimeChoice_totalCostsShouldBe50() {
|
||||
TimeWindow timeWindow = TimeWindow.newInstance(40, 45);
|
||||
Service service = Service.Builder.newInstance("s").setLocation(TestUtils.loc("servLoc", Coordinate.newInstance(0, 10))).setTimeWindow(timeWindow).build();
|
||||
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(TestUtils.loc("vehLoc", Coordinate.newInstance(0, 0)))
|
||||
.setType(VehicleTypeImpl.Builder.newInstance("vType").build()).build();
|
||||
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
vrpBuilder.setActivityCosts(new VehicleRoutingActivityCosts() {
|
||||
|
||||
@Override
|
||||
public double getActivityCost(TourActivity tourAct, double arrivalTime, Driver driver, Vehicle vehicle) {
|
||||
double waiting = Math.max(0, tourAct.getTheoreticalEarliestOperationStartTime() - arrivalTime) * 1;
|
||||
double late = Math.max(0, arrivalTime - tourAct.getTheoreticalLatestOperationStartTime()) * 100;
|
||||
return waiting + late;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getActivityDuration(TourActivity tourAct, double arrivalTime, Driver driver, Vehicle vehicle) {
|
||||
return tourAct.getOperationTime();
|
||||
}
|
||||
|
||||
});
|
||||
VehicleRoutingProblem vrp = vrpBuilder.addJob(service).addVehicle(vehicle).build();
|
||||
|
||||
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfigWithDepartureTimeChoice.xml");
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
Assert.assertEquals(20.0, Solutions.bestOf(solutions).getCost(), 0.1);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSettingOneCustWithTWAndDepTimeChoice_depTimeShouldBe0() {
|
||||
TimeWindow timeWindow = TimeWindow.newInstance(40, 45);
|
||||
Service service = Service.Builder.newInstance("s").setLocation(TestUtils.loc("servLoc", Coordinate.newInstance(0, 10))).setTimeWindow(timeWindow).build();
|
||||
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(TestUtils.loc("vehLoc", Coordinate.newInstance(0, 0)))
|
||||
.setType(VehicleTypeImpl.Builder.newInstance("vType").build()).build();
|
||||
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
vrpBuilder.setActivityCosts(new VehicleRoutingActivityCosts() {
|
||||
|
||||
@Override
|
||||
public double getActivityCost(TourActivity tourAct, double arrivalTime, Driver driver, Vehicle vehicle) {
|
||||
double waiting = Math.max(0, tourAct.getTheoreticalEarliestOperationStartTime() - arrivalTime) * 1;
|
||||
double late = Math.max(0, arrivalTime - tourAct.getTheoreticalLatestOperationStartTime()) * 100;
|
||||
return waiting + late;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getActivityDuration(TourActivity tourAct, double arrivalTime, Driver driver, Vehicle vehicle) {
|
||||
return tourAct.getOperationTime();
|
||||
}
|
||||
|
||||
});
|
||||
VehicleRoutingProblem vrp = vrpBuilder.addJob(service).addVehicle(vehicle).build();
|
||||
|
||||
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfigWithDepartureTimeChoice.xml");
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
Assert.assertEquals(30.0, Solutions.bestOf(solutions).getRoutes().iterator().next().getStart().getEndTime(), 0.1);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSettingTwoCustWithTWAndDepTimeChoice_totalCostsShouldBe50() {
|
||||
TimeWindow timeWindow = TimeWindow.newInstance(40, 45);
|
||||
Service service = Service.Builder.newInstance("s").setLocation(TestUtils.loc("servLoc", Coordinate.newInstance(0, 10))).setTimeWindow(timeWindow).build();
|
||||
|
||||
Service service2 = Service.Builder.newInstance("s2").setLocation(TestUtils.loc("servLoc2", Coordinate.newInstance(0, 20))).
|
||||
setTimeWindow(TimeWindow.newInstance(30, 40)).build();
|
||||
|
||||
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(TestUtils.loc("vehLoc", Coordinate.newInstance(0, 0)))
|
||||
.setType(VehicleTypeImpl.Builder.newInstance("vType").build()).build();
|
||||
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
vrpBuilder.setActivityCosts(new VehicleRoutingActivityCosts() {
|
||||
|
||||
@Override
|
||||
public double getActivityCost(TourActivity tourAct, double arrivalTime, Driver driver, Vehicle vehicle) {
|
||||
double waiting = Math.max(0, tourAct.getTheoreticalEarliestOperationStartTime() - arrivalTime) * 1;
|
||||
double late = Math.max(0, arrivalTime - tourAct.getTheoreticalLatestOperationStartTime()) * 100;
|
||||
return waiting + late;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getActivityDuration(TourActivity tourAct, double arrivalTime, Driver driver, Vehicle vehicle) {
|
||||
return tourAct.getOperationTime();
|
||||
}
|
||||
|
||||
});
|
||||
VehicleRoutingProblem vrp = vrpBuilder.addJob(service).addJob(service2).addVehicle(vehicle).build();
|
||||
|
||||
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfigWithDepartureTimeChoice.xml");
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
Assert.assertEquals(40.0, Solutions.bestOf(solutions).getCost(), 0.1);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSettingTwoCustWithTWAndDepTimeChoice_depTimeShouldBe10() {
|
||||
TimeWindow timeWindow = TimeWindow.newInstance(40, 45);
|
||||
Service service = Service.Builder.newInstance("s").setLocation(TestUtils.loc("servLoc", Coordinate.newInstance(0, 10))).setTimeWindow(timeWindow).build();
|
||||
|
||||
Service service2 = Service.Builder.newInstance("s2").setLocation(TestUtils.loc("servLoc2", Coordinate.newInstance(0, 20))).
|
||||
setTimeWindow(TimeWindow.newInstance(30, 40)).build();
|
||||
|
||||
Vehicle vehicle = VehicleImpl.Builder.newInstance("v").setStartLocation(TestUtils.loc("vehLoc", Coordinate.newInstance(0, 0)))
|
||||
.setType(VehicleTypeImpl.Builder.newInstance("vType").build()).build();
|
||||
|
||||
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
vrpBuilder.setActivityCosts(new VehicleRoutingActivityCosts() {
|
||||
|
||||
@Override
|
||||
public double getActivityCost(TourActivity tourAct, double arrivalTime, Driver driver, Vehicle vehicle) {
|
||||
double waiting = Math.max(0, tourAct.getTheoreticalEarliestOperationStartTime() - arrivalTime) * 1;
|
||||
double late = Math.max(0, arrivalTime - tourAct.getTheoreticalLatestOperationStartTime()) * 100;
|
||||
return waiting + late;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getActivityDuration(TourActivity tourAct, double arrivalTime, Driver driver, Vehicle vehicle) {
|
||||
return tourAct.getOperationTime();
|
||||
}
|
||||
|
||||
});
|
||||
VehicleRoutingProblem vrp = vrpBuilder.addJob(service).addJob(service2).addVehicle(vehicle).build();
|
||||
|
||||
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "src/test/resources/algorithmConfigWithDepartureTimeChoice.xml");
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
Assert.assertEquals(10.0, Solutions.bestOf(solutions).getRoutes().iterator().next().getStart().getEndTime(), 0.1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,149 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2013 Stefan Schroeder
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package com.graphhopper.jsprit.core.util;
|
||||
|
||||
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
||||
import com.graphhopper.jsprit.core.problem.job.Delivery;
|
||||
import com.graphhopper.jsprit.core.problem.job.Pickup;
|
||||
import com.graphhopper.jsprit.core.problem.job.Service;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
|
||||
/**
|
||||
* Reader that reads Christophides, Mingozzi and Toth instances.
|
||||
* <p>
|
||||
* <p>Files and file-description can be found <a href="http://neo.lcc.uma.es/vrp/vrp-instances/capacitated-vrp-instances/">here</a>.
|
||||
*
|
||||
* @author stefan schroeder
|
||||
*/
|
||||
public class ChristofidesReader {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(ChristofidesReader.class);
|
||||
|
||||
private final VehicleRoutingProblem.Builder vrpBuilder;
|
||||
|
||||
private double coordProjectionFactor = 1;
|
||||
|
||||
private JobType jobType = JobType.SERVICE;
|
||||
|
||||
/**
|
||||
* Constructs the reader.
|
||||
*
|
||||
* @param vrpBuilder the builder
|
||||
*/
|
||||
public ChristofidesReader(VehicleRoutingProblem.Builder vrpBuilder) {
|
||||
super();
|
||||
this.vrpBuilder = vrpBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads instance-file and memorizes vehicles, customers and so forth in
|
||||
* {@link com.graphhopper.jsprit.core.problem.VehicleRoutingProblem.Builder}.
|
||||
*
|
||||
* @param inputStream
|
||||
*/
|
||||
public void read(InputStream inputStream) {
|
||||
vrpBuilder.setFleetSize(FleetSize.INFINITE);
|
||||
BufferedReader reader = getReader(inputStream);
|
||||
int vehicleCapacity = 0;
|
||||
double serviceTime = 0.0;
|
||||
double endTime = Double.MAX_VALUE;
|
||||
int counter = 0;
|
||||
String line;
|
||||
while ((line = readLine(reader)) != null) {
|
||||
line = line.replace("\r", "");
|
||||
line = line.trim();
|
||||
String[] tokens = line.split(" ");
|
||||
if (counter == 0) {
|
||||
vehicleCapacity = Integer.parseInt(tokens[1].trim());
|
||||
endTime = Double.parseDouble(tokens[2].trim());
|
||||
serviceTime = Double.parseDouble(tokens[3].trim());
|
||||
} else if (counter == 1) {
|
||||
Coordinate depotCoord = makeCoord(tokens[0].trim(), tokens[1].trim());
|
||||
VehicleTypeImpl vehicleType = VehicleTypeImpl.Builder.newInstance("christophidesType").addCapacityDimension(0, vehicleCapacity).
|
||||
setCostPerDistance(1.0).build();
|
||||
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("christophidesVehicle").setLatestArrival(endTime).setStartLocation(Location.newInstance(depotCoord.getX(), depotCoord.getY())).
|
||||
setType(vehicleType).build();
|
||||
vrpBuilder.addVehicle(vehicle);
|
||||
} else {
|
||||
Coordinate customerCoord = makeCoord(tokens[0].trim(), tokens[1].trim());
|
||||
int demand = Integer.parseInt(tokens[2].trim());
|
||||
String customer = Integer.valueOf(counter - 1).toString();
|
||||
if(jobType.equals(JobType.SERVICE)) {
|
||||
Service service = Service.Builder.newInstance(customer).addSizeDimension(0, demand).setServiceTime(serviceTime).setLocation(Location.newInstance(customerCoord.getX(), customerCoord.getY())).build();
|
||||
vrpBuilder.addJob(service);
|
||||
}
|
||||
else if(jobType.equals(JobType.DELIVERY)){
|
||||
Delivery service = Delivery.Builder.newInstance(customer).addSizeDimension(0, demand).setServiceTime(serviceTime).setLocation(Location.newInstance(customerCoord.getX(), customerCoord.getY())).build();
|
||||
vrpBuilder.addJob(service);
|
||||
}
|
||||
else if(jobType.equals(JobType.PICKUP)){
|
||||
Pickup service = Pickup.Builder.newInstance(customer).addSizeDimension(0, demand).setServiceTime(serviceTime).setLocation(Location.newInstance(customerCoord.getX(), customerCoord.getY())).build();
|
||||
vrpBuilder.addJob(service);
|
||||
}
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
close(reader);
|
||||
}
|
||||
|
||||
public void setCoordProjectionFactor(double coordProjectionFactor) {
|
||||
this.coordProjectionFactor = coordProjectionFactor;
|
||||
}
|
||||
|
||||
private void close(BufferedReader reader) {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private String readLine(BufferedReader reader) {
|
||||
try {
|
||||
return reader.readLine();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Coordinate makeCoord(String xString, String yString) {
|
||||
double x = Double.parseDouble(xString);
|
||||
double y = Double.parseDouble(yString);
|
||||
return new Coordinate(x * coordProjectionFactor, y * coordProjectionFactor);
|
||||
}
|
||||
|
||||
private BufferedReader getReader(InputStream inputStream) {
|
||||
return new BufferedReader(new InputStreamReader(inputStream));
|
||||
}
|
||||
|
||||
public ChristofidesReader setJobType(JobType jobType) {
|
||||
this.jobType = jobType;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.graphhopper.jsprit.core.util;
|
||||
|
||||
/**
|
||||
* Created by schroeder on 27/07/16.
|
||||
*/
|
||||
public enum JobType {
|
||||
|
||||
SERVICE, PICKUP, DELIVERY
|
||||
}
|
||||
|
|
@ -0,0 +1,197 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (C) 2013 Stefan Schroeder
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package com.graphhopper.jsprit.core.util;
|
||||
|
||||
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem.Builder;
|
||||
import com.graphhopper.jsprit.core.problem.job.Shipment;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* test instances for the capacitated vrp with pickup and deliveries and time windows.
|
||||
* instances are from li and lim and can be found at:
|
||||
* http://www.top.sintef.no/vrp/benchmarks.html
|
||||
*
|
||||
* @author stefan schroeder
|
||||
*/
|
||||
|
||||
|
||||
public class LiLimReader {
|
||||
|
||||
static class CustomerData {
|
||||
public Coordinate coord;
|
||||
public double start;
|
||||
public double end;
|
||||
public double serviceTime;
|
||||
|
||||
public CustomerData(Coordinate coord, double start, double end, double serviceTime) {
|
||||
super();
|
||||
this.coord = coord;
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
this.serviceTime = serviceTime;
|
||||
}
|
||||
}
|
||||
|
||||
static class Relation {
|
||||
public String from;
|
||||
public String to;
|
||||
public int demand;
|
||||
|
||||
public Relation(String from, String to, int demand) {
|
||||
super();
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
this.demand = demand;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(LiLimReader.class);
|
||||
|
||||
private Builder vrpBuilder;
|
||||
|
||||
private int vehicleCapacity;
|
||||
|
||||
private String depotId;
|
||||
|
||||
private Map<String, CustomerData> customers;
|
||||
|
||||
private Collection<Relation> relations;
|
||||
|
||||
private double depotOpeningTime;
|
||||
|
||||
private double depotClosingTime;
|
||||
|
||||
private int fixCosts = 0;
|
||||
|
||||
public LiLimReader(Builder vrpBuilder) {
|
||||
customers = new HashMap<String, CustomerData>();
|
||||
relations = new ArrayList<Relation>();
|
||||
this.vrpBuilder = vrpBuilder;
|
||||
}
|
||||
|
||||
public LiLimReader(Builder builder, int fixCosts) {
|
||||
customers = new HashMap<String, CustomerData>();
|
||||
relations = new ArrayList<Relation>();
|
||||
this.vrpBuilder = builder;
|
||||
this.fixCosts = fixCosts;
|
||||
}
|
||||
|
||||
public void read(InputStream inputStream) {
|
||||
readShipments(inputStream);
|
||||
buildShipments();
|
||||
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("type").addCapacityDimension(0, vehicleCapacity)
|
||||
.setCostPerDistance(1.0).setFixedCost(fixCosts).build();
|
||||
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("vehicle")
|
||||
.setEarliestStart(depotOpeningTime).setLatestArrival(depotClosingTime)
|
||||
.setStartLocation(Location.Builder.newInstance().setCoordinate(customers.get(depotId).coord).build()).setType(type).build();
|
||||
vrpBuilder.addVehicle(vehicle);
|
||||
}
|
||||
|
||||
private void buildShipments() {
|
||||
Integer counter = 0;
|
||||
for (Relation rel : relations) {
|
||||
counter++;
|
||||
String from = rel.from;
|
||||
String to = rel.to;
|
||||
int demand = rel.demand;
|
||||
Shipment s = Shipment.Builder.newInstance(counter.toString()).addSizeDimension(0, demand)
|
||||
.setPickupLocation(Location.Builder.newInstance().setCoordinate(customers.get(from).coord).build()).setPickupServiceTime(customers.get(from).serviceTime)
|
||||
.setPickupTimeWindow(TimeWindow.newInstance(customers.get(from).start, customers.get(from).end))
|
||||
.setDeliveryLocation(Location.Builder.newInstance().setCoordinate(customers.get(to).coord).build()).setDeliveryServiceTime(customers.get(to).serviceTime)
|
||||
.setDeliveryTimeWindow(TimeWindow.newInstance(customers.get(to).start, customers.get(to).end)).build();
|
||||
vrpBuilder.addJob(s);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private BufferedReader getReader(InputStream inputStream) {
|
||||
return new BufferedReader(new InputStreamReader(inputStream));
|
||||
}
|
||||
|
||||
private void readShipments(InputStream inputStream) {
|
||||
BufferedReader reader = getReader(inputStream);
|
||||
String line = null;
|
||||
boolean firstLine = true;
|
||||
try {
|
||||
while ((line = reader.readLine()) != null) {
|
||||
line = line.replace("\r", "");
|
||||
line = line.trim();
|
||||
String[] tokens = line.split("\t");
|
||||
if (firstLine) {
|
||||
int vehicleCapacity = getInt(tokens[1]);
|
||||
this.vehicleCapacity = vehicleCapacity;
|
||||
firstLine = false;
|
||||
continue;
|
||||
} else {
|
||||
String customerId = tokens[0];
|
||||
Coordinate coord = makeCoord(tokens[1], tokens[2]);
|
||||
int demand = getInt(tokens[3]);
|
||||
double startTimeWindow = getDouble(tokens[4]);
|
||||
double endTimeWindow = getDouble(tokens[5]);
|
||||
double serviceTime = getDouble(tokens[6]);
|
||||
// vrpBuilder.addLocation(customerId, coord);
|
||||
customers.put(customerId, new CustomerData(coord, startTimeWindow, endTimeWindow, serviceTime));
|
||||
if (customerId.equals("0")) {
|
||||
depotId = customerId;
|
||||
depotOpeningTime = startTimeWindow;
|
||||
depotClosingTime = endTimeWindow;
|
||||
}
|
||||
if (demand > 0) {
|
||||
relations.add(new Relation(customerId, tokens[8], demand));
|
||||
}
|
||||
}
|
||||
}
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Coordinate makeCoord(String xString, String yString) {
|
||||
double x = Double.parseDouble(xString);
|
||||
double y = Double.parseDouble(yString);
|
||||
return new Coordinate(x, y);
|
||||
}
|
||||
|
||||
private double getDouble(String string) {
|
||||
return Double.parseDouble(string);
|
||||
}
|
||||
|
||||
private int getInt(String string) {
|
||||
return Integer.parseInt(string);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
/*******************************************************************************
|
||||
* 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.util;
|
||||
|
||||
|
||||
import com.graphhopper.jsprit.core.problem.Location;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem;
|
||||
import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
||||
import com.graphhopper.jsprit.core.problem.job.Service;
|
||||
import com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import com.graphhopper.jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
|
||||
/**
|
||||
* Reader that reads the well-known solomon-instances.
|
||||
* <p>
|
||||
* <p>See: <a href="http://neo.lcc.uma.es/vrp/vrp-instances/capacitated-vrp-with-time-windows-instances/">neo.org</a>
|
||||
*
|
||||
* @author stefan
|
||||
*/
|
||||
|
||||
public class SolomonReader {
|
||||
|
||||
/**
|
||||
* @param costProjectionFactor the costProjectionFactor to set
|
||||
*/
|
||||
public void setVariableCostProjectionFactor(double costProjectionFactor) {
|
||||
this.variableCostProjectionFactor = costProjectionFactor;
|
||||
}
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(SolomonReader.class);
|
||||
|
||||
private final VehicleRoutingProblem.Builder vrpBuilder;
|
||||
|
||||
private double coordProjectionFactor = 1;
|
||||
|
||||
private double timeProjectionFactor = 1;
|
||||
|
||||
private double variableCostProjectionFactor = 1;
|
||||
|
||||
private double fixedCostPerVehicle = 0.0;
|
||||
|
||||
public SolomonReader(VehicleRoutingProblem.Builder vrpBuilder) {
|
||||
super();
|
||||
this.vrpBuilder = vrpBuilder;
|
||||
}
|
||||
|
||||
public SolomonReader(VehicleRoutingProblem.Builder vrpBuilder, double fixedCostPerVehicle) {
|
||||
super();
|
||||
this.vrpBuilder = vrpBuilder;
|
||||
this.fixedCostPerVehicle = fixedCostPerVehicle;
|
||||
}
|
||||
|
||||
public void read(InputStream inputStream) {
|
||||
vrpBuilder.setFleetSize(FleetSize.INFINITE);
|
||||
BufferedReader reader = getReader(inputStream);
|
||||
int vehicleCapacity = 0;
|
||||
|
||||
int counter = 0;
|
||||
String line;
|
||||
while ((line = readLine(reader)) != null) {
|
||||
line = line.replace("\r", "");
|
||||
line = line.trim();
|
||||
String[] tokens = line.split(" +");
|
||||
counter++;
|
||||
if (counter == 5) {
|
||||
vehicleCapacity = Integer.parseInt(tokens[1]);
|
||||
continue;
|
||||
}
|
||||
if (counter > 9) {
|
||||
if (tokens.length < 7) continue;
|
||||
Coordinate coord = makeCoord(tokens[1], tokens[2]);
|
||||
String customerId = tokens[0];
|
||||
int demand = Integer.parseInt(tokens[3]);
|
||||
double start = Double.parseDouble(tokens[4]) * timeProjectionFactor;
|
||||
double end = Double.parseDouble(tokens[5]) * timeProjectionFactor;
|
||||
double serviceTime = Double.parseDouble(tokens[6]) * timeProjectionFactor;
|
||||
if (counter == 10) {
|
||||
VehicleTypeImpl.Builder typeBuilder = VehicleTypeImpl.Builder.newInstance("solomonType").addCapacityDimension(0, vehicleCapacity);
|
||||
typeBuilder.setCostPerDistance(1.0 * variableCostProjectionFactor).setFixedCost(fixedCostPerVehicle);
|
||||
VehicleTypeImpl vehicleType = typeBuilder.build();
|
||||
|
||||
VehicleImpl vehicle = VehicleImpl.Builder.newInstance("solomonVehicle").setEarliestStart(start).setLatestArrival(end)
|
||||
.setStartLocation(Location.Builder.newInstance().setId(customerId)
|
||||
.setCoordinate(coord).build()).setType(vehicleType).build();
|
||||
vrpBuilder.addVehicle(vehicle);
|
||||
|
||||
} else {
|
||||
Service service = Service.Builder.newInstance(customerId).addSizeDimension(0, demand)
|
||||
.setLocation(Location.Builder.newInstance().setCoordinate(coord).setId(customerId).build()).setServiceTime(serviceTime)
|
||||
.setTimeWindow(TimeWindow.newInstance(start, end)).build();
|
||||
vrpBuilder.addJob(service);
|
||||
}
|
||||
}
|
||||
}
|
||||
close(reader);
|
||||
}
|
||||
|
||||
public void setCoordProjectionFactor(double coordProjectionFactor) {
|
||||
this.coordProjectionFactor = coordProjectionFactor;
|
||||
}
|
||||
|
||||
private void close(BufferedReader reader) {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private String readLine(BufferedReader reader) {
|
||||
try {
|
||||
return reader.readLine();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Coordinate makeCoord(String xString, String yString) {
|
||||
double x = Double.parseDouble(xString);
|
||||
double y = Double.parseDouble(yString);
|
||||
return new Coordinate(x * coordProjectionFactor, y * coordProjectionFactor);
|
||||
}
|
||||
|
||||
private BufferedReader getReader(InputStream inputStream) {
|
||||
return new BufferedReader(new InputStreamReader(inputStream));
|
||||
}
|
||||
|
||||
public void setTimeProjectionFactor(double timeProjection) {
|
||||
this.timeProjectionFactor = timeProjection;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
C101
|
||||
|
||||
VEHICLE
|
||||
NUMBER CAPACITY
|
||||
25 200
|
||||
|
||||
CUSTOMER
|
||||
CUST NO. XCOORD. YCOORD. DEMAND READY TIME DUE DATE SERVICE TIME
|
||||
|
||||
0 40 50 0 0 1236 0
|
||||
1 45 68 10 912 967 90
|
||||
2 45 70 30 825 870 90
|
||||
3 42 66 10 65 146 90
|
||||
4 42 68 10 727 782 90
|
||||
5 42 65 10 15 67 90
|
||||
6 40 69 20 621 702 90
|
||||
7 40 66 20 170 225 90
|
||||
8 38 68 20 255 324 90
|
||||
9 38 70 10 534 605 90
|
||||
10 35 66 10 357 410 90
|
||||
11 35 69 10 448 505 90
|
||||
12 25 85 20 652 721 90
|
||||
13 22 75 30 30 92 90
|
||||
14 22 85 10 567 620 90
|
||||
15 20 80 40 384 429 90
|
||||
16 20 85 40 475 528 90
|
||||
17 18 75 20 99 148 90
|
||||
18 15 75 20 179 254 90
|
||||
19 15 80 10 278 345 90
|
||||
20 30 50 10 10 73 90
|
||||
21 30 52 20 914 965 90
|
||||
22 28 52 20 812 883 90
|
||||
23 28 55 10 732 777 90
|
||||
24 25 50 10 65 144 90
|
||||
25 25 52 40 169 224 90
|
||||
26 25 55 10 622 701 90
|
||||
27 23 52 10 261 316 90
|
||||
28 23 55 20 546 593 90
|
||||
29 20 50 10 358 405 90
|
||||
30 20 55 10 449 504 90
|
||||
31 10 35 20 200 237 90
|
||||
32 10 40 30 31 100 90
|
||||
33 8 40 40 87 158 90
|
||||
34 8 45 20 751 816 90
|
||||
35 5 35 10 283 344 90
|
||||
36 5 45 10 665 716 90
|
||||
37 2 40 20 383 434 90
|
||||
38 0 40 30 479 522 90
|
||||
39 0 45 20 567 624 90
|
||||
40 35 30 10 264 321 90
|
||||
41 35 32 10 166 235 90
|
||||
42 33 32 20 68 149 90
|
||||
43 33 35 10 16 80 90
|
||||
44 32 30 10 359 412 90
|
||||
45 30 30 10 541 600 90
|
||||
46 30 32 30 448 509 90
|
||||
47 30 35 10 1054 1127 90
|
||||
48 28 30 10 632 693 90
|
||||
49 28 35 10 1001 1066 90
|
||||
50 26 32 10 815 880 90
|
||||
51 25 30 10 725 786 90
|
||||
52 25 35 10 912 969 90
|
||||
53 44 5 20 286 347 90
|
||||
54 42 10 40 186 257 90
|
||||
55 42 15 10 95 158 90
|
||||
56 40 5 30 385 436 90
|
||||
57 40 15 40 35 87 90
|
||||
58 38 5 30 471 534 90
|
||||
59 38 15 10 651 740 90
|
||||
60 35 5 20 562 629 90
|
||||
61 50 30 10 531 610 90
|
||||
62 50 35 20 262 317 90
|
||||
63 50 40 50 171 218 90
|
||||
64 48 30 10 632 693 90
|
||||
65 48 40 10 76 129 90
|
||||
66 47 35 10 826 875 90
|
||||
67 47 40 10 12 77 90
|
||||
68 45 30 10 734 777 90
|
||||
69 45 35 10 916 969 90
|
||||
70 95 30 30 387 456 90
|
||||
71 95 35 20 293 360 90
|
||||
72 53 30 10 450 505 90
|
||||
73 92 30 10 478 551 90
|
||||
74 53 35 50 353 412 90
|
||||
75 45 65 20 997 1068 90
|
||||
76 90 35 10 203 260 90
|
||||
77 88 30 10 574 643 90
|
||||
78 88 35 20 109 170 90
|
||||
79 87 30 10 668 731 90
|
||||
80 85 25 10 769 820 90
|
||||
81 85 35 30 47 124 90
|
||||
82 75 55 20 369 420 90
|
||||
83 72 55 10 265 338 90
|
||||
84 70 58 20 458 523 90
|
||||
85 68 60 30 555 612 90
|
||||
86 66 55 10 173 238 90
|
||||
87 65 55 20 85 144 90
|
||||
88 65 60 30 645 708 90
|
||||
89 63 58 10 737 802 90
|
||||
90 60 55 10 20 84 90
|
||||
91 60 60 10 836 889 90
|
||||
92 67 85 20 368 441 90
|
||||
93 65 85 40 475 518 90
|
||||
94 65 82 10 285 336 90
|
||||
95 62 80 30 196 239 90
|
||||
96 60 80 10 95 156 90
|
||||
97 60 85 30 561 622 90
|
||||
98 58 75 20 30 84 90
|
||||
99 55 80 10 743 820 90
|
||||
100 55 85 20 647 726 90
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
25 200 1
|
||||
0 35 35 0 0 230 0 0 0
|
||||
1 41 49 -25 161 171 10 66 0
|
||||
2 35 17 7 50 60 10 0 73
|
||||
3 55 45 -6 116 126 10 69 0
|
||||
4 55 20 -6 149 159 10 56 0
|
||||
5 15 30 26 34 44 10 0 85
|
||||
6 25 30 -9 99 109 10 52 0
|
||||
7 20 50 -9 81 91 10 88 0
|
||||
8 10 43 9 95 105 10 0 17
|
||||
9 55 60 -21 97 107 10 30 0
|
||||
10 30 60 -27 124 134 10 31 0
|
||||
11 20 65 12 67 77 10 0 20
|
||||
12 50 35 -16 63 73 10 28 0
|
||||
13 30 25 -7 159 169 10 43 0
|
||||
14 15 10 20 32 42 10 0 38
|
||||
15 30 5 8 61 71 10 0 97
|
||||
16 10 20 19 75 85 10 0 91
|
||||
17 5 30 -9 157 167 10 8 0
|
||||
18 20 40 12 87 97 10 0 89
|
||||
19 15 60 -5 76 86 10 36 0
|
||||
20 45 65 -12 126 136 10 11 0
|
||||
21 45 20 11 62 72 10 0 41
|
||||
22 45 10 -18 97 107 10 75 0
|
||||
23 55 5 29 68 78 0 0 104
|
||||
24 65 35 3 153 163 10 0 80
|
||||
25 65 20 -2 172 182 10 55 0
|
||||
26 45 30 -9 132 142 10 40 0
|
||||
27 35 40 16 37 47 10 0 79
|
||||
28 41 37 16 39 49 10 0 12
|
||||
29 64 42 9 63 73 10 0 78
|
||||
30 40 60 21 71 81 10 0 9
|
||||
31 31 52 27 50 60 10 0 10
|
||||
32 35 69 -3 141 151 10 90 0
|
||||
33 53 52 11 37 47 10 0 34
|
||||
34 65 55 -11 117 127 10 33 0
|
||||
35 63 65 8 143 153 10 0 77
|
||||
36 2 60 5 41 51 10 0 19
|
||||
37 20 20 -11 134 144 10 83 0
|
||||
38 5 5 -20 83 93 10 14 0
|
||||
39 60 12 31 44 54 10 0 67
|
||||
40 40 25 9 85 95 10 0 26
|
||||
41 42 7 -11 97 107 10 21 0
|
||||
42 24 12 5 31 41 10 0 87
|
||||
43 23 3 7 132 142 10 0 13
|
||||
44 11 14 18 69 79 0 0 105
|
||||
45 6 38 16 32 42 10 0 84
|
||||
46 2 48 -27 117 127 10 47 0
|
||||
47 8 56 27 51 61 10 0 46
|
||||
48 13 52 -9 165 175 10 64 0
|
||||
49 6 68 -10 108 118 10 63 0
|
||||
50 47 47 -15 124 134 10 71 0
|
||||
51 49 58 10 88 98 0 0 101
|
||||
52 27 43 9 52 62 10 0 6
|
||||
53 37 31 14 95 105 0 0 106
|
||||
54 57 29 -13 140 150 10 76 0
|
||||
55 63 23 2 136 146 10 0 25
|
||||
56 53 12 6 130 140 10 0 4
|
||||
57 32 12 -2 101 111 10 92 0
|
||||
58 36 26 -25 200 210 10 72 0
|
||||
59 21 24 28 18 28 10 0 96
|
||||
60 17 34 -16 162 172 10 82 0
|
||||
61 12 24 13 76 86 10 0 93
|
||||
62 24 58 19 58 68 10 0 70
|
||||
63 27 69 10 34 44 10 0 49
|
||||
64 15 77 9 73 83 10 0 48
|
||||
65 62 77 20 51 61 10 0 81
|
||||
66 49 73 25 127 137 10 0 1
|
||||
67 67 5 -31 83 93 10 39 0
|
||||
68 56 39 36 142 152 0 0 103
|
||||
69 37 47 6 50 60 10 0 3
|
||||
70 37 56 -19 182 192 10 62 0
|
||||
71 57 68 15 77 87 10 0 50
|
||||
72 47 16 25 35 45 10 0 58
|
||||
73 44 17 -7 78 88 10 2 0
|
||||
74 46 13 8 149 159 0 0 102
|
||||
75 49 11 18 69 79 10 0 22
|
||||
76 49 42 13 73 83 10 0 54
|
||||
77 53 43 -8 179 189 10 35 0
|
||||
78 61 52 -9 96 106 10 29 0
|
||||
79 57 48 -16 92 102 10 27 0
|
||||
80 56 37 -3 182 192 10 24 0
|
||||
81 55 54 -20 94 104 10 65 0
|
||||
82 15 47 16 55 65 10 0 60
|
||||
83 14 37 11 44 54 10 0 37
|
||||
84 11 31 -16 101 111 10 45 0
|
||||
85 16 22 -26 91 101 10 5 0
|
||||
86 4 18 -10 94 104 10 98 0
|
||||
87 28 18 -5 93 103 10 42 0
|
||||
88 26 52 9 74 84 10 0 7
|
||||
89 26 35 -12 176 186 10 18 0
|
||||
90 31 67 3 95 105 10 0 32
|
||||
91 15 19 -19 160 170 10 16 0
|
||||
92 22 22 2 18 28 10 0 57
|
||||
93 18 24 -13 188 198 10 61 0
|
||||
94 26 27 -9 100 110 10 99 0
|
||||
95 25 24 20 39 49 10 0 100
|
||||
96 22 27 -28 135 145 10 59 0
|
||||
97 25 21 -8 133 143 10 15 0
|
||||
98 19 21 10 58 68 10 0 86
|
||||
99 20 26 9 83 93 10 0 94
|
||||
100 18 18 -20 185 195 10 95 0
|
||||
101 49 58 -10 88 98 10 51 0
|
||||
102 46 13 -8 149 159 10 74 0
|
||||
103 56 39 -36 142 152 10 68 0
|
||||
104 55 5 -29 68 78 10 23 0
|
||||
105 11 14 -18 69 79 10 44 0
|
||||
106 37 31 -14 95 105 10 53 0
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
0 0 0.0 0.0
|
||||
0 1 7641.0 394.0
|
||||
0 2 7244.0 370.0
|
||||
0 3 15236.0 747.0
|
||||
0 4 7841.0 452.0
|
||||
0 5 7013.0 388.0
|
||||
0 6 3336.0 232.0
|
||||
0 7 6729.0 364.0
|
||||
0 8 22401.0 918.0
|
||||
0 9 16830.0 772.0
|
||||
0 10 8311.0 434.0
|
||||
1 0 7463.0 381.0
|
||||
1 1 0.0 0.0
|
||||
1 2 1605.0 90.0
|
||||
1 3 8336.0 380.0
|
||||
1 4 4949.0 304.0
|
||||
1 5 3632.0 221.0
|
||||
1 6 5611.0 324.0
|
||||
1 7 3407.0 212.0
|
||||
1 8 29674.0 1216.0
|
||||
1 9 9378.0 513.0
|
||||
1 10 633.0 42.0
|
||||
2 0 5857.0 291.0
|
||||
2 1 1366.0 78.0
|
||||
2 2 0.0 0.0
|
||||
2 3 8961.0 431.0
|
||||
2 4 5346.0 325.0
|
||||
2 5 1994.0 144.0
|
||||
2 6 4006.0 234.0
|
||||
2 7 1802.0 122.0
|
||||
2 8 28069.0 1126.0
|
||||
2 9 9809.0 536.0
|
||||
2 10 2035.0 118.0
|
||||
3 0 15179.0 645.0
|
||||
3 1 7322.0 329.0
|
||||
3 2 7534.0 364.0
|
||||
3 3 0.0 0.0
|
||||
3 4 10908.0 483.0
|
||||
3 5 9605.0 470.0
|
||||
3 6 13327.0 588.0
|
||||
3 7 9336.0 486.0
|
||||
3 8 36409.0 1438.0
|
||||
3 9 4130.0 236.0
|
||||
3 10 6404.0 321.0
|
||||
4 0 7652.0 457.0
|
||||
4 1 4611.0 288.0
|
||||
4 2 4948.0 303.0
|
||||
4 3 10982.0 539.0
|
||||
4 4 0.0 0.0
|
||||
4 5 6942.0 447.0
|
||||
4 6 6199.0 415.0
|
||||
4 7 6750.0 425.0
|
||||
4 8 29970.0 1270.0
|
||||
4 9 10932.0 566.0
|
||||
4 10 4384.0 277.0
|
||||
5 0 4845.0 284.0
|
||||
5 1 3010.0 187.0
|
||||
5 2 2612.0 163.0
|
||||
5 3 10784.0 530.0
|
||||
5 4 6990.0 435.0
|
||||
5 5 0.0 0.0
|
||||
5 6 2964.0 219.0
|
||||
5 7 819.0 68.0
|
||||
5 8 27332.0 1124.0
|
||||
5 9 13064.0 615.0
|
||||
5 10 3679.0 227.0
|
||||
6 0 2952.0 209.0
|
||||
6 1 5089.0 297.0
|
||||
6 2 4691.0 273.0
|
||||
6 3 12684.0 650.0
|
||||
6 4 6489.0 430.0
|
||||
6 5 4460.0 291.0
|
||||
6 6 0.0 0.0
|
||||
6 7 4176.0 267.0
|
||||
6 8 25472.0 1083.0
|
||||
6 9 14278.0 675.0
|
||||
6 10 5758.0 337.0
|
||||
7 0 4334.0 253.0
|
||||
7 1 2956.0 182.0
|
||||
7 2 2559.0 158.0
|
||||
7 3 10551.0 535.0
|
||||
7 4 6936.0 429.0
|
||||
7 5 2081.0 162.0
|
||||
7 6 2453.0 188.0
|
||||
7 7 0.0 0.0
|
||||
7 8 26821.0 1092.0
|
||||
7 9 13010.0 610.0
|
||||
7 10 3625.0 222.0
|
||||
8 0 22667.0 926.0
|
||||
8 1 29281.0 1189.0
|
||||
8 2 28884.0 1165.0
|
||||
8 3 37504.0 1484.0
|
||||
8 4 29608.0 1240.0
|
||||
8 5 28008.0 1174.0
|
||||
8 6 25198.0 1063.0
|
||||
8 7 27518.0 1151.0
|
||||
8 8 0.0 0.0
|
||||
8 9 36799.0 1529.0
|
||||
8 10 29950.0 1230.0
|
||||
9 0 15604.0 722.0
|
||||
9 1 8945.0 492.0
|
||||
9 2 9283.0 507.0
|
||||
9 3 3730.0 212.0
|
||||
9 4 11018.0 594.0
|
||||
9 5 12864.0 633.0
|
||||
9 6 13753.0 665.0
|
||||
9 7 12558.0 607.0
|
||||
9 8 36821.0 1553.0
|
||||
9 9 0.0 0.0
|
||||
9 10 8307.0 472.0
|
||||
10 0 7591.0 404.0
|
||||
10 1 1117.0 81.0
|
||||
10 2 1733.0 113.0
|
||||
10 3 7844.0 354.0
|
||||
10 4 5077.0 327.0
|
||||
10 5 3914.0 243.0
|
||||
10 6 5739.0 347.0
|
||||
10 7 3535.0 235.0
|
||||
10 8 29802.0 1239.0
|
||||
10 9 8906.0 493.0
|
||||
10 10 0.0 0.0
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
50 160 999999 0
|
||||
30 40
|
||||
37 52 7
|
||||
49 49 30
|
||||
52 64 16
|
||||
20 26 9
|
||||
40 30 21
|
||||
21 47 15
|
||||
17 63 19
|
||||
31 62 23
|
||||
52 33 11
|
||||
51 21 5
|
||||
42 41 19
|
||||
31 32 29
|
||||
5 25 23
|
||||
12 42 21
|
||||
36 16 10
|
||||
52 41 15
|
||||
27 23 3
|
||||
17 33 41
|
||||
13 13 9
|
||||
57 58 28
|
||||
62 42 8
|
||||
42 57 8
|
||||
16 57 16
|
||||
8 52 10
|
||||
7 38 28
|
||||
27 68 7
|
||||
30 48 15
|
||||
43 67 14
|
||||
58 48 6
|
||||
58 27 19
|
||||
37 69 11
|
||||
38 46 12
|
||||
46 10 23
|
||||
61 33 26
|
||||
62 63 17
|
||||
63 69 6
|
||||
32 22 9
|
||||
45 35 15
|
||||
59 15 14
|
||||
5 6 7
|
||||
10 17 27
|
||||
21 10 13
|
||||
5 64 11
|
||||
30 15 16
|
||||
39 10 10
|
||||
32 39 5
|
||||
25 32 25
|
||||
25 55 17
|
||||
48 28 18
|
||||
56 37 10
|
||||
|
|
@ -77,7 +77,7 @@
|
|||
<timeWindows>
|
||||
<timeWindow>
|
||||
<start>54000.0</start>
|
||||
<end>64800.0</end>
|
||||
<end>54000.0</end>
|
||||
</timeWindow>
|
||||
</timeWindows>
|
||||
</service>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue