mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
prepare for release v0.1.0
This commit is contained in:
parent
77d38de461
commit
a85b0fc395
304 changed files with 4035 additions and 64795 deletions
|
|
@ -1,48 +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 algorithms;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
|
||||
import algorithms.acceptors.AcceptNewRemoveWorstTest;
|
||||
import algorithms.selectors.SelectBestTest;
|
||||
import algorithms.selectors.SelectRandomlyTest;
|
||||
|
||||
|
||||
|
||||
@RunWith(Suite.class)
|
||||
@Suite.SuiteClasses({
|
||||
CalcVehicleTypeDependentServiceInsertionTest.class,
|
||||
// FindCheaperVehicleTest.class,
|
||||
GendreauPostOptTest.class,
|
||||
TestAlgorithmReader.class,
|
||||
// TestAux.class,
|
||||
TestCalculatesServiceInsertion.class,
|
||||
TestCalculatesServiceInsertionOnRouteLevel.class,
|
||||
TestSchrimpf.class,
|
||||
|
||||
TestJobDistanceAvgCosts.class,
|
||||
TestTourStateUpdaterWithService.class,
|
||||
|
||||
SelectBestTest.class,
|
||||
SelectRandomlyTest.class,
|
||||
AcceptNewRemoveWorstTest.class,
|
||||
// TestUpdateTourStatesForwardInTime.class
|
||||
|
||||
})
|
||||
public class AlgorithmsSuite {}
|
||||
|
|
@ -1,137 +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 algorithms;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import util.Solutions;
|
||||
import algorithms.acceptors.AcceptNewIfBetterThanWorst;
|
||||
import algorithms.selectors.SelectBest;
|
||||
import basics.VehicleRoutingAlgorithm;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblemSolution;
|
||||
import basics.algo.IterationStartsListener;
|
||||
import basics.algo.SearchStrategy;
|
||||
import basics.algo.SearchStrategyManager;
|
||||
import basics.algo.SolutionCostCalculator;
|
||||
import basics.io.VrpXMLReader;
|
||||
import basics.route.InfiniteFleetManagerFactory;
|
||||
import basics.route.TourActivity;
|
||||
import basics.route.VehicleFleetManager;
|
||||
import basics.route.VehicleRoute;
|
||||
|
||||
public class BuildCVRPAlgoFromScratchTest {
|
||||
|
||||
VehicleRoutingProblem vrp;
|
||||
|
||||
VehicleRoutingAlgorithm vra;
|
||||
|
||||
@Before
|
||||
public void setup(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder).read("src/test/resources/vrpnc1-jsprit.xml");
|
||||
vrp = builder.build();
|
||||
|
||||
final StateManager stateManager = new StateManager();
|
||||
HardActivityStateLevelConstraint hardActLevelConstraint = new HardActivityStateLevelConstraint() {
|
||||
|
||||
@Override
|
||||
public ConstraintsStatus fulfilled(InsertionContext iFacts, TourActivity prevAct, TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
|
||||
return ConstraintsStatus.FULFILLED;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ActivityInsertionCostsCalculator marginalCalculus = new LocalActivityInsertionCostsCalculator(vrp.getTransportCosts(), vrp.getActivityCosts());
|
||||
|
||||
ServiceInsertionCalculator serviceInsertion = new ServiceInsertionCalculator(vrp.getTransportCosts(), marginalCalculus, new LoadConstraint(stateManager), hardActLevelConstraint);
|
||||
|
||||
|
||||
|
||||
VehicleFleetManager fleetManager = new InfiniteFleetManagerFactory(vrp.getVehicles()).createFleetManager();
|
||||
JobInsertionCostsCalculator finalServiceInsertion = new VehicleTypeDependentJobInsertionCalculator(fleetManager, serviceInsertion);
|
||||
|
||||
BestInsertion bestInsertion = new BestInsertion(finalServiceInsertion);
|
||||
|
||||
RuinRadial radial = new RuinRadial(vrp, 0.15, new JobDistanceAvgCosts(vrp.getTransportCosts()));
|
||||
RuinRandom random = new RuinRandom(vrp, 0.25);
|
||||
|
||||
SolutionCostCalculator solutionCostCalculator = new SolutionCostCalculator() {
|
||||
|
||||
@Override
|
||||
public double getCosts(VehicleRoutingProblemSolution solution) {
|
||||
double costs = 0.0;
|
||||
for(VehicleRoute route : solution.getRoutes()){
|
||||
costs += stateManager.getRouteState(route, StateFactory.COSTS).toDouble();
|
||||
}
|
||||
return costs;
|
||||
}
|
||||
};
|
||||
|
||||
SearchStrategy randomStrategy = new SearchStrategy(new SelectBest(), new AcceptNewIfBetterThanWorst(1), solutionCostCalculator);
|
||||
RuinAndRecreateModule randomModule = new RuinAndRecreateModule("randomRuin_bestInsertion", bestInsertion, random);
|
||||
randomStrategy.addModule(randomModule);
|
||||
|
||||
SearchStrategy radialStrategy = new SearchStrategy(new SelectBest(), new AcceptNewIfBetterThanWorst(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);
|
||||
|
||||
vra = new VehicleRoutingAlgorithm(vrp, strategyManager);
|
||||
|
||||
//listeners
|
||||
IterationStartsListener clearStateManager = new IterationStartsListener() {
|
||||
|
||||
@Override
|
||||
public void informIterationStarts(int i, VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) {
|
||||
stateManager.clear();
|
||||
}
|
||||
};
|
||||
vra.getAlgorithmListeners().addListener(clearStateManager);
|
||||
vra.getSearchStrategyManager().addSearchStrategyModuleListener(new RemoveEmptyVehicles(fleetManager));
|
||||
|
||||
vra.getSearchStrategyManager().addSearchStrategyModuleListener(new UpdateCostsAtRouteLevel(stateManager, vrp.getTransportCosts(), vrp.getActivityCosts()));
|
||||
vra.getSearchStrategyManager().addSearchStrategyModuleListener(new UpdateLoadAtRouteLevel(stateManager));
|
||||
|
||||
|
||||
VehicleRoutingProblemSolution iniSolution = new InsertionInitialSolutionFactory(bestInsertion, solutionCostCalculator).createSolution(vrp);
|
||||
|
||||
// System.out.println("ini: costs="+iniSolution.getCost()+";#routes="+iniSolution.getRoutes().size());
|
||||
vra.addInitialSolution(iniSolution);
|
||||
|
||||
vra.setNuOfIterations(2000);
|
||||
// vra.setPrematureBreak(200);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVRA(){
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
System.out.println("costs="+Solutions.getBest(solutions).getCost()+";#routes="+Solutions.getBest(solutions).getRoutes().size());
|
||||
assertEquals(530.0, Solutions.getBest(solutions).getCost(),15.0);
|
||||
assertEquals(5, Solutions.getBest(solutions).getRoutes().size());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,262 +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 algorithms;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import util.Solutions;
|
||||
import algorithms.acceptors.AcceptNewIfBetterThanWorst;
|
||||
import algorithms.selectors.SelectBest;
|
||||
import basics.Job;
|
||||
import basics.Service;
|
||||
import basics.Shipment;
|
||||
import basics.VehicleRoutingAlgorithm;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblemSolution;
|
||||
import basics.algo.InsertionStartsListener;
|
||||
import basics.algo.JobInsertedListener;
|
||||
import basics.algo.SearchStrategy;
|
||||
import basics.algo.SearchStrategyManager;
|
||||
import basics.algo.SolutionCostCalculator;
|
||||
import basics.io.VrpXMLReader;
|
||||
import basics.io.VrpXMLWriter;
|
||||
import basics.route.InfiniteFleetManagerFactory;
|
||||
import basics.route.ReverseRouteActivityVisitor;
|
||||
import basics.route.RouteActivityVisitor;
|
||||
import basics.route.VehicleFleetManager;
|
||||
import basics.route.VehicleRoute;
|
||||
|
||||
public class BuildPDVRPWithShipmentsAlgoFromScratchTest {
|
||||
|
||||
VehicleRoutingProblem vrp;
|
||||
|
||||
VehicleRoutingAlgorithm vra;
|
||||
|
||||
static Logger log = Logger.getLogger(BuildPDVRPWithShipmentsAlgoFromScratchTest.class);
|
||||
|
||||
ExecutorService executorService;
|
||||
|
||||
@Before
|
||||
public void setup(){
|
||||
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder).read("src/test/resources/pdp.xml");
|
||||
// VehicleType type = VehicleTypeImpl.Builder.newInstance("t", 2).setCostPerDistance(1.0).build();
|
||||
// Vehicle v = VehicleImpl.Builder.newInstance("v").setLocationCoord(Coordinate.newInstance(-1, -1)).setType(type).build();
|
||||
//
|
||||
// Shipment s1 = Shipment.Builder.newInstance("s1", 1).setPickupCoord(Coordinate.newInstance(0, 0)).setDeliveryCoord(Coordinate.newInstance(10, 10)).build();
|
||||
// Shipment s2 = Shipment.Builder.newInstance("s2", 1).setPickupCoord(Coordinate.newInstance(1, 1)).setDeliveryCoord(Coordinate.newInstance(10, 10)).build();
|
||||
//
|
||||
// Service serv1 = Service.Builder.newInstance("serv1", 1).setCoord(Coordinate.newInstance(0, 5)).build();
|
||||
// Service serv2 = Service.Builder.newInstance("serv2", 1).setCoord(Coordinate.newInstance(5, 0)).build();
|
||||
//
|
||||
// builder.addJob(s1).addJob(s2).addJob(serv1).addJob(serv2);
|
||||
// builder.addVehicle(v);
|
||||
|
||||
vrp = builder.build();
|
||||
|
||||
final StateManager stateManager = new StateManager();
|
||||
|
||||
ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager);
|
||||
constraintManager.addTimeWindowConstraint();
|
||||
constraintManager.addLoadConstraint();
|
||||
// constraintManager.addConstraint(new HardPickupAndDeliveryShipmentActivityLevelConstraint(stateManager));
|
||||
|
||||
VehicleFleetManager fleetManager = new InfiniteFleetManagerFactory(vrp.getVehicles()).createFleetManager();
|
||||
|
||||
int nuOfThreads = 10;
|
||||
executorService = Executors.newFixedThreadPool(nuOfThreads);
|
||||
|
||||
BestInsertionBuilder bestIBuilder = new BestInsertionBuilder(vrp, fleetManager, stateManager,constraintManager);
|
||||
|
||||
bestIBuilder.setConcurrentMode(executorService, nuOfThreads);
|
||||
InsertionStrategy bestInsertion = bestIBuilder.build();
|
||||
|
||||
// bestIBuilder.
|
||||
|
||||
// ActivityInsertionCostsCalculator marginalCalculus = new LocalActivityInsertionCostsCalculator(vrp.getTransportCosts(), vrp.getActivityCosts());
|
||||
//
|
||||
// ShipmentInsertionCalculator shipmentInsertion = new ShipmentInsertionCalculator(vrp.getTransportCosts(), marginalCalculus, constraintManager, constraintManager);
|
||||
//
|
||||
// ServiceInsertionCalculator serviceInsertion = new ServiceInsertionCalculator(vrp.getTransportCosts(), marginalCalculus, constraintManager, constraintManager);
|
||||
//
|
||||
// JobCalculatorSwitcher switcher = new JobCalculatorSwitcher();
|
||||
// switcher.put(Shipment.class, shipmentInsertion);
|
||||
// switcher.put(Service.class, serviceInsertion);
|
||||
//
|
||||
//
|
||||
// JobInsertionCostsCalculator finalServiceInsertion = new VehicleTypeDependentJobInsertionCalculator(fleetManager, switcher);
|
||||
//
|
||||
// BestInsertion bestInsertion = new BestInsertion(finalServiceInsertion);
|
||||
|
||||
|
||||
// BestInsertionConc bestInsertion = new BestInsertionConc(finalServiceInsertion, executorService, 2);
|
||||
|
||||
RuinRadial radial = new RuinRadial(vrp, 0.3, new AvgJobDistance(vrp.getTransportCosts()));
|
||||
RuinRandom random = new RuinRandom(vrp, 0.5);
|
||||
|
||||
SolutionCostCalculator solutionCostCalculator = new SolutionCostCalculator() {
|
||||
|
||||
@Override
|
||||
public double getCosts(VehicleRoutingProblemSolution solution) {
|
||||
double costs = 0.0;
|
||||
for(VehicleRoute route : solution.getRoutes()){
|
||||
costs += stateManager.getRouteState(route, StateFactory.COSTS).toDouble();
|
||||
}
|
||||
return costs;
|
||||
}
|
||||
};
|
||||
|
||||
SearchStrategy randomStrategy = new SearchStrategy(new SelectBest(), new AcceptNewIfBetterThanWorst(1), solutionCostCalculator);
|
||||
RuinAndRecreateModule randomModule = new RuinAndRecreateModule("randomRuin_bestInsertion", bestInsertion, random);
|
||||
randomStrategy.addModule(randomModule);
|
||||
|
||||
SearchStrategy radialStrategy = new SearchStrategy(new SelectBest(), new AcceptNewIfBetterThanWorst(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);
|
||||
|
||||
vra = new VehicleRoutingAlgorithmFactoryImpl(strategyManager, stateManager, fleetManager).createAlgorithm(vrp);
|
||||
//
|
||||
//// vra.getAlgorithmListeners().addListener(stateManager);
|
||||
//
|
||||
//// final RouteActivityVisitor iterateForward = new RouteActivityVisitor();
|
||||
//
|
||||
//// iterateForward.addActivityVisitor(new UpdateActivityTimes(vrp.getTransportCosts()));
|
||||
//// iterateForward.addActivityVisitor(new UpdateVariableCosts(vrp.getActivityCosts(), vrp.getTransportCosts(), stateManager));
|
||||
////
|
||||
//// iterateForward.addActivityVisitor(new UpdateOccuredDeliveries(stateManager));
|
||||
//// iterateForward.addActivityVisitor(new UpdateLoads(stateManager));
|
||||
////
|
||||
//// final ReverseRouteActivityVisitor iterateBackward = new ReverseRouteActivityVisitor();
|
||||
//// iterateBackward.addActivityVisitor(new TimeWindowUpdater(stateManager, vrp.getTransportCosts()));
|
||||
//// iterateBackward.addActivityVisitor(new UpdateFuturePickups(stateManager));
|
||||
////
|
||||
//// JobInsertedListener updateWhenJobHasBeenInserted = new JobInsertedListener() {
|
||||
////
|
||||
//// @Override
|
||||
//// public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) {
|
||||
//// iterateForward.visit(inRoute);
|
||||
//// iterateBackward.visit(inRoute);
|
||||
//// }
|
||||
////
|
||||
//// };
|
||||
////
|
||||
//// InsertionStartsListener updateRoutesWhenInsertionStarts = new InsertionStartsListener() {
|
||||
////
|
||||
//// @Override
|
||||
//// public void informInsertionStarts(Collection<VehicleRoute> vehicleRoutes, Collection<Job> unassignedJobs) {
|
||||
//// for(VehicleRoute route : vehicleRoutes){
|
||||
//// iterateForward.visit(route);
|
||||
//// iterateBackward.visit(route);
|
||||
//// }
|
||||
////
|
||||
//// }
|
||||
//// };
|
||||
//
|
||||
//<<<<<<< HEAD
|
||||
//// vra.getSearchStrategyManager().addSearchStrategyModuleListener(new RemoveEmptyVehicles(fleetManager));
|
||||
//=======
|
||||
// iterateForward.addActivityVisitor(new UpdatePrevMaxLoad(stateManager));
|
||||
// iterateForward.addActivityVisitor(new UpdateLoads(stateManager));
|
||||
//>>>>>>> branch 'PickupAndDelivery' of https://github.com/jsprit/jsprit.git
|
||||
//
|
||||
//<<<<<<< HEAD
|
||||
//// bestInsertion.addListener(new UpdateLoads(stateManager));
|
||||
//// bestInsertion.addListener(updateWhenJobHasBeenInserted);
|
||||
//// bestInsertion.addListener(updateRoutesWhenInsertionStarts);
|
||||
//=======
|
||||
// final ReverseRouteActivityVisitor iterateBackward = new ReverseRouteActivityVisitor();
|
||||
// iterateBackward.addActivityVisitor(new TimeWindowUpdater(stateManager, vrp.getTransportCosts()));
|
||||
// iterateBackward.addActivityVisitor(new UpdateMaxLoad(stateManager));
|
||||
//
|
||||
// JobInsertedListener updateWhenJobHasBeenInserted = new JobInsertedListener() {
|
||||
//
|
||||
// @Override
|
||||
// public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) {
|
||||
// iterateForward.visit(inRoute);
|
||||
// iterateBackward.visit(inRoute);
|
||||
// }
|
||||
//
|
||||
// };
|
||||
//
|
||||
// InsertionStartsListener updateRoutesWhenInsertionStarts = new InsertionStartsListener() {
|
||||
//
|
||||
// @Override
|
||||
// public void informInsertionStarts(Collection<VehicleRoute> vehicleRoutes, Collection<Job> unassignedJobs) {
|
||||
// for(VehicleRoute route : vehicleRoutes){
|
||||
// iterateForward.visit(route);
|
||||
// iterateBackward.visit(route);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// vra.getSearchStrategyManager().addSearchStrategyModuleListener(new RemoveEmptyVehicles(fleetManager));
|
||||
//
|
||||
// bestInsertion.addListener(new UpdateLoads(stateManager));
|
||||
// bestInsertion.addListener(updateWhenJobHasBeenInserted);
|
||||
// bestInsertion.addListener(updateRoutesWhenInsertionStarts);
|
||||
//>>>>>>> branch 'PickupAndDelivery' of https://github.com/jsprit/jsprit.git
|
||||
//
|
||||
VehicleRoutingProblemSolution iniSolution = new InsertionInitialSolutionFactory(bestInsertion, solutionCostCalculator).createSolution(vrp);
|
||||
// System.out.println("ini: costs="+iniSolution.getCost()+";#routes="+iniSolution.getRoutes().size());
|
||||
vra.addInitialSolution(iniSolution);
|
||||
|
||||
vra.setNuOfIterations(10);
|
||||
// vra.setPrematureBreak(500);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
VehicleRoutingProblemSolution best = Solutions.getBest(solutions);
|
||||
|
||||
executorService.shutdown();
|
||||
// Wait until all threads are finish
|
||||
// executorService.awaitTermination();
|
||||
|
||||
// for(VehicleRoute r : best.getRoutes()){
|
||||
// System.out.println(r);
|
||||
// System.out.println("#jobs="+r.getTourActivities().jobSize());
|
||||
// System.out.println(r.getStart());
|
||||
// for(TourActivity act : r.getTourActivities().getActivities()){
|
||||
// System.out.println(act);
|
||||
// }
|
||||
// System.out.println(r.getEnd());
|
||||
// }
|
||||
//
|
||||
System.out.println("total="+best.getCost());
|
||||
System.out.println("#routes="+best.getRoutes().size());
|
||||
|
||||
// for()
|
||||
|
||||
new VrpXMLWriter(vrp, solutions).write("src/test/resources/pdp_sol.xml");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,290 +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 algorithms;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import util.Coordinate;
|
||||
import util.ManhattanDistanceCalculator;
|
||||
import util.RouteUtils;
|
||||
import basics.Job;
|
||||
import basics.Service;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblemSolution;
|
||||
import basics.costs.VehicleRoutingActivityCosts;
|
||||
import basics.costs.VehicleRoutingTransportCosts;
|
||||
import basics.route.Driver;
|
||||
import basics.route.DriverImpl;
|
||||
import basics.route.FiniteFleetManagerFactory;
|
||||
import basics.route.ServiceActivity;
|
||||
import basics.route.TimeWindow;
|
||||
import basics.route.TourActivities;
|
||||
import basics.route.Vehicle;
|
||||
import basics.route.VehicleFleetManager;
|
||||
import basics.route.VehicleImpl;
|
||||
import basics.route.VehicleRoute;
|
||||
import basics.route.VehicleTypeImpl;
|
||||
|
||||
public class GendreauPostOptTest {
|
||||
|
||||
TourActivities tour;
|
||||
|
||||
Vehicle heavyVehicle;
|
||||
|
||||
Vehicle lightVehicle1;
|
||||
|
||||
Vehicle lightVehicle2;
|
||||
|
||||
VehicleRoutingTransportCosts cost;
|
||||
|
||||
VehicleRoutingActivityCosts activityCosts;
|
||||
|
||||
VehicleRoutingProblem vrp;
|
||||
|
||||
Service job1;
|
||||
|
||||
Service job2;
|
||||
|
||||
Service job3;
|
||||
|
||||
private StateManager states;
|
||||
|
||||
private List<Vehicle> vehicles;
|
||||
|
||||
private VehicleFleetManager fleetManager;
|
||||
|
||||
private JobInsertionCostsCalculator insertionCalc;
|
||||
|
||||
@Before
|
||||
public void setUp(){
|
||||
|
||||
cost = new VehicleRoutingTransportCosts() {
|
||||
|
||||
@Override
|
||||
public double getBackwardTransportTime(String fromId, String toId,
|
||||
double arrivalTime, Driver driver, Vehicle vehicle) {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBackwardTransportCost(String fromId, String toId,
|
||||
double arrivalTime, Driver driver, Vehicle vehicle) {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTransportCost(String fromId, String toId, double departureTime, Driver driver, Vehicle vehicle) {
|
||||
|
||||
String[] fromTokens = fromId.split(",");
|
||||
String[] toTokens = toId.split(",");
|
||||
double fromX = Double.parseDouble(fromTokens[0]);
|
||||
double fromY = Double.parseDouble(fromTokens[1]);
|
||||
|
||||
double toX = Double.parseDouble(toTokens[0]);
|
||||
double toY = Double.parseDouble(toTokens[1]);
|
||||
|
||||
double costPerDistanceUnit;
|
||||
if(vehicle != null){
|
||||
costPerDistanceUnit = vehicle.getType().getVehicleCostParams().perDistanceUnit;
|
||||
}
|
||||
else{
|
||||
costPerDistanceUnit = 1;
|
||||
}
|
||||
|
||||
return costPerDistanceUnit*ManhattanDistanceCalculator.calculateDistance(new Coordinate(fromX, fromY), new Coordinate(toX, toY));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTransportTime(String fromId, String toId, double departureTime, Driver driver, Vehicle vehicle) {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
VehicleTypeImpl lightType = VehicleTypeImpl.Builder.newInstance("light", 10).setFixedCost(10).setCostPerDistance(1.0).build();
|
||||
VehicleTypeImpl heavyType = VehicleTypeImpl.Builder.newInstance("heavy", 10).setFixedCost(30).setCostPerDistance(2.0).build();
|
||||
|
||||
lightVehicle1 = VehicleImpl.Builder.newInstance("light").setLocationId("0,0").setType(lightType).build();
|
||||
lightVehicle2 = VehicleImpl.Builder.newInstance("light2").setLocationId("0,0").setType(lightType).build();
|
||||
heavyVehicle = VehicleImpl.Builder.newInstance("heavy").setLocationId("0,0").setType(heavyType).build();
|
||||
|
||||
|
||||
job1 = getService("10,0");
|
||||
job2 = getService("10,10");
|
||||
job3 = getService("0,10");
|
||||
|
||||
Collection<Job> jobs = new ArrayList<Job>();
|
||||
jobs.add(job1);
|
||||
jobs.add(job2);
|
||||
jobs.add(job3);
|
||||
|
||||
vehicles = Arrays.asList(lightVehicle1,lightVehicle2, heavyVehicle);
|
||||
|
||||
// Collection<Vehicle> vehicles = Arrays.asList(lightVehicle1,lightVehicle2, heavyVehicle);
|
||||
fleetManager = new FiniteFleetManagerFactory(vehicles).createFleetManager();
|
||||
states = new StateManager();
|
||||
|
||||
activityCosts = new ExampleActivityCostFunction();
|
||||
|
||||
|
||||
ServiceInsertionCalculator standardServiceInsertion = new ServiceInsertionCalculator(cost, new LocalActivityInsertionCostsCalculator(cost, activityCosts), new LoadConstraint(states), new TimeWindowConstraint(states, cost));
|
||||
|
||||
|
||||
|
||||
|
||||
JobInsertionConsideringFixCostsCalculator withFixCost = new JobInsertionConsideringFixCostsCalculator(standardServiceInsertion, states);
|
||||
withFixCost.setWeightOfFixCost(1.2);
|
||||
|
||||
insertionCalc = new VehicleTypeDependentJobInsertionCalculator(fleetManager, withFixCost);
|
||||
|
||||
// updater = new TourStateUpdater(states, cost, activityCosts);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenPostOpt_splitsTour_oneActiveTourBecomeTwoSeperateActiveTours(){
|
||||
Collection<Job> jobs = new ArrayList<Job>();
|
||||
jobs.add(job1);
|
||||
jobs.add(job2);
|
||||
|
||||
vrp = VehicleRoutingProblem.Builder.newInstance().addAllJobs(jobs).addAllVehicles(vehicles).setRoutingCost(cost).build();
|
||||
|
||||
TourActivities tour = new TourActivities();
|
||||
tour.addActivity(ServiceActivity.newInstance(job1));
|
||||
tour.addActivity(ServiceActivity.newInstance(job2));
|
||||
|
||||
VehicleRoute route = VehicleRoute.newInstance(tour,DriverImpl.noDriver(),heavyVehicle);
|
||||
|
||||
fleetManager.lock(heavyVehicle);
|
||||
|
||||
UpdateStates stateUpdater = new UpdateStates(states, vrp.getTransportCosts(), vrp.getActivityCosts());
|
||||
stateUpdater.update(route);
|
||||
|
||||
Collection<VehicleRoute> routes = new ArrayList<VehicleRoute>();
|
||||
routes.add(route);
|
||||
// routes.add(new VehicleRoute(getEmptyTour(),getDriver(),getNoVehicle()));
|
||||
// routes.add(new VehicleRoute(getEmptyTour(),getDriver(),getNoVehicle()));
|
||||
|
||||
|
||||
VehicleRoutingProblemSolution sol = new VehicleRoutingProblemSolution(routes, states.getRouteState(route, StateFactory.COSTS).toDouble() + getFixedCosts(routes));
|
||||
|
||||
|
||||
assertEquals(110.0, sol.getCost(), 0.5);
|
||||
|
||||
|
||||
RuinRadial radialRuin = new RuinRadial(vrp, 0.2, new JobDistanceAvgCosts(vrp.getTransportCosts()));
|
||||
// radialRuin.addListener(stateUpdater);
|
||||
|
||||
InsertionStrategy insertionStrategy = new BestInsertion(insertionCalc);
|
||||
insertionStrategy.addListener(stateUpdater);
|
||||
insertionStrategy.addListener(new VehicleSwitched(fleetManager));
|
||||
Gendreau postOpt = new Gendreau(vrp, radialRuin, insertionStrategy, fleetManager);
|
||||
|
||||
VehicleRoutingProblemSolution newSolution = postOpt.runAndGetSolution(sol);
|
||||
newSolution.setCost(getCosts(newSolution,states));
|
||||
|
||||
assertEquals(2,RouteUtils.getNuOfActiveRoutes(newSolution.getRoutes()));
|
||||
assertEquals(2,newSolution.getRoutes().size());
|
||||
assertEquals(80.0,newSolution.getCost(),0.5);
|
||||
}
|
||||
|
||||
private double getFixedCosts(Collection<VehicleRoute> routes) {
|
||||
double c = 0.0;
|
||||
for(VehicleRoute r : routes){ c += r.getVehicle().getType().getVehicleCostParams().fix; }
|
||||
return c;
|
||||
}
|
||||
|
||||
private double getCosts(VehicleRoutingProblemSolution newSolution, StateManager states) {
|
||||
double c = 0.0;
|
||||
for(VehicleRoute r : newSolution.getRoutes()){
|
||||
|
||||
c += states.getRouteState(r, StateFactory.COSTS).toDouble() + r.getVehicle().getType().getVehicleCostParams().fix;
|
||||
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenPostOpt_optsRoutesWithMoreThanTwoJobs_oneRouteBecomesTwoRoutes(){
|
||||
Collection<Job> jobs = new ArrayList<Job>();
|
||||
jobs.add(job1);
|
||||
jobs.add(job2);
|
||||
jobs.add(job3);
|
||||
|
||||
vrp = VehicleRoutingProblem.Builder.newInstance().addAllJobs(jobs).addAllVehicles(vehicles).setRoutingCost(cost).build();
|
||||
|
||||
TourActivities tour = new TourActivities();
|
||||
tour.addActivity(ServiceActivity.newInstance(job1));
|
||||
tour.addActivity(ServiceActivity.newInstance(job2));
|
||||
tour.addActivity(ServiceActivity.newInstance(job3));
|
||||
|
||||
VehicleRoute route = VehicleRoute.newInstance(tour,DriverImpl.noDriver(),heavyVehicle);
|
||||
|
||||
UpdateStates stateUpdater = new UpdateStates(states, vrp.getTransportCosts(), vrp.getActivityCosts());
|
||||
stateUpdater.update(route);
|
||||
|
||||
fleetManager.lock(heavyVehicle);
|
||||
|
||||
Collection<VehicleRoute> routes = new ArrayList<VehicleRoute>();
|
||||
routes.add(route);
|
||||
|
||||
VehicleRoutingProblemSolution sol = new VehicleRoutingProblemSolution(routes, route.getCost());
|
||||
sol.setCost(getCosts(sol,states));
|
||||
|
||||
assertEquals(110.0, sol.getCost(), 0.5);
|
||||
|
||||
RuinRadial radialRuin = new RuinRadial(vrp, 0.2, new JobDistanceAvgCosts(vrp.getTransportCosts()));
|
||||
InsertionStrategy insertionStrategy = new BestInsertion(insertionCalc);
|
||||
insertionStrategy.addListener(stateUpdater);
|
||||
insertionStrategy.addListener(new VehicleSwitched(fleetManager));
|
||||
Gendreau postOpt = new Gendreau(vrp, radialRuin, insertionStrategy, fleetManager);
|
||||
postOpt.setShareOfJobsToRuin(1.0);
|
||||
postOpt.setNuOfIterations(1);
|
||||
|
||||
// postOpt.setWithFix(withFixCost);
|
||||
VehicleRoutingProblemSolution newSolution = postOpt.runAndGetSolution(sol);
|
||||
newSolution.setCost(getCosts(newSolution,states));
|
||||
|
||||
assertEquals(2,RouteUtils.getNuOfActiveRoutes(newSolution.getRoutes()));
|
||||
assertEquals(2,newSolution.getRoutes().size());
|
||||
assertEquals(80.0,newSolution.getCost(),0.5);
|
||||
}
|
||||
|
||||
private Service getService(String to, double serviceTime) {
|
||||
Service s = Service.Builder.newInstance(to, 0).setLocationId(to).setServiceTime(serviceTime).setTimeWindow(TimeWindow.newInstance(0.0, 20.0)).build();
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
private Service getService(String to) {
|
||||
Service s = getService(to, 0.0);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
package algorithms;
|
||||
|
||||
import basics.Service;
|
||||
|
||||
class LoadConstraint implements HardRouteStateLevelConstraint{
|
||||
|
||||
private StateGetter states;
|
||||
|
||||
public LoadConstraint(StateGetter states) {
|
||||
super();
|
||||
this.states = states;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fulfilled(InsertionContext insertionContext) {
|
||||
int currentLoad = (int) states.getRouteState(insertionContext.getRoute(), StateFactory.LOAD).toDouble();
|
||||
Service service = (Service) insertionContext.getJob();
|
||||
if(currentLoad + service.getCapacityDemand() > insertionContext.getNewVehicle().getCapacity()){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,80 +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 algorithms;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import basics.Job;
|
||||
import basics.algo.InsertionStartsListener;
|
||||
import basics.algo.JobInsertedListener;
|
||||
import basics.costs.VehicleRoutingActivityCosts;
|
||||
import basics.costs.VehicleRoutingTransportCosts;
|
||||
import basics.route.ReverseRouteActivityVisitor;
|
||||
import basics.route.RouteActivityVisitor;
|
||||
import basics.route.VehicleRoute;
|
||||
|
||||
|
||||
|
||||
class UpdateStates implements JobInsertedListener, InsertionStartsListener{
|
||||
|
||||
private RouteActivityVisitor routeActivityVisitor;
|
||||
|
||||
private ReverseRouteActivityVisitor revRouteActivityVisitor;
|
||||
|
||||
private InsertionListeners insertionListeners = new InsertionListeners();
|
||||
|
||||
public UpdateStates(StateManager states, VehicleRoutingTransportCosts routingCosts, VehicleRoutingActivityCosts activityCosts) {
|
||||
routeActivityVisitor = new RouteActivityVisitor();
|
||||
routeActivityVisitor.addActivityVisitor(new UpdateActivityTimes(routingCosts));
|
||||
routeActivityVisitor.addActivityVisitor(new UpdateVariableCosts(activityCosts, routingCosts, states));
|
||||
routeActivityVisitor.addActivityVisitor(new UpdateLoads(states));
|
||||
routeActivityVisitor.addActivityVisitor(new UpdateMaxLoad_(states));
|
||||
revRouteActivityVisitor = new ReverseRouteActivityVisitor();
|
||||
revRouteActivityVisitor.addActivityVisitor(new TimeWindowUpdater(states, routingCosts));
|
||||
insertionListeners.addListener(new UpdateLoads(states));
|
||||
// insertionListeners.addListener(new UpdateLoadsAtStartAndEndOfRouteWhenJobHasBeenInserted(states));
|
||||
}
|
||||
|
||||
public void update(VehicleRoute route){
|
||||
List<VehicleRoute> routes = Arrays.asList(route);
|
||||
insertionListeners.informInsertionStarts(routes, Collections.EMPTY_LIST);
|
||||
routeActivityVisitor.visit(route);
|
||||
revRouteActivityVisitor.visit(route);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) {
|
||||
insertionListeners.informJobInserted(job2insert, inRoute, additionalCosts, additionalTime);
|
||||
routeActivityVisitor.visit(inRoute);
|
||||
revRouteActivityVisitor.visit(inRoute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void informInsertionStarts(Collection<VehicleRoute> vehicleRoutes,Collection<Job> unassignedJobs) {
|
||||
insertionListeners.informInsertionStarts(vehicleRoutes, unassignedJobs);
|
||||
for(VehicleRoute route : vehicleRoutes) {
|
||||
routeActivityVisitor.visit(route);
|
||||
revRouteActivityVisitor.visit(route);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
package algorithms;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import algorithms.StateManager.StateImpl;
|
||||
import basics.Job;
|
||||
import basics.algo.InsertionEndsListener;
|
||||
import basics.algo.InsertionStartsListener;
|
||||
import basics.algo.JobInsertedListener;
|
||||
import basics.costs.VehicleRoutingActivityCosts;
|
||||
import basics.costs.VehicleRoutingTransportCosts;
|
||||
import basics.route.RouteActivityVisitor;
|
||||
import basics.route.VehicleRoute;
|
||||
|
||||
class UpdateCostsAtRouteLevel implements StateUpdater,JobInsertedListener, InsertionStartsListener, InsertionEndsListener{
|
||||
|
||||
private StateManager states;
|
||||
|
||||
private VehicleRoutingTransportCosts tpCosts;
|
||||
|
||||
private VehicleRoutingActivityCosts actCosts;
|
||||
|
||||
public UpdateCostsAtRouteLevel(StateManager states, VehicleRoutingTransportCosts tpCosts, VehicleRoutingActivityCosts actCosts) {
|
||||
super();
|
||||
this.states = states;
|
||||
this.tpCosts = tpCosts;
|
||||
this.actCosts = actCosts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) {
|
||||
// inRoute.getVehicleRouteCostCalculator().addTransportCost(additionalCosts);
|
||||
double oldCosts = states.getRouteState(inRoute, StateFactory.COSTS).toDouble();
|
||||
oldCosts += additionalCosts;
|
||||
states.putRouteState(inRoute, StateFactory.COSTS, new StateImpl(oldCosts));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void informInsertionStarts(Collection<VehicleRoute> vehicleRoutes, Collection<Job> unassignedJobs) {
|
||||
RouteActivityVisitor forwardInTime = new RouteActivityVisitor();
|
||||
forwardInTime.addActivityVisitor(new UpdateVariableCosts(actCosts, tpCosts, states));
|
||||
for(VehicleRoute route : vehicleRoutes){
|
||||
forwardInTime.visit(route);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void informInsertionEnds(Collection<VehicleRoute> vehicleRoutes) {
|
||||
|
||||
// IterateRouteForwardInTime forwardInTime = new IterateRouteForwardInTime(tpCosts);
|
||||
// forwardInTime.addListener(new UpdateCostsAtAllLevels(actCosts, tpCosts, states));
|
||||
for(VehicleRoute route : vehicleRoutes){
|
||||
if(route.isEmpty()) continue;
|
||||
route.getVehicleRouteCostCalculator().reset();
|
||||
route.getVehicleRouteCostCalculator().addOtherCost(states.getRouteState(route, StateFactory.COSTS).toDouble());
|
||||
route.getVehicleRouteCostCalculator().price(route.getVehicle());
|
||||
// forwardInTime.iterate(route);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
package algorithms;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import algorithms.StateManager.StateImpl;
|
||||
import basics.Job;
|
||||
import basics.Service;
|
||||
import basics.algo.InsertionStartsListener;
|
||||
import basics.algo.JobInsertedListener;
|
||||
import basics.route.VehicleRoute;
|
||||
|
||||
/**
|
||||
* Updates load at route level, i.e. modifies StateTypes.LOAD for each route.
|
||||
*
|
||||
* @author stefan
|
||||
*
|
||||
*/
|
||||
class UpdateLoadAtRouteLevel implements JobInsertedListener, InsertionStartsListener, StateUpdater{
|
||||
|
||||
private StateManager states;
|
||||
|
||||
/**
|
||||
* Updates load at route level, i.e. modifies StateTypes.LOAD for each route.
|
||||
*
|
||||
* @author stefan
|
||||
*
|
||||
*/
|
||||
public UpdateLoadAtRouteLevel(StateManager states) {
|
||||
super();
|
||||
this.states = states;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void informJobInserted(Job job2insert, VehicleRoute inRoute, double additionalCosts, double additionalTime) {
|
||||
if(!(job2insert instanceof Service)){
|
||||
return;
|
||||
}
|
||||
double oldLoad = states.getRouteState(inRoute, StateFactory.LOAD).toDouble();
|
||||
states.putRouteState(inRoute, StateFactory.LOAD, StateFactory.createState(oldLoad + job2insert.getCapacityDemand()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void informInsertionStarts(Collection<VehicleRoute> vehicleRoutes, Collection<Job> unassignedJobs) {
|
||||
for(VehicleRoute route : vehicleRoutes){
|
||||
int load = 0;
|
||||
for(Job j : route.getTourActivities().getJobs()){
|
||||
load += j.getCapacityDemand();
|
||||
}
|
||||
states.putRouteState(route, StateFactory.LOAD, new StateImpl(load));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,35 +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 allsuites;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
|
||||
import algorithms.AlgorithmsSuite;
|
||||
import basics.BasicsSuite;
|
||||
|
||||
|
||||
|
||||
@RunWith(Suite.class)
|
||||
@Suite.SuiteClasses({
|
||||
AlgorithmsSuite.class,
|
||||
BasicsSuite.class
|
||||
})
|
||||
public class AllTests {}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,50 +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 basics;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
|
||||
import algorithms.TestVehicleFleetManager;
|
||||
import basics.algo.SearchStrategyManagerTest;
|
||||
import basics.algo.SearchStrategyTest;
|
||||
import basics.io.VrpReaderV2Test;
|
||||
import basics.io.VrpWriterV2Test;
|
||||
import basics.io.VrpWriterV3Test;
|
||||
import basics.route.ServiceActTest;
|
||||
import basics.route.TestTour;
|
||||
import basics.route.TestVehicleRoute;
|
||||
|
||||
|
||||
|
||||
|
||||
@RunWith(Suite.class)
|
||||
@Suite.SuiteClasses({
|
||||
SearchStrategyManagerTest.class,
|
||||
SearchStrategyTest.class,
|
||||
TestTour.class,
|
||||
TestVehicleFleetManager.class,
|
||||
TestVehicleRoute.class,
|
||||
ServiceActTest.class,
|
||||
ServiceTest.class,
|
||||
VehicleRoutingProblemBuilderTest.class,
|
||||
VrpReaderV2Test.class,
|
||||
VrpWriterV2Test.class,
|
||||
VrpWriterV3Test.class
|
||||
|
||||
})
|
||||
public class BasicsSuite {}
|
||||
|
|
@ -1,98 +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 basics.io;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import basics.Service;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblem.FleetComposition;
|
||||
import basics.VehicleRoutingProblem.FleetSize;
|
||||
import basics.VehicleRoutingProblemSolution;
|
||||
import basics.route.End;
|
||||
import basics.route.ServiceActivity;
|
||||
import basics.route.Start;
|
||||
import basics.route.Vehicle;
|
||||
import basics.route.VehicleImpl;
|
||||
import basics.route.VehicleRoute;
|
||||
import basics.route.VehicleTypeImpl;
|
||||
|
||||
public class VrpWriterV3Test {
|
||||
|
||||
private String infileName;
|
||||
|
||||
@Before
|
||||
public void doBefore(){
|
||||
infileName = "src/test/resources/infiniteWriterV2Test.xml";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenWritingSolutions_itWritesThemCorrectly(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
builder.setFleetComposition(FleetComposition.HETEROGENEOUS);
|
||||
builder.setFleetSize(FleetSize.FINITE);
|
||||
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
|
||||
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
|
||||
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setLocationId("loc").setType(type1).build();
|
||||
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setLocationId("loc").setType(type2).build();
|
||||
builder.addVehicleType(type1);
|
||||
builder.addVehicleType(type2);
|
||||
builder.addVehicle(v1);
|
||||
builder.addVehicle(v2);
|
||||
|
||||
Service s1 = Service.Builder.newInstance("1", 1).setLocationId("loc").setServiceTime(2.0).build();
|
||||
Service s2 = Service.Builder.newInstance("2", 1).setLocationId("loc2").setServiceTime(4.0).build();
|
||||
builder.addService(s1).addService(s2);
|
||||
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
|
||||
Collection<VehicleRoute> routes = new ArrayList<VehicleRoute>();
|
||||
Start start = Start.newInstance("start", 0.0, Double.MAX_VALUE);
|
||||
start.setEndTime(10.0);
|
||||
End end = End.newInstance("end", 0.0, Double.MAX_VALUE);
|
||||
end.setArrTime(100);
|
||||
VehicleRoute.Builder routebuilder = VehicleRoute.Builder.newInstance(start, end);
|
||||
|
||||
ServiceActivity act1 = ServiceActivity.newInstance(s1);
|
||||
ServiceActivity act2 = ServiceActivity.newInstance(s2);
|
||||
act1.setArrTime(20.0);
|
||||
act1.setEndTime(30.0);
|
||||
|
||||
act2.setArrTime(40.0);
|
||||
act2.setEndTime(80.0);
|
||||
|
||||
routebuilder.addActivity(act1).addActivity(act2).setVehicle(v1);
|
||||
VehicleRoute route = routebuilder.build();
|
||||
routes.add(route);
|
||||
|
||||
VehicleRoutingProblemSolution solution = new VehicleRoutingProblemSolution(routes, 100);
|
||||
|
||||
new VrpXMLWriter(vrp, Arrays.asList(solution)).write(infileName);
|
||||
|
||||
VehicleRoutingProblem.Builder vrpToReadBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
Collection<VehicleRoutingProblemSolution> solutions = new ArrayList<VehicleRoutingProblemSolution>();
|
||||
new VrpXMLReader(vrpToReadBuilder, solutions).read(infileName);
|
||||
VehicleRoutingProblem readVrp = vrpToReadBuilder.build();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
/*******************************************************************************
|
||||
* 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 jsprit.core.algorithm;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import jsprit.core.algorithm.acceptor.GreedyAcceptance;
|
||||
import jsprit.core.algorithm.listener.IterationStartsListener;
|
||||
import jsprit.core.algorithm.module.RuinAndRecreateModule;
|
||||
import jsprit.core.algorithm.recreate.BestInsertionBuilder;
|
||||
import jsprit.core.algorithm.recreate.InsertionStrategy;
|
||||
import jsprit.core.algorithm.ruin.RadialRuinStrategyFactory;
|
||||
import jsprit.core.algorithm.ruin.RandomRuinStrategyFactory;
|
||||
import jsprit.core.algorithm.ruin.RuinStrategy;
|
||||
import jsprit.core.algorithm.ruin.distance.AvgServiceDistance;
|
||||
import jsprit.core.algorithm.selector.SelectBest;
|
||||
import jsprit.core.algorithm.state.StateManager;
|
||||
import jsprit.core.algorithm.state.UpdateVariableCosts;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.constraint.ConstraintManager;
|
||||
import jsprit.core.problem.io.VrpXMLReader;
|
||||
import jsprit.core.problem.solution.SolutionCostCalculator;
|
||||
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import jsprit.core.problem.solution.route.state.StateFactory;
|
||||
import jsprit.core.problem.vehicle.InfiniteFleetManagerFactory;
|
||||
import jsprit.core.problem.vehicle.VehicleFleetManager;
|
||||
import jsprit.core.util.Solutions;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class BuildCVRPAlgoFromScratch_IT {
|
||||
|
||||
VehicleRoutingProblem vrp;
|
||||
|
||||
VehicleRoutingAlgorithm vra;
|
||||
|
||||
@Before
|
||||
public void setup(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder).read("src/test/resources/vrpnc1-jsprit.xml");
|
||||
vrp = builder.build();
|
||||
|
||||
final StateManager stateManager = new StateManager(vrp);
|
||||
stateManager.updateLoadStates();
|
||||
stateManager.updateTimeWindowStates();
|
||||
stateManager.addStateUpdater(new UpdateVariableCosts(vrp.getActivityCosts(), vrp.getTransportCosts(), stateManager));
|
||||
|
||||
|
||||
ConstraintManager cManager = new ConstraintManager(vrp, stateManager);
|
||||
cManager.addLoadConstraint();
|
||||
cManager.addTimeWindowConstraint();
|
||||
|
||||
VehicleFleetManager fleetManager = new InfiniteFleetManagerFactory(vrp.getVehicles()).createFleetManager();
|
||||
|
||||
InsertionStrategy bestInsertion = new BestInsertionBuilder(vrp, fleetManager, stateManager, cManager).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()){
|
||||
costs += stateManager.getRouteState(route, StateFactory.COSTS).toDouble();
|
||||
}
|
||||
return costs;
|
||||
}
|
||||
};
|
||||
|
||||
SearchStrategy randomStrategy = new SearchStrategy(new SelectBest(), new GreedyAcceptance(1), solutionCostCalculator);
|
||||
RuinAndRecreateModule randomModule = new RuinAndRecreateModule("randomRuin_bestInsertion", bestInsertion, random);
|
||||
randomStrategy.addModule(randomModule);
|
||||
|
||||
SearchStrategy radialStrategy = new SearchStrategy(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);
|
||||
|
||||
vra = new VehicleRoutingAlgorithm(vrp, strategyManager);
|
||||
vra.addListener(stateManager);
|
||||
vra.addListener(new RemoveEmptyVehicles(fleetManager));
|
||||
|
||||
// vra.getAlgorithmListeners().addListener(stateManager);
|
||||
// vra.getSearchStrategyManager().addSearchStrategyModuleListener(stateManager);
|
||||
// vra.getSearchStrategyManager().addSearchStrategyModuleListener(new RemoveEmptyVehicles(fleetManager));
|
||||
|
||||
VehicleRoutingProblemSolution iniSolution = new InsertionInitialSolutionFactory(bestInsertion, solutionCostCalculator).createSolution(vrp);
|
||||
|
||||
vra.addInitialSolution(iniSolution);
|
||||
|
||||
vra.setNuOfIterations(2000);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVRA(){
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
System.out.println("costs="+Solutions.bestOf(solutions).getCost()+";#routes="+Solutions.bestOf(solutions).getRoutes().size());
|
||||
assertEquals(530.0, Solutions.bestOf(solutions).getCost(),15.0);
|
||||
assertEquals(5, Solutions.bestOf(solutions).getRoutes().size());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -14,35 +14,43 @@
|
|||
* 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 algorithms;
|
||||
package jsprit.core.algorithm;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import jsprit.core.algorithm.acceptor.GreedyAcceptance;
|
||||
import jsprit.core.algorithm.module.RuinAndRecreateModule;
|
||||
import jsprit.core.algorithm.recreate.BestInsertionBuilder;
|
||||
import jsprit.core.algorithm.recreate.InsertionStrategy;
|
||||
import jsprit.core.algorithm.ruin.RadialRuinStrategyFactory;
|
||||
import jsprit.core.algorithm.ruin.RandomRuinStrategyFactory;
|
||||
import jsprit.core.algorithm.ruin.RuinStrategy;
|
||||
import jsprit.core.algorithm.ruin.distance.AvgServiceDistance;
|
||||
import jsprit.core.algorithm.selector.SelectBest;
|
||||
import jsprit.core.algorithm.state.StateManager;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.constraint.ConstraintManager;
|
||||
import jsprit.core.problem.io.VrpXMLReader;
|
||||
import jsprit.core.problem.solution.SolutionCostCalculator;
|
||||
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import jsprit.core.problem.solution.route.state.StateFactory;
|
||||
import jsprit.core.problem.vehicle.InfiniteFleetManagerFactory;
|
||||
import jsprit.core.problem.vehicle.VehicleFleetManager;
|
||||
import jsprit.core.util.Solutions;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import util.Solutions;
|
||||
import algorithms.acceptors.AcceptNewIfBetterThanWorst;
|
||||
import algorithms.selectors.SelectBest;
|
||||
import basics.VehicleRoutingAlgorithm;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblemSolution;
|
||||
import basics.algo.SearchStrategy;
|
||||
import basics.algo.SearchStrategyManager;
|
||||
import basics.algo.SolutionCostCalculator;
|
||||
import basics.io.VrpXMLReader;
|
||||
import basics.route.InfiniteFleetManagerFactory;
|
||||
import basics.route.VehicleFleetManager;
|
||||
import basics.route.VehicleRoute;
|
||||
|
||||
public class BuildPDVRPAlgoFromScratchTest {
|
||||
public class BuildPDVRPAlgoFromScratch_IT {
|
||||
|
||||
VehicleRoutingProblem vrp;
|
||||
|
||||
VehicleRoutingAlgorithm vra;
|
||||
|
||||
static Logger log = Logger.getLogger(BuildPDVRPAlgoFromScratchTest.class);
|
||||
static Logger log = Logger.getLogger(BuildPDVRPAlgoFromScratch_IT.class);
|
||||
|
||||
@Before
|
||||
public void setup(){
|
||||
|
|
@ -51,7 +59,7 @@ public class BuildPDVRPAlgoFromScratchTest {
|
|||
new VrpXMLReader(builder).read("src/test/resources/pd_solomon_r101.xml");
|
||||
vrp = builder.build();
|
||||
|
||||
final StateManager stateManager = new StateManager();
|
||||
final StateManager stateManager = new StateManager(vrp);
|
||||
|
||||
ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager);
|
||||
constraintManager.addTimeWindowConstraint();
|
||||
|
|
@ -63,8 +71,8 @@ public class BuildPDVRPAlgoFromScratchTest {
|
|||
// iBuilder.setConstraintManager(constraintManger);
|
||||
InsertionStrategy bestInsertion = iBuilder.build();
|
||||
|
||||
RuinRadial radial = new RuinRadial(vrp, 0.15, new JobDistanceAvgCosts(vrp.getTransportCosts()));
|
||||
RuinRandom random = new RuinRandom(vrp, 0.25);
|
||||
RuinStrategy radial = new RadialRuinStrategyFactory( 0.15, new AvgServiceDistance(vrp.getTransportCosts())).createStrategy(vrp);
|
||||
RuinStrategy random = new RandomRuinStrategyFactory(0.25).createStrategy(vrp);
|
||||
|
||||
SolutionCostCalculator solutionCostCalculator = new SolutionCostCalculator() {
|
||||
|
||||
|
|
@ -78,11 +86,11 @@ public class BuildPDVRPAlgoFromScratchTest {
|
|||
}
|
||||
};
|
||||
|
||||
SearchStrategy randomStrategy = new SearchStrategy(new SelectBest(), new AcceptNewIfBetterThanWorst(1), solutionCostCalculator);
|
||||
SearchStrategy randomStrategy = new SearchStrategy(new SelectBest(), new GreedyAcceptance(1), solutionCostCalculator);
|
||||
RuinAndRecreateModule randomModule = new RuinAndRecreateModule("randomRuin_bestInsertion", bestInsertion, random);
|
||||
randomStrategy.addModule(randomModule);
|
||||
|
||||
SearchStrategy radialStrategy = new SearchStrategy(new SelectBest(), new AcceptNewIfBetterThanWorst(1), solutionCostCalculator);
|
||||
SearchStrategy radialStrategy = new SearchStrategy(new SelectBest(), new GreedyAcceptance(1), solutionCostCalculator);
|
||||
RuinAndRecreateModule radialModule = new RuinAndRecreateModule("radialRuin_bestInsertion", bestInsertion, radial);
|
||||
radialStrategy.addModule(radialModule);
|
||||
|
||||
|
|
@ -90,11 +98,12 @@ public class BuildPDVRPAlgoFromScratchTest {
|
|||
strategyManager.addStrategy(radialStrategy, 0.5);
|
||||
strategyManager.addStrategy(randomStrategy, 0.5);
|
||||
|
||||
vra = new VehicleRoutingAlgorithmFactoryImpl(strategyManager, stateManager, fleetManager).createAlgorithm(vrp);
|
||||
vra = new VehicleRoutingAlgorithm(vrp, strategyManager);
|
||||
vra.addListener(stateManager);
|
||||
vra.addListener(new RemoveEmptyVehicles(fleetManager));
|
||||
|
||||
VehicleRoutingProblemSolution iniSolution = new InsertionInitialSolutionFactory(bestInsertion, solutionCostCalculator).createSolution(vrp);
|
||||
|
||||
// System.out.println("ini: costs="+iniSolution.getCost()+";#routes="+iniSolution.getRoutes().size());
|
||||
vra.addInitialSolution(iniSolution);
|
||||
vra.setNuOfIterations(1000);
|
||||
vra.setPrematureBreak(100);
|
||||
|
|
@ -104,9 +113,7 @@ public class BuildPDVRPAlgoFromScratchTest {
|
|||
@Test
|
||||
public void test(){
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
System.out.println(Solutions.getBest(solutions).getCost());
|
||||
// new VrpXMLWriter(vrp, solutions).write("output/pd_solomon_r101.xml");
|
||||
|
||||
System.out.println(Solutions.bestOf(solutions).getCost());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
/*******************************************************************************
|
||||
* 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 jsprit.core.algorithm;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import jsprit.core.algorithm.acceptor.GreedyAcceptance;
|
||||
import jsprit.core.algorithm.module.RuinAndRecreateModule;
|
||||
import jsprit.core.algorithm.recreate.BestInsertionBuilder;
|
||||
import jsprit.core.algorithm.recreate.InsertionStrategy;
|
||||
import jsprit.core.algorithm.ruin.RadialRuinStrategyFactory;
|
||||
import jsprit.core.algorithm.ruin.RandomRuinStrategyFactory;
|
||||
import jsprit.core.algorithm.ruin.RuinStrategy;
|
||||
import jsprit.core.algorithm.ruin.distance.AvgServiceAndShipmentDistance;
|
||||
import jsprit.core.algorithm.selector.SelectBest;
|
||||
import jsprit.core.algorithm.state.StateManager;
|
||||
import jsprit.core.algorithm.state.UpdateVariableCosts;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.constraint.ConstraintManager;
|
||||
import jsprit.core.problem.io.VrpXMLReader;
|
||||
import jsprit.core.problem.solution.SolutionCostCalculator;
|
||||
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import jsprit.core.problem.solution.route.state.StateFactory;
|
||||
import jsprit.core.problem.vehicle.InfiniteFleetManagerFactory;
|
||||
import jsprit.core.problem.vehicle.VehicleFleetManager;
|
||||
import jsprit.core.util.Solutions;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class BuildPDVRPWithShipmentsAlgoFromScratch_IT {
|
||||
|
||||
VehicleRoutingProblem vrp;
|
||||
|
||||
VehicleRoutingAlgorithm vra;
|
||||
|
||||
static Logger log = Logger.getLogger(BuildPDVRPWithShipmentsAlgoFromScratch_IT.class);
|
||||
|
||||
@Before
|
||||
public void setup(){
|
||||
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpXMLReader(builder).read("src/test/resources/pdp.xml");
|
||||
|
||||
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, StateFactory.COSTS).toDouble();
|
||||
}
|
||||
return costs;
|
||||
}
|
||||
};
|
||||
|
||||
SearchStrategy randomStrategy = new SearchStrategy(new SelectBest(), new GreedyAcceptance(1), solutionCostCalculator);
|
||||
RuinAndRecreateModule randomModule = new RuinAndRecreateModule("randomRuin_bestInsertion", bestInsertion, random);
|
||||
randomStrategy.addModule(randomModule);
|
||||
|
||||
SearchStrategy radialStrategy = new SearchStrategy(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);
|
||||
|
||||
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.setNuOfIterations(3);
|
||||
// vra.setPrematureBreak(500);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
VehicleRoutingProblemSolution best = Solutions.bestOf(solutions);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -14,13 +14,13 @@
|
|||
* 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 algorithms;
|
||||
package jsprit.core.algorithm;
|
||||
|
||||
import basics.costs.VehicleRoutingActivityCosts;
|
||||
import basics.route.Driver;
|
||||
import basics.route.TourActivity;
|
||||
import basics.route.TourActivity.JobActivity;
|
||||
import basics.route.Vehicle;
|
||||
import jsprit.core.problem.cost.VehicleRoutingActivityCosts;
|
||||
import jsprit.core.problem.driver.Driver;
|
||||
import jsprit.core.problem.solution.route.activity.TourActivity;
|
||||
import jsprit.core.problem.solution.route.activity.TourActivity.JobActivity;
|
||||
import jsprit.core.problem.vehicle.Vehicle;
|
||||
|
||||
|
||||
public class ExampleActivityCostFunction implements VehicleRoutingActivityCosts{
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
package jsprit.core.algorithm;
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2013 Stefan Schroeder
|
||||
*
|
||||
|
|
@ -0,0 +1,305 @@
|
|||
///*******************************************************************************
|
||||
// * 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 jsprit.core.algorithm;
|
||||
//
|
||||
//import static org.junit.Assert.assertEquals;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Arrays;
|
||||
//import java.util.Collection;
|
||||
//import java.util.List;
|
||||
//
|
||||
//import jsprit.core.algorithm.module.Gendreau;
|
||||
//import jsprit.core.algorithm.recreate.BestInsertion;
|
||||
//import jsprit.core.algorithm.recreate.InsertionStrategy;
|
||||
//import jsprit.core.algorithm.recreate.JobInsertionConsideringFixCostsCalculator;
|
||||
//import jsprit.core.algorithm.recreate.JobInsertionCostsCalculator;
|
||||
//import jsprit.core.algorithm.recreate.LocalActivityInsertionCostsCalculator;
|
||||
//import jsprit.core.algorithm.recreate.ServiceInsertionCalculator;
|
||||
//import jsprit.core.algorithm.recreate.VehicleSwitched;
|
||||
//import jsprit.core.algorithm.recreate.VehicleTypeDependentJobInsertionCalculator;
|
||||
//import jsprit.core.algorithm.ruin.RuinRadial;
|
||||
//import jsprit.core.algorithm.ruin.distance.JobDistanceAvgCosts;
|
||||
//import jsprit.core.algorithm.state.StateFactory;
|
||||
//import jsprit.core.algorithm.state.StateManager;
|
||||
//import jsprit.core.problem.VehicleRoutingProblem;
|
||||
//import jsprit.core.problem.constraint.TimeWindowConstraint;
|
||||
//import jsprit.core.problem.cost.VehicleRoutingActivityCosts;
|
||||
//import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||
//import jsprit.core.problem.driver.Driver;
|
||||
//import jsprit.core.problem.driver.DriverImpl;
|
||||
//import jsprit.core.problem.job.Job;
|
||||
//import jsprit.core.problem.job.Service;
|
||||
//import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
//import jsprit.core.problem.solution.route.VehicleRoute;
|
||||
//import jsprit.core.problem.solution.route.activity.ServiceActivity;
|
||||
//import jsprit.core.problem.solution.route.activity.TimeWindow;
|
||||
//import jsprit.core.problem.solution.route.activity.TourActivities;
|
||||
//import jsprit.core.problem.vehicle.FiniteFleetManagerFactory;
|
||||
//import jsprit.core.problem.vehicle.Vehicle;
|
||||
//import jsprit.core.problem.vehicle.VehicleFleetManager;
|
||||
//import jsprit.core.problem.vehicle.VehicleImpl;
|
||||
//import jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
//import jsprit.core.util.Coordinate;
|
||||
//import jsprit.core.util.ManhattanDistanceCalculator;
|
||||
//import jsprit.core.util.RouteUtils;
|
||||
//
|
||||
//import org.junit.Before;
|
||||
//import org.junit.Test;
|
||||
//
|
||||
//
|
||||
//public class GendreauPostOptTest {
|
||||
//
|
||||
// TourActivities tour;
|
||||
//
|
||||
// Vehicle heavyVehicle;
|
||||
//
|
||||
// Vehicle lightVehicle1;
|
||||
//
|
||||
// Vehicle lightVehicle2;
|
||||
//
|
||||
// VehicleRoutingTransportCosts cost;
|
||||
//
|
||||
// VehicleRoutingActivityCosts activityCosts;
|
||||
//
|
||||
// VehicleRoutingProblem vrp;
|
||||
//
|
||||
// Service job1;
|
||||
//
|
||||
// Service job2;
|
||||
//
|
||||
// Service job3;
|
||||
//
|
||||
// private StateManager states;
|
||||
//
|
||||
// private List<Vehicle> vehicles;
|
||||
//
|
||||
// private VehicleFleetManager fleetManager;
|
||||
//
|
||||
// private JobInsertionCostsCalculator insertionCalc;
|
||||
//
|
||||
// @Before
|
||||
// public void setUp(){
|
||||
//
|
||||
// cost = new VehicleRoutingTransportCosts() {
|
||||
//
|
||||
// @Override
|
||||
// public double getBackwardTransportTime(String fromId, String toId,
|
||||
// double arrivalTime, Driver driver, Vehicle vehicle) {
|
||||
// // TODO Auto-generated method stub
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public double getBackwardTransportCost(String fromId, String toId,
|
||||
// double arrivalTime, Driver driver, Vehicle vehicle) {
|
||||
// // TODO Auto-generated method stub
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public double getTransportCost(String fromId, String toId, double departureTime, Driver driver, Vehicle vehicle) {
|
||||
//
|
||||
// String[] fromTokens = fromId.split(",");
|
||||
// String[] toTokens = toId.split(",");
|
||||
// double fromX = Double.parseDouble(fromTokens[0]);
|
||||
// double fromY = Double.parseDouble(fromTokens[1]);
|
||||
//
|
||||
// double toX = Double.parseDouble(toTokens[0]);
|
||||
// double toY = Double.parseDouble(toTokens[1]);
|
||||
//
|
||||
// double costPerDistanceUnit;
|
||||
// if(vehicle != null){
|
||||
// costPerDistanceUnit = vehicle.getType().getVehicleCostParams().perDistanceUnit;
|
||||
// }
|
||||
// else{
|
||||
// costPerDistanceUnit = 1;
|
||||
// }
|
||||
//
|
||||
// return costPerDistanceUnit*ManhattanDistanceCalculator.calculateDistance(new Coordinate(fromX, fromY), new Coordinate(toX, toY));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public double getTransportTime(String fromId, String toId, double departureTime, Driver driver, Vehicle vehicle) {
|
||||
// return 0;
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// VehicleTypeImpl lightType = VehicleTypeImpl.Builder.newInstance("light", 10).setFixedCost(10).setCostPerDistance(1.0).build();
|
||||
// VehicleTypeImpl heavyType = VehicleTypeImpl.Builder.newInstance("heavy", 10).setFixedCost(30).setCostPerDistance(2.0).build();
|
||||
//
|
||||
// lightVehicle1 = VehicleImpl.Builder.newInstance("light").setLocationId("0,0").setType(lightType).build();
|
||||
// lightVehicle2 = VehicleImpl.Builder.newInstance("light2").setLocationId("0,0").setType(lightType).build();
|
||||
// heavyVehicle = VehicleImpl.Builder.newInstance("heavy").setLocationId("0,0").setType(heavyType).build();
|
||||
//
|
||||
//
|
||||
// job1 = getService("10,0");
|
||||
// job2 = getService("10,10");
|
||||
// job3 = getService("0,10");
|
||||
//
|
||||
// Collection<Job> jobs = new ArrayList<Job>();
|
||||
// jobs.add(job1);
|
||||
// jobs.add(job2);
|
||||
// jobs.add(job3);
|
||||
//
|
||||
// vehicles = Arrays.asList(lightVehicle1,lightVehicle2, heavyVehicle);
|
||||
//
|
||||
//// Collection<Vehicle> vehicles = Arrays.asList(lightVehicle1,lightVehicle2, heavyVehicle);
|
||||
// fleetManager = new FiniteFleetManagerFactory(vehicles).createFleetManager();
|
||||
// states = new StateManager();
|
||||
//
|
||||
// activityCosts = new ExampleActivityCostFunction();
|
||||
//
|
||||
//
|
||||
// ServiceInsertionCalculator standardServiceInsertion = new ServiceInsertionCalculator(cost, new LocalActivityInsertionCostsCalculator(cost, activityCosts), new LoadConstraint(states), new TimeWindowConstraint(states, cost));
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// JobInsertionConsideringFixCostsCalculator withFixCost = new JobInsertionConsideringFixCostsCalculator(standardServiceInsertion, states);
|
||||
// withFixCost.setWeightOfFixCost(1.2);
|
||||
//
|
||||
// insertionCalc = new VehicleTypeDependentJobInsertionCalculator(fleetManager, withFixCost);
|
||||
//
|
||||
//// updater = new TourStateUpdater(states, cost, activityCosts);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void whenPostOpt_splitsTour_oneActiveTourBecomeTwoSeperateActiveTours(){
|
||||
// Collection<Job> jobs = new ArrayList<Job>();
|
||||
// jobs.add(job1);
|
||||
// jobs.add(job2);
|
||||
//
|
||||
// vrp = VehicleRoutingProblem.Builder.newInstance().addAllJobs(jobs).addAllVehicles(vehicles).setRoutingCost(cost).build();
|
||||
//
|
||||
// TourActivities tour = new TourActivities();
|
||||
// tour.addActivity(ServiceActivity.newInstance(job1));
|
||||
// tour.addActivity(ServiceActivity.newInstance(job2));
|
||||
//
|
||||
// VehicleRoute route = VehicleRoute.newInstance(tour,DriverImpl.noDriver(),heavyVehicle);
|
||||
//
|
||||
// fleetManager.lock(heavyVehicle);
|
||||
//
|
||||
// UpdateStates stateUpdater = new UpdateStates(states, vrp.getTransportCosts(), vrp.getActivityCosts());
|
||||
// stateUpdater.update(route);
|
||||
//
|
||||
// Collection<VehicleRoute> routes = new ArrayList<VehicleRoute>();
|
||||
// routes.add(route);
|
||||
//// routes.add(new VehicleRoute(getEmptyTour(),getDriver(),getNoVehicle()));
|
||||
//// routes.add(new VehicleRoute(getEmptyTour(),getDriver(),getNoVehicle()));
|
||||
//
|
||||
//
|
||||
// VehicleRoutingProblemSolution sol = new VehicleRoutingProblemSolution(routes, states.getRouteState(route, StateFactory.COSTS).toDouble() + getFixedCosts(routes));
|
||||
//
|
||||
//
|
||||
// assertEquals(110.0, sol.getCost(), 0.5);
|
||||
//
|
||||
//
|
||||
// RuinRadial radialRuin = new RuinRadial(vrp, 0.2, new JobDistanceAvgCosts(vrp.getTransportCosts()));
|
||||
//// radialRuin.addListener(stateUpdater);
|
||||
//
|
||||
// InsertionStrategy insertionStrategy = new BestInsertion(insertionCalc);
|
||||
// insertionStrategy.addListener(stateUpdater);
|
||||
// insertionStrategy.addListener(new VehicleSwitched(fleetManager));
|
||||
// Gendreau postOpt = new Gendreau(vrp, radialRuin, insertionStrategy, fleetManager);
|
||||
//
|
||||
// VehicleRoutingProblemSolution newSolution = postOpt.runAndGetSolution(sol);
|
||||
// newSolution.setCost(getCosts(newSolution,states));
|
||||
//
|
||||
// assertEquals(2,RouteUtils.getNuOfActiveRoutes(newSolution.getRoutes()));
|
||||
// assertEquals(2,newSolution.getRoutes().size());
|
||||
// assertEquals(80.0,newSolution.getCost(),0.5);
|
||||
// }
|
||||
//
|
||||
// private double getFixedCosts(Collection<VehicleRoute> routes) {
|
||||
// double c = 0.0;
|
||||
// for(VehicleRoute r : routes){ c += r.getVehicle().getType().getVehicleCostParams().fix; }
|
||||
// return c;
|
||||
// }
|
||||
//
|
||||
// private double getCosts(VehicleRoutingProblemSolution newSolution, StateManager states) {
|
||||
// double c = 0.0;
|
||||
// for(VehicleRoute r : newSolution.getRoutes()){
|
||||
//
|
||||
// c += states.getRouteState(r, StateFactory.COSTS).toDouble() + r.getVehicle().getType().getVehicleCostParams().fix;
|
||||
//
|
||||
// }
|
||||
// return c;
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void whenPostOpt_optsRoutesWithMoreThanTwoJobs_oneRouteBecomesTwoRoutes(){
|
||||
// Collection<Job> jobs = new ArrayList<Job>();
|
||||
// jobs.add(job1);
|
||||
// jobs.add(job2);
|
||||
// jobs.add(job3);
|
||||
//
|
||||
// vrp = VehicleRoutingProblem.Builder.newInstance().addAllJobs(jobs).addAllVehicles(vehicles).setRoutingCost(cost).build();
|
||||
//
|
||||
// TourActivities tour = new TourActivities();
|
||||
// tour.addActivity(ServiceActivity.newInstance(job1));
|
||||
// tour.addActivity(ServiceActivity.newInstance(job2));
|
||||
// tour.addActivity(ServiceActivity.newInstance(job3));
|
||||
//
|
||||
// VehicleRoute route = VehicleRoute.newInstance(tour,DriverImpl.noDriver(),heavyVehicle);
|
||||
//
|
||||
// UpdateStates stateUpdater = new UpdateStates(states, vrp.getTransportCosts(), vrp.getActivityCosts());
|
||||
// stateUpdater.update(route);
|
||||
//
|
||||
// fleetManager.lock(heavyVehicle);
|
||||
//
|
||||
// Collection<VehicleRoute> routes = new ArrayList<VehicleRoute>();
|
||||
// routes.add(route);
|
||||
//
|
||||
// VehicleRoutingProblemSolution sol = new VehicleRoutingProblemSolution(routes, route.getCost());
|
||||
// sol.setCost(getCosts(sol,states));
|
||||
//
|
||||
// assertEquals(110.0, sol.getCost(), 0.5);
|
||||
//
|
||||
// RuinRadial radialRuin = new RuinRadial(vrp, 0.2, new JobDistanceAvgCosts(vrp.getTransportCosts()));
|
||||
// InsertionStrategy insertionStrategy = new BestInsertion(insertionCalc);
|
||||
// insertionStrategy.addListener(stateUpdater);
|
||||
// insertionStrategy.addListener(new VehicleSwitched(fleetManager));
|
||||
// Gendreau postOpt = new Gendreau(vrp, radialRuin, insertionStrategy, fleetManager);
|
||||
// postOpt.setShareOfJobsToRuin(1.0);
|
||||
// postOpt.setNuOfIterations(1);
|
||||
//
|
||||
//// postOpt.setWithFix(withFixCost);
|
||||
// VehicleRoutingProblemSolution newSolution = postOpt.runAndGetSolution(sol);
|
||||
// newSolution.setCost(getCosts(newSolution,states));
|
||||
//
|
||||
// assertEquals(2,RouteUtils.getNuOfActiveRoutes(newSolution.getRoutes()));
|
||||
// assertEquals(2,newSolution.getRoutes().size());
|
||||
// assertEquals(80.0,newSolution.getCost(),0.5);
|
||||
// }
|
||||
//
|
||||
// private Service getService(String to, double serviceTime) {
|
||||
// Service s = Service.Builder.newInstance(to, 0).setLocationId(to).setServiceTime(serviceTime).setTimeWindow(TimeWindow.newInstance(0.0, 20.0)).build();
|
||||
//
|
||||
// return s;
|
||||
// }
|
||||
//
|
||||
// private Service getService(String to) {
|
||||
// Service s = getService(to, 0.0);
|
||||
// return s;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package algorithms;
|
||||
package jsprit.core.algorithm;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
|
@ -26,24 +26,25 @@ import java.io.IOException;
|
|||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import jsprit.core.algorithm.box.GreedySchrimpfFactory;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
||||
import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||
import jsprit.core.problem.driver.Driver;
|
||||
import jsprit.core.problem.job.Service;
|
||||
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import jsprit.core.problem.vehicle.Vehicle;
|
||||
import jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
import jsprit.core.util.Solutions;
|
||||
import jsprit.core.util.VehicleRoutingTransportCostsMatrix;
|
||||
import jsprit.core.util.VehicleRoutingTransportCostsMatrix.Builder;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import util.Solutions;
|
||||
import util.VehicleRoutingTransportCostsMatrix;
|
||||
import util.VehicleRoutingTransportCostsMatrix.Builder;
|
||||
import basics.Service;
|
||||
import basics.VehicleRoutingAlgorithm;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblem.FleetSize;
|
||||
import basics.VehicleRoutingProblemSolution;
|
||||
import basics.costs.VehicleRoutingTransportCosts;
|
||||
import basics.route.Driver;
|
||||
import basics.route.Vehicle;
|
||||
import basics.route.VehicleImpl;
|
||||
import basics.route.VehicleTypeImpl;
|
||||
|
||||
|
||||
public class RefuseCollectionTest {
|
||||
public class RefuseCollection_IT {
|
||||
|
||||
static class RelationKey {
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package basics.algo;
|
||||
package jsprit.core.algorithm;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
|
@ -25,6 +25,9 @@ import static org.mockito.Mockito.when;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import jsprit.core.algorithm.SearchStrategy;
|
||||
import jsprit.core.algorithm.SearchStrategyManager;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package basics.algo;
|
||||
package jsprit.core.algorithm;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
|
@ -24,12 +24,17 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.Random;
|
||||
|
||||
import jsprit.core.algorithm.SearchStrategy;
|
||||
import jsprit.core.algorithm.SearchStrategyModule;
|
||||
import jsprit.core.algorithm.acceptor.SolutionAcceptor;
|
||||
import jsprit.core.algorithm.listener.SearchStrategyModuleListener;
|
||||
import jsprit.core.algorithm.selector.SolutionSelector;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.solution.SolutionCostCalculator;
|
||||
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import algorithms.acceptors.SolutionAcceptor;
|
||||
import algorithms.selectors.SolutionSelector;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblemSolution;
|
||||
|
||||
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package algorithms.acceptors;
|
||||
package jsprit.core.algorithm.acceptor;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -25,10 +25,12 @@ import static org.mockito.Mockito.when;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import jsprit.core.algorithm.acceptor.GreedyAcceptance;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblemSolution;
|
||||
|
||||
|
||||
|
||||
|
|
@ -49,7 +51,7 @@ public class AcceptNewRemoveWorstTest {
|
|||
|
||||
VehicleRoutingProblemSolution sol3 = mock(VehicleRoutingProblemSolution.class);
|
||||
|
||||
new AcceptNewIfBetterThanWorst(2).acceptSolution(solList, sol3);
|
||||
new GreedyAcceptance(2).acceptSolution(solList, sol3);
|
||||
|
||||
assertEquals(2,solList.size());
|
||||
assertThat(sol3,is(solList.get(1)));
|
||||
|
|
@ -14,12 +14,14 @@
|
|||
* 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 algorithms;
|
||||
package jsprit.core.algorithm.box;
|
||||
|
||||
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import jsprit.core.algorithm.box.SchrimpfFactory;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import basics.VehicleRoutingAlgorithm;
|
||||
import basics.VehicleRoutingProblem;
|
||||
|
||||
public class TestSchrimpf {
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package algorithms;
|
||||
package jsprit.core.algorithm.io;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
|
@ -22,30 +22,33 @@ import static org.junit.Assert.assertTrue;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import jsprit.core.algorithm.SearchStrategy;
|
||||
import jsprit.core.algorithm.SearchStrategyModule;
|
||||
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import jsprit.core.algorithm.acceptor.GreedyAcceptance;
|
||||
import jsprit.core.algorithm.acceptor.SolutionAcceptor;
|
||||
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms.ModKey;
|
||||
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap.AcceptorKey;
|
||||
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap.RuinStrategyKey;
|
||||
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap.SelectorKey;
|
||||
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap.StrategyModuleKey;
|
||||
import jsprit.core.algorithm.listener.SearchStrategyModuleListener;
|
||||
import jsprit.core.algorithm.ruin.RuinStrategy;
|
||||
import jsprit.core.algorithm.ruin.listener.RuinListener;
|
||||
import jsprit.core.algorithm.selector.SelectBest;
|
||||
import jsprit.core.algorithm.selector.SolutionSelector;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.io.VrpXMLReader;
|
||||
import jsprit.core.problem.job.Job;
|
||||
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import jsprit.core.problem.solution.route.VehicleRoute;
|
||||
|
||||
import org.apache.commons.configuration.ConfigurationException;
|
||||
import org.apache.commons.configuration.XMLConfiguration;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import algorithms.VehicleRoutingAlgorithms.ModKey;
|
||||
import algorithms.VehicleRoutingAlgorithms.TypedMap.AcceptorKey;
|
||||
import algorithms.VehicleRoutingAlgorithms.TypedMap.RuinStrategyKey;
|
||||
import algorithms.VehicleRoutingAlgorithms.TypedMap.SelectorKey;
|
||||
import algorithms.VehicleRoutingAlgorithms.TypedMap.StrategyModuleKey;
|
||||
import algorithms.acceptors.AcceptNewIfBetterThanWorst;
|
||||
import algorithms.acceptors.SolutionAcceptor;
|
||||
import algorithms.selectors.SelectBest;
|
||||
import algorithms.selectors.SolutionSelector;
|
||||
import basics.Job;
|
||||
import basics.VehicleRoutingAlgorithm;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblemSolution;
|
||||
import basics.algo.RuinListener;
|
||||
import basics.algo.SearchStrategy;
|
||||
import basics.algo.SearchStrategyModule;
|
||||
import basics.algo.SearchStrategyModuleListener;
|
||||
import basics.io.VrpXMLReader;
|
||||
import basics.route.VehicleRoute;
|
||||
|
||||
public class TestAlgorithmReader {
|
||||
|
||||
|
|
@ -66,7 +69,7 @@ public class TestAlgorithmReader {
|
|||
|
||||
@Test
|
||||
public void testTypedMap(){
|
||||
algorithms.VehicleRoutingAlgorithms.TypedMap typedMap = new algorithms.VehicleRoutingAlgorithms.TypedMap();
|
||||
jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap typedMap = new jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap();
|
||||
|
||||
String acceptorName = "acceptor";
|
||||
String acceptorId = "acceptorId";
|
||||
|
|
@ -74,7 +77,7 @@ public class TestAlgorithmReader {
|
|||
ModKey key = new ModKey(acceptorName,acceptorId);
|
||||
AcceptorKey accKey = new AcceptorKey(key);
|
||||
|
||||
SolutionAcceptor acceptor = new AcceptNewIfBetterThanWorst(1);
|
||||
SolutionAcceptor acceptor = new GreedyAcceptance(1);
|
||||
|
||||
typedMap.put(accKey, acceptor);
|
||||
|
||||
|
|
@ -84,7 +87,7 @@ public class TestAlgorithmReader {
|
|||
|
||||
@Test
|
||||
public void testTypedMap2(){
|
||||
algorithms.VehicleRoutingAlgorithms.TypedMap typedMap = new algorithms.VehicleRoutingAlgorithms.TypedMap();
|
||||
jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap typedMap = new jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap();
|
||||
|
||||
String acceptorName = "acceptor";
|
||||
String acceptorId = "acceptorId";
|
||||
|
|
@ -94,7 +97,7 @@ public class TestAlgorithmReader {
|
|||
|
||||
ModKey key = new ModKey(acceptorName,acceptorId);
|
||||
AcceptorKey accKey = new AcceptorKey(key);
|
||||
SolutionAcceptor acceptor = new AcceptNewIfBetterThanWorst(1);
|
||||
SolutionAcceptor acceptor = new GreedyAcceptance(1);
|
||||
|
||||
SelectorKey selKey = new SelectorKey(new ModKey(selectorName,selectorId));
|
||||
SolutionSelector selector = new SelectBest();
|
||||
|
|
@ -108,7 +111,7 @@ public class TestAlgorithmReader {
|
|||
|
||||
@Test
|
||||
public void testTypedMap3(){
|
||||
algorithms.VehicleRoutingAlgorithms.TypedMap typedMap = new algorithms.VehicleRoutingAlgorithms.TypedMap();
|
||||
jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap typedMap = new jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap();
|
||||
|
||||
String acceptorName = "acceptor";
|
||||
String acceptorId = "acceptorId";
|
||||
|
|
@ -121,13 +124,13 @@ public class TestAlgorithmReader {
|
|||
|
||||
ModKey key = new ModKey(acceptorName,acceptorId);
|
||||
AcceptorKey accKey = new AcceptorKey(key);
|
||||
SolutionAcceptor acceptor = new AcceptNewIfBetterThanWorst(1);
|
||||
SolutionAcceptor acceptor = new GreedyAcceptance(1);
|
||||
|
||||
SelectorKey selKey = new SelectorKey(new ModKey(selectorName,selectorId));
|
||||
SolutionSelector selector = new SelectBest();
|
||||
|
||||
AcceptorKey accKey2 = new AcceptorKey(new ModKey(acceptorName2,acceptorId2));
|
||||
SolutionAcceptor acceptor2 = new AcceptNewIfBetterThanWorst(1);
|
||||
SolutionAcceptor acceptor2 = new GreedyAcceptance(1);
|
||||
|
||||
typedMap.put(accKey, acceptor);
|
||||
typedMap.put(selKey, selector);
|
||||
|
|
@ -140,7 +143,7 @@ public class TestAlgorithmReader {
|
|||
|
||||
@Test
|
||||
public void testTypedMap4(){
|
||||
algorithms.VehicleRoutingAlgorithms.TypedMap typedMap = new algorithms.VehicleRoutingAlgorithms.TypedMap();
|
||||
jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap typedMap = new jsprit.core.algorithm.io.VehicleRoutingAlgorithms.TypedMap();
|
||||
|
||||
String acceptorName = "acceptor";
|
||||
String acceptorId = "acceptorId";
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package algorithms;
|
||||
package jsprit.core.algorithm.recreate;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
|
@ -23,16 +23,17 @@ import static org.mockito.Mockito.when;
|
|||
|
||||
import java.util.Arrays;
|
||||
|
||||
import jsprit.core.problem.job.Service;
|
||||
import jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import jsprit.core.problem.solution.route.activity.TimeWindow;
|
||||
import jsprit.core.problem.vehicle.Vehicle;
|
||||
import jsprit.core.problem.vehicle.VehicleFleetManager;
|
||||
import jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import basics.Service;
|
||||
import basics.route.TimeWindow;
|
||||
import basics.route.Vehicle;
|
||||
import basics.route.VehicleFleetManager;
|
||||
import basics.route.VehicleImpl;
|
||||
import basics.route.VehicleRoute;
|
||||
import basics.route.VehicleTypeImpl;
|
||||
|
||||
|
||||
|
||||
|
|
@ -14,26 +14,28 @@
|
|||
* 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 algorithms;
|
||||
package jsprit.core.algorithm.recreate;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import util.Coordinate;
|
||||
import util.CrowFlyCosts;
|
||||
import util.Solutions;
|
||||
import basics.Service;
|
||||
import basics.VehicleRoutingAlgorithm;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblem.FleetSize;
|
||||
import basics.VehicleRoutingProblemSolution;
|
||||
import basics.costs.VehicleRoutingTransportCosts;
|
||||
import basics.route.Driver;
|
||||
import basics.route.Vehicle;
|
||||
import basics.route.VehicleImpl;
|
||||
import basics.route.VehicleRoute;
|
||||
import basics.route.VehicleTypeImpl;
|
||||
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
||||
import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||
import jsprit.core.problem.driver.Driver;
|
||||
import jsprit.core.problem.job.Service;
|
||||
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import jsprit.core.problem.vehicle.Vehicle;
|
||||
import jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
import jsprit.core.util.Coordinate;
|
||||
import jsprit.core.util.CrowFlyCosts;
|
||||
import jsprit.core.util.Solutions;
|
||||
|
||||
|
||||
public class CalcWithTimeSchedulingTest {
|
||||
|
||||
|
|
@ -1,30 +1,44 @@
|
|||
package algorithms;
|
||||
package jsprit.core.algorithm.recreate;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import jsprit.core.algorithm.recreate.ActivityInsertionCostsCalculator;
|
||||
import jsprit.core.algorithm.recreate.Inserter;
|
||||
import jsprit.core.algorithm.recreate.InsertionData;
|
||||
import jsprit.core.algorithm.recreate.JobCalculatorSwitcher;
|
||||
import jsprit.core.algorithm.recreate.LocalActivityInsertionCostsCalculator;
|
||||
import jsprit.core.algorithm.recreate.ServiceInsertionCalculator;
|
||||
import jsprit.core.algorithm.recreate.ShipmentInsertionCalculator;
|
||||
import jsprit.core.algorithm.recreate.listener.InsertionListeners;
|
||||
import jsprit.core.algorithm.state.StateManager;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.constraint.ConstraintManager;
|
||||
import jsprit.core.problem.constraint.HardActivityStateLevelConstraint;
|
||||
import jsprit.core.problem.constraint.HardRouteStateLevelConstraint;
|
||||
import jsprit.core.problem.cost.VehicleRoutingActivityCosts;
|
||||
import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||
import jsprit.core.problem.driver.Driver;
|
||||
import jsprit.core.problem.driver.DriverImpl;
|
||||
import jsprit.core.problem.job.Delivery;
|
||||
import jsprit.core.problem.job.Pickup;
|
||||
import jsprit.core.problem.job.Shipment;
|
||||
import jsprit.core.problem.misc.JobInsertionContext;
|
||||
import jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import jsprit.core.problem.solution.route.activity.TourActivity;
|
||||
import jsprit.core.problem.vehicle.Vehicle;
|
||||
import jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import jsprit.core.problem.vehicle.VehicleType;
|
||||
import jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
import jsprit.core.util.Coordinate;
|
||||
import jsprit.core.util.Locations;
|
||||
import jsprit.core.util.ManhattanCosts;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import util.Coordinate;
|
||||
import util.Locations;
|
||||
import util.ManhattanCosts;
|
||||
import basics.Delivery;
|
||||
import basics.Pickup;
|
||||
import basics.Shipment;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.costs.VehicleRoutingActivityCosts;
|
||||
import basics.costs.VehicleRoutingTransportCosts;
|
||||
import basics.route.Driver;
|
||||
import basics.route.DriverImpl;
|
||||
import basics.route.TourActivity;
|
||||
import basics.route.Vehicle;
|
||||
import basics.route.VehicleImpl;
|
||||
import basics.route.VehicleRoute;
|
||||
import basics.route.VehicleType;
|
||||
import basics.route.VehicleTypeImpl;
|
||||
|
||||
public class ServiceInsertionAndLoadConstraintsTest {
|
||||
|
||||
|
|
@ -42,7 +56,7 @@ public class ServiceInsertionAndLoadConstraintsTest {
|
|||
HardActivityStateLevelConstraint hardActivityLevelConstraint = new HardActivityStateLevelConstraint() {
|
||||
|
||||
@Override
|
||||
public ConstraintsStatus fulfilled(InsertionContext iFacts, TourActivity prevAct,TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
|
||||
public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prevAct,TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
|
||||
return ConstraintsStatus.FULFILLED;
|
||||
}
|
||||
};
|
||||
|
|
@ -50,7 +64,7 @@ public class ServiceInsertionAndLoadConstraintsTest {
|
|||
HardRouteStateLevelConstraint hardRouteLevelConstraint = new HardRouteStateLevelConstraint(){
|
||||
|
||||
@Override
|
||||
public boolean fulfilled(InsertionContext insertionContext) {
|
||||
public boolean fulfilled(JobInsertionContext insertionContext) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +117,7 @@ public class ServiceInsertionAndLoadConstraintsTest {
|
|||
// inserter.insertJob(shipment2, new InsertionData(0,1,2,vehicle,null), route);
|
||||
// inserter.insertJob(shipment2, new InsertionData(0,1,2,vehicle,null), route);
|
||||
|
||||
StateManager stateManager = new StateManager();
|
||||
|
||||
|
||||
// RouteActivityVisitor routeActVisitor = new RouteActivityVisitor();
|
||||
// routeActVisitor.addActivityVisitor(new UpdateLoads(stateManager));
|
||||
|
|
@ -111,6 +125,9 @@ public class ServiceInsertionAndLoadConstraintsTest {
|
|||
|
||||
VehicleRoutingProblem vrp = mock(VehicleRoutingProblem.class);
|
||||
|
||||
StateManager stateManager = new StateManager(vrp);
|
||||
stateManager.updateLoadStates();
|
||||
|
||||
ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager);
|
||||
constraintManager.addLoadConstraint();
|
||||
// constraintManager.addConstraint(new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager),Priority.CRITICAL);
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package algorithms;
|
||||
package jsprit.core.algorithm.recreate;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
|
@ -6,27 +6,36 @@ import static org.mockito.Mockito.mock;
|
|||
|
||||
import java.util.Arrays;
|
||||
|
||||
import jsprit.core.algorithm.recreate.listener.InsertionListeners;
|
||||
import jsprit.core.algorithm.state.StateManager;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.constraint.ConstraintManager;
|
||||
import jsprit.core.problem.constraint.ConstraintManager.Priority;
|
||||
import jsprit.core.problem.constraint.HardActivityStateLevelConstraint;
|
||||
import jsprit.core.problem.constraint.HardRouteStateLevelConstraint;
|
||||
import jsprit.core.problem.constraint.PickupAndDeliverShipmentLoadActivityLevelConstraint;
|
||||
import jsprit.core.problem.constraint.ShipmentPickupsFirstConstraint;
|
||||
import jsprit.core.problem.cost.VehicleRoutingActivityCosts;
|
||||
import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||
import jsprit.core.problem.driver.Driver;
|
||||
import jsprit.core.problem.driver.DriverImpl;
|
||||
import jsprit.core.problem.job.Pickup;
|
||||
import jsprit.core.problem.job.Shipment;
|
||||
import jsprit.core.problem.misc.JobInsertionContext;
|
||||
import jsprit.core.problem.solution.route.RouteActivityVisitor;
|
||||
import jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import jsprit.core.problem.solution.route.activity.TourActivity;
|
||||
import jsprit.core.problem.vehicle.Vehicle;
|
||||
import jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import jsprit.core.problem.vehicle.VehicleType;
|
||||
import jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
import jsprit.core.util.Coordinate;
|
||||
import jsprit.core.util.Locations;
|
||||
import jsprit.core.util.ManhattanCosts;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import util.Coordinate;
|
||||
import util.Locations;
|
||||
import util.ManhattanCosts;
|
||||
import algorithms.ConstraintManager.Priority;
|
||||
import basics.Pickup;
|
||||
import basics.Shipment;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.costs.VehicleRoutingActivityCosts;
|
||||
import basics.costs.VehicleRoutingTransportCosts;
|
||||
import basics.route.Driver;
|
||||
import basics.route.DriverImpl;
|
||||
import basics.route.RouteActivityVisitor;
|
||||
import basics.route.TourActivity;
|
||||
import basics.route.Vehicle;
|
||||
import basics.route.VehicleImpl;
|
||||
import basics.route.VehicleRoute;
|
||||
import basics.route.VehicleType;
|
||||
import basics.route.VehicleTypeImpl;
|
||||
|
||||
public class ShipmentInsertionCalculatorTest {
|
||||
|
||||
|
|
@ -44,7 +53,7 @@ public class ShipmentInsertionCalculatorTest {
|
|||
HardActivityStateLevelConstraint hardActivityLevelConstraint = new HardActivityStateLevelConstraint() {
|
||||
|
||||
@Override
|
||||
public ConstraintsStatus fulfilled(InsertionContext iFacts, TourActivity prevAct,TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
|
||||
public ConstraintsStatus fulfilled(JobInsertionContext iFacts, TourActivity prevAct,TourActivity newAct, TourActivity nextAct, double prevActDepTime) {
|
||||
return ConstraintsStatus.FULFILLED;
|
||||
}
|
||||
};
|
||||
|
|
@ -52,7 +61,7 @@ public class ShipmentInsertionCalculatorTest {
|
|||
HardRouteStateLevelConstraint hardRouteLevelConstraint = new HardRouteStateLevelConstraint(){
|
||||
|
||||
@Override
|
||||
public boolean fulfilled(InsertionContext insertionContext) {
|
||||
public boolean fulfilled(JobInsertionContext insertionContext) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -119,7 +128,7 @@ public class ShipmentInsertionCalculatorTest {
|
|||
createInsertionCalculator(new HardRouteStateLevelConstraint() {
|
||||
|
||||
@Override
|
||||
public boolean fulfilled(InsertionContext insertionContext) {
|
||||
public boolean fulfilled(JobInsertionContext insertionContext) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -180,14 +189,12 @@ public class ShipmentInsertionCalculatorTest {
|
|||
inserter.insertJob(shipment, new InsertionData(0,0,0,vehicle,null), route);
|
||||
inserter.insertJob(shipment2, new InsertionData(0,1,2,vehicle,null), route);
|
||||
|
||||
StateManager stateManager = new StateManager();
|
||||
|
||||
RouteActivityVisitor routeActVisitor = new RouteActivityVisitor();
|
||||
routeActVisitor.addActivityVisitor(new UpdateLoads(stateManager));
|
||||
routeActVisitor.visit(route);
|
||||
|
||||
VehicleRoutingProblem vrp = mock(VehicleRoutingProblem.class);
|
||||
|
||||
StateManager stateManager = new StateManager(vrp);
|
||||
stateManager.updateLoadStates();
|
||||
stateManager.informInsertionStarts(Arrays.asList(route), null);
|
||||
|
||||
ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager);
|
||||
constraintManager.addConstraint(new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager),Priority.CRITICAL);
|
||||
constraintManager.addConstraint(new ShipmentPickupsFirstConstraint(),Priority.CRITICAL);
|
||||
|
|
@ -216,13 +223,17 @@ public class ShipmentInsertionCalculatorTest {
|
|||
inserter.insertJob(shipment2, new InsertionData(0,1,2,vehicle,null), route);
|
||||
// inserter.insertJob(shipment2, new InsertionData(0,1,2,vehicle,null), route);
|
||||
|
||||
StateManager stateManager = new StateManager();
|
||||
VehicleRoutingProblem vrp = mock(VehicleRoutingProblem.class);
|
||||
|
||||
StateManager stateManager = new StateManager(vrp);
|
||||
stateManager.updateLoadStates();
|
||||
stateManager.informInsertionStarts(Arrays.asList(route), null);
|
||||
|
||||
// RouteActivityVisitor routeActVisitor = new RouteActivityVisitor();
|
||||
// routeActVisitor.addActivityVisitor(new UpdateLoads(stateManager));
|
||||
// routeActVisitor.visit(route);
|
||||
|
||||
VehicleRoutingProblem vrp = mock(VehicleRoutingProblem.class);
|
||||
|
||||
|
||||
ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager);
|
||||
constraintManager.addLoadConstraint();
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
package jsprit.core.algorithm.recreate;
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2013 Stefan Schroeder
|
||||
*
|
||||
|
|
@ -14,31 +14,37 @@
|
|||
* 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 algorithms;
|
||||
package jsprit.core.algorithm.recreate;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import jsprit.core.algorithm.ExampleActivityCostFunction;
|
||||
import jsprit.core.algorithm.state.StateManager;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.constraint.ConstraintManager;
|
||||
import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||
import jsprit.core.problem.driver.DriverImpl;
|
||||
import jsprit.core.problem.driver.DriverImpl.NoDriver;
|
||||
import jsprit.core.problem.job.Job;
|
||||
import jsprit.core.problem.job.Service;
|
||||
import jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import jsprit.core.problem.solution.route.activity.ServiceActivity;
|
||||
import jsprit.core.problem.solution.route.activity.TimeWindow;
|
||||
import jsprit.core.problem.solution.route.activity.TourActivities;
|
||||
import jsprit.core.problem.solution.route.activity.TourActivity;
|
||||
import jsprit.core.problem.vehicle.Vehicle;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import basics.Job;
|
||||
import basics.Service;
|
||||
import basics.costs.VehicleRoutingTransportCosts;
|
||||
import basics.route.DriverImpl;
|
||||
import basics.route.DriverImpl.NoDriver;
|
||||
import basics.route.ServiceActivity;
|
||||
import basics.route.TimeWindow;
|
||||
import basics.route.TourActivities;
|
||||
import basics.route.TourActivity;
|
||||
import basics.route.Vehicle;
|
||||
import basics.route.VehicleRoute;
|
||||
|
||||
|
||||
|
||||
|
|
@ -62,7 +68,7 @@ public class TestCalculatesServiceInsertion {
|
|||
|
||||
private NoDriver driver;
|
||||
|
||||
private UpdateStates stateUpdater;
|
||||
// private UpdateStates stateUpdater;
|
||||
|
||||
@Before
|
||||
public void setup(){
|
||||
|
|
@ -148,15 +154,23 @@ public class TestCalculatesServiceInsertion {
|
|||
jobs.add(second);
|
||||
jobs.add(third);
|
||||
|
||||
states = new StateManager();
|
||||
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addAllJobs(jobs).addVehicle(vehicle).setRoutingCost(costs).build();
|
||||
|
||||
states = new StateManager(vrp);
|
||||
states.updateLoadStates();
|
||||
states.updateTimeWindowStates();
|
||||
|
||||
ConstraintManager cManager = new ConstraintManager(vrp,states);
|
||||
cManager.addLoadConstraint();
|
||||
cManager.addTimeWindowConstraint();
|
||||
|
||||
ExampleActivityCostFunction activityCosts = new ExampleActivityCostFunction();
|
||||
|
||||
|
||||
serviceInsertion = new ServiceInsertionCalculator(costs, new LocalActivityInsertionCostsCalculator(costs, activityCosts), new LoadConstraint(states), new TimeWindowConstraint(states, costs));
|
||||
serviceInsertion = new ServiceInsertionCalculator(costs, new LocalActivityInsertionCostsCalculator(costs, activityCosts), cManager, cManager);
|
||||
|
||||
|
||||
stateUpdater = new UpdateStates(states, costs, activityCosts);
|
||||
// stateUpdater = new UpdateStates(states, costs, activityCosts);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -171,7 +185,8 @@ public class TestCalculatesServiceInsertion {
|
|||
TourActivities tour = new TourActivities();
|
||||
|
||||
VehicleRoute route = VehicleRoute.newInstance(tour,driver,vehicle);
|
||||
stateUpdater.update(route);
|
||||
states.informInsertionStarts(Arrays.asList(route), null);
|
||||
// stateUpdater.update(route);
|
||||
|
||||
InsertionData iData = serviceInsertion.getInsertionData(route, first, vehicle, vehicle.getEarliestDeparture(), null, Double.MAX_VALUE);
|
||||
assertEquals(20.0, iData.getInsertionCost(), 0.2);
|
||||
|
|
@ -184,7 +199,7 @@ public class TestCalculatesServiceInsertion {
|
|||
tour.addActivity(ServiceActivity.newInstance(first));
|
||||
|
||||
VehicleRoute route = VehicleRoute.newInstance(tour,driver,vehicle);
|
||||
stateUpdater.update(route);
|
||||
states.informInsertionStarts(Arrays.asList(route), null);
|
||||
|
||||
InsertionData iData = serviceInsertion.getInsertionData(route, second, vehicle, vehicle.getEarliestDeparture(), null, Double.MAX_VALUE);
|
||||
assertEquals(20.0, iData.getInsertionCost(), 0.2);
|
||||
|
|
@ -198,8 +213,7 @@ public class TestCalculatesServiceInsertion {
|
|||
tour.addActivity(ServiceActivity.newInstance(second));
|
||||
|
||||
VehicleRoute route = VehicleRoute.newInstance(tour,driver,vehicle);
|
||||
|
||||
stateUpdater.update(route);
|
||||
states.informInsertionStarts(Arrays.asList(route), null);
|
||||
|
||||
InsertionData iData = serviceInsertion.getInsertionData(route, third, vehicle, vehicle.getEarliestDeparture(), null, Double.MAX_VALUE);
|
||||
assertEquals(0.0, iData.getInsertionCost(), 0.2);
|
||||
|
|
@ -213,8 +227,7 @@ public class TestCalculatesServiceInsertion {
|
|||
tour.addActivity(ServiceActivity.newInstance(second));
|
||||
|
||||
VehicleRoute route = VehicleRoute.newInstance(tour,driver,vehicle);
|
||||
|
||||
stateUpdater.update(route);
|
||||
states.informInsertionStarts(Arrays.asList(route), null);
|
||||
|
||||
InsertionData iData = serviceInsertion.getInsertionData(route, third, newVehicle, newVehicle.getEarliestDeparture(), null, Double.MAX_VALUE);
|
||||
assertEquals(20.0, iData.getInsertionCost(), 0.2);
|
||||
|
|
@ -228,7 +241,7 @@ public class TestCalculatesServiceInsertion {
|
|||
tour.addActivity(ServiceActivity.newInstance(third));
|
||||
|
||||
VehicleRoute route = VehicleRoute.newInstance(tour,driver,vehicle);
|
||||
stateUpdater.update(route);
|
||||
states.informInsertionStarts(Arrays.asList(route), null);
|
||||
|
||||
InsertionData iData = serviceInsertion.getInsertionData(route, second, vehicle, vehicle.getEarliestDeparture(), null, Double.MAX_VALUE);
|
||||
assertEquals(0.0, iData.getInsertionCost(), 0.2);
|
||||
|
|
@ -244,7 +257,7 @@ public class TestCalculatesServiceInsertion {
|
|||
VehicleRoute route = VehicleRoute.newInstance(tour,driver,vehicle);
|
||||
// route.addActivity(states.getActivity(first,true));
|
||||
// route.addActivity(states.getActivity(third,true));
|
||||
stateUpdater.update(route);
|
||||
states.informInsertionStarts(Arrays.asList(route), null);
|
||||
|
||||
InsertionData iData = serviceInsertion.getInsertionData(route, second, newVehicle, newVehicle.getEarliestDeparture(), null, Double.MAX_VALUE);
|
||||
assertEquals(20.0, iData.getInsertionCost(), 0.2);
|
||||
|
|
@ -14,34 +14,41 @@
|
|||
* 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 algorithms;
|
||||
package jsprit.core.algorithm.recreate;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import jsprit.core.algorithm.ExampleActivityCostFunction;
|
||||
import jsprit.core.algorithm.state.StateManager;
|
||||
import jsprit.core.algorithm.state.UpdateVariableCosts;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.constraint.ConstraintManager;
|
||||
import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||
import jsprit.core.problem.driver.Driver;
|
||||
import jsprit.core.problem.driver.DriverImpl;
|
||||
import jsprit.core.problem.driver.DriverImpl.NoDriver;
|
||||
import jsprit.core.problem.job.Job;
|
||||
import jsprit.core.problem.job.Service;
|
||||
import jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import jsprit.core.problem.solution.route.activity.ServiceActivity;
|
||||
import jsprit.core.problem.solution.route.activity.TimeWindow;
|
||||
import jsprit.core.problem.solution.route.activity.TourActivities;
|
||||
import jsprit.core.problem.solution.route.activity.TourActivity;
|
||||
import jsprit.core.problem.vehicle.Vehicle;
|
||||
import jsprit.core.util.Coordinate;
|
||||
import jsprit.core.util.ManhattanDistanceCalculator;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import util.Coordinate;
|
||||
import util.ManhattanDistanceCalculator;
|
||||
import basics.Job;
|
||||
import basics.Service;
|
||||
import basics.costs.VehicleRoutingTransportCosts;
|
||||
import basics.route.Driver;
|
||||
import basics.route.DriverImpl;
|
||||
import basics.route.DriverImpl.NoDriver;
|
||||
import basics.route.ServiceActivity;
|
||||
import basics.route.TimeWindow;
|
||||
import basics.route.TourActivities;
|
||||
import basics.route.TourActivity;
|
||||
import basics.route.Vehicle;
|
||||
import basics.route.VehicleRoute;
|
||||
|
||||
|
||||
|
||||
|
|
@ -65,8 +72,6 @@ public class TestCalculatesServiceInsertionOnRouteLevel {
|
|||
|
||||
private NoDriver driver;
|
||||
|
||||
private UpdateStates updateStates;
|
||||
|
||||
@Before
|
||||
public void setup(){
|
||||
Logger.getRootLogger().setLevel(Level.DEBUG);
|
||||
|
|
@ -139,15 +144,24 @@ public class TestCalculatesServiceInsertionOnRouteLevel {
|
|||
jobs.add(second);
|
||||
jobs.add(third);
|
||||
|
||||
states = new StateManager();
|
||||
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addAllJobs(jobs).addVehicle(vehicle).addVehicle(newVehicle).setRoutingCost(costs).build();
|
||||
|
||||
states = new StateManager(vrp);
|
||||
states.updateLoadStates();
|
||||
states.updateTimeWindowStates();
|
||||
states.addStateUpdater(new UpdateVariableCosts(vrp.getActivityCosts(), vrp.getTransportCosts(), states));
|
||||
|
||||
ConstraintManager cManager = new ConstraintManager(vrp,states);
|
||||
cManager.addLoadConstraint();
|
||||
cManager.addTimeWindowConstraint();
|
||||
|
||||
|
||||
ExampleActivityCostFunction activityCosts = new ExampleActivityCostFunction();
|
||||
ActivityInsertionCostsCalculator actInsertionCostCalculator = new RouteLevelActivityInsertionCostsEstimator(costs, activityCosts, states);
|
||||
serviceInsertion = new ServiceInsertionOnRouteLevelCalculator(costs,activityCosts, actInsertionCostCalculator, new LoadConstraint(states), new TimeWindowConstraint(states, costs));
|
||||
serviceInsertion = new ServiceInsertionOnRouteLevelCalculator(costs,activityCosts, actInsertionCostCalculator, cManager, cManager);
|
||||
serviceInsertion.setNuOfActsForwardLooking(4);
|
||||
serviceInsertion.setStates(states);
|
||||
|
||||
updateStates = new UpdateStates(states, costs, activityCosts);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -162,7 +176,7 @@ public class TestCalculatesServiceInsertionOnRouteLevel {
|
|||
TourActivities tour = new TourActivities();
|
||||
|
||||
VehicleRoute route = VehicleRoute.newInstance(tour,driver,vehicle);
|
||||
updateStates.update(route);
|
||||
states.informInsertionStarts(Arrays.asList(route), null);
|
||||
|
||||
InsertionData iData = serviceInsertion.getInsertionData(route, first, vehicle, vehicle.getEarliestDeparture(), null, Double.MAX_VALUE);
|
||||
assertEquals(20.0, iData.getInsertionCost(), 0.2);
|
||||
|
|
@ -176,7 +190,7 @@ public class TestCalculatesServiceInsertionOnRouteLevel {
|
|||
tour.addActivity(ServiceActivity.newInstance(second));
|
||||
|
||||
VehicleRoute route = VehicleRoute.newInstance(tour,driver,vehicle);
|
||||
updateStates.update(route);
|
||||
states.informInsertionStarts(Arrays.asList(route), null);
|
||||
|
||||
InsertionData iData = serviceInsertion.getInsertionData(route, third, vehicle, vehicle.getEarliestDeparture(), null, Double.MAX_VALUE);
|
||||
assertEquals(0.0, iData.getInsertionCost(), 0.2);
|
||||
|
|
@ -190,7 +204,7 @@ public class TestCalculatesServiceInsertionOnRouteLevel {
|
|||
tour.addActivity(ServiceActivity.newInstance(second));
|
||||
|
||||
VehicleRoute route = VehicleRoute.newInstance(tour,driver,vehicle);
|
||||
updateStates.update(route);
|
||||
states.informInsertionStarts(Arrays.asList(route), null);
|
||||
|
||||
InsertionData iData = serviceInsertion.getInsertionData(route, third, newVehicle, vehicle.getEarliestDeparture(), null, Double.MAX_VALUE);
|
||||
assertEquals(40.0, iData.getInsertionCost(), 0.2);
|
||||
|
|
@ -204,7 +218,7 @@ public class TestCalculatesServiceInsertionOnRouteLevel {
|
|||
tour.addActivity(ServiceActivity.newInstance(third));
|
||||
|
||||
VehicleRoute route = VehicleRoute.newInstance(tour,driver,vehicle);
|
||||
updateStates.update(route);
|
||||
states.informInsertionStarts(Arrays.asList(route), null);
|
||||
|
||||
InsertionData iData = serviceInsertion.getInsertionData(route, second, vehicle, vehicle.getEarliestDeparture(), null, Double.MAX_VALUE);
|
||||
assertEquals(0.0, iData.getInsertionCost(), 0.2);
|
||||
|
|
@ -218,7 +232,7 @@ public class TestCalculatesServiceInsertionOnRouteLevel {
|
|||
tour.addActivity(ServiceActivity.newInstance(third));
|
||||
|
||||
VehicleRoute route = VehicleRoute.newInstance(tour,driver,vehicle);
|
||||
updateStates.update(route);
|
||||
states.informInsertionStarts(Arrays.asList(route), null);
|
||||
|
||||
InsertionData iData = serviceInsertion.getInsertionData(route, second, newVehicle, vehicle.getEarliestDeparture(), null, Double.MAX_VALUE);
|
||||
assertEquals(40.0, iData.getInsertionCost(), 0.2);
|
||||
|
|
@ -14,30 +14,32 @@
|
|||
* 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 algorithms;
|
||||
package jsprit.core.algorithm.recreate;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.VehicleRoutingProblem.Builder;
|
||||
import jsprit.core.problem.cost.VehicleRoutingActivityCosts;
|
||||
import jsprit.core.problem.driver.Driver;
|
||||
import jsprit.core.problem.job.Service;
|
||||
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import jsprit.core.problem.solution.route.activity.TimeWindow;
|
||||
import jsprit.core.problem.solution.route.activity.TourActivity;
|
||||
import jsprit.core.problem.vehicle.Vehicle;
|
||||
import jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import jsprit.core.problem.vehicle.VehicleType;
|
||||
import jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
import jsprit.core.util.Coordinate;
|
||||
import jsprit.core.util.Solutions;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import util.Coordinate;
|
||||
import util.Solutions;
|
||||
import basics.Service;
|
||||
import basics.VehicleRoutingAlgorithm;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblem.Builder;
|
||||
import basics.VehicleRoutingProblemSolution;
|
||||
import basics.costs.VehicleRoutingActivityCosts;
|
||||
import basics.route.Driver;
|
||||
import basics.route.TimeWindow;
|
||||
import basics.route.TourActivity;
|
||||
import basics.route.Vehicle;
|
||||
import basics.route.VehicleImpl;
|
||||
import basics.route.VehicleType;
|
||||
import basics.route.VehicleTypeImpl;
|
||||
|
||||
public class TestDepartureTimeOpt {
|
||||
|
||||
|
|
@ -1,22 +1,26 @@
|
|||
package algorithms;
|
||||
package jsprit.core.algorithm.recreate;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import jsprit.core.algorithm.recreate.BestInsertionBuilder;
|
||||
import jsprit.core.algorithm.recreate.InsertionStrategy;
|
||||
import jsprit.core.algorithm.state.StateManager;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.constraint.ConstraintManager;
|
||||
import jsprit.core.problem.job.Delivery;
|
||||
import jsprit.core.problem.job.Shipment;
|
||||
import jsprit.core.problem.vehicle.InfiniteFleetManagerFactory;
|
||||
import jsprit.core.problem.vehicle.Vehicle;
|
||||
import jsprit.core.problem.vehicle.VehicleFleetManager;
|
||||
import jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import jsprit.core.problem.vehicle.VehicleType;
|
||||
import jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
import jsprit.core.problem.vehicle.VehicleImpl.Builder;
|
||||
import jsprit.core.util.Coordinate;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import util.Coordinate;
|
||||
import basics.Delivery;
|
||||
import basics.Shipment;
|
||||
import basics.VehicleRoutingAlgorithm;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.route.InfiniteFleetManagerFactory;
|
||||
import basics.route.Vehicle;
|
||||
import basics.route.VehicleFleetManager;
|
||||
import basics.route.VehicleImpl;
|
||||
import basics.route.VehicleImpl.Builder;
|
||||
import basics.route.VehicleType;
|
||||
import basics.route.VehicleTypeImpl;
|
||||
|
||||
public class TestMixedServiceAndShipmentsProblemOnRouteLevel {
|
||||
|
||||
|
|
@ -76,7 +80,8 @@ public class TestMixedServiceAndShipmentsProblemOnRouteLevel {
|
|||
|
||||
VehicleRoutingAlgorithm vra;
|
||||
|
||||
final StateManager stateManager = new StateManager();
|
||||
final StateManager stateManager = new StateManager(vrp);
|
||||
|
||||
|
||||
ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager);
|
||||
constraintManager.addLoadConstraint();
|
||||
|
|
@ -141,7 +146,7 @@ public class TestMixedServiceAndShipmentsProblemOnRouteLevel {
|
|||
|
||||
VehicleRoutingAlgorithm vra;
|
||||
|
||||
final StateManager stateManager = new StateManager();
|
||||
final StateManager stateManager = new StateManager(vrp);
|
||||
|
||||
ConstraintManager constraintManager = new ConstraintManager(vrp,stateManager);
|
||||
constraintManager.addLoadConstraint();
|
||||
|
|
@ -1,20 +1,23 @@
|
|||
package algorithms;
|
||||
package jsprit.core.algorithm.ruin;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import jsprit.core.algorithm.ruin.RuinRadial.JobNeighborhoodsImpl;
|
||||
import jsprit.core.algorithm.ruin.distance.EuclideanServiceDistance;
|
||||
import jsprit.core.algorithm.ruin.distance.JobDistance;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.job.Job;
|
||||
import jsprit.core.problem.job.Service;
|
||||
import jsprit.core.util.Coordinate;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import util.Coordinate;
|
||||
import algorithms.RuinRadial.JobNeighborhoodsImpl;
|
||||
import basics.Job;
|
||||
import basics.Service;
|
||||
import basics.VehicleRoutingProblem;
|
||||
|
||||
public class JobNeighborhoodsImplTest {
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package algorithms;
|
||||
package jsprit.core.algorithm.ruin;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -7,15 +7,18 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import jsprit.core.algorithm.ruin.RuinRadial.JobNeighborhoodsImpl;
|
||||
import jsprit.core.algorithm.ruin.RuinRadial.JobNeighborhoodsImplWithCapRestriction;
|
||||
import jsprit.core.algorithm.ruin.distance.EuclideanServiceDistance;
|
||||
import jsprit.core.algorithm.ruin.distance.JobDistance;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.job.Job;
|
||||
import jsprit.core.problem.job.Service;
|
||||
import jsprit.core.util.Coordinate;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import util.Coordinate;
|
||||
import algorithms.RuinRadial.JobNeighborhoodsImpl;
|
||||
import algorithms.RuinRadial.JobNeighborhoodsImplWithCapRestriction;
|
||||
import basics.Job;
|
||||
import basics.Service;
|
||||
import basics.VehicleRoutingProblem;
|
||||
|
||||
public class JobNeighborhoodsWithCapRestrictionImplTest {
|
||||
|
||||
|
|
@ -1,16 +1,17 @@
|
|||
package algorithms;
|
||||
package jsprit.core.algorithm.ruin.distance;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import jsprit.core.algorithm.ruin.distance.AvgServiceAndShipmentDistance;
|
||||
import jsprit.core.problem.job.Service;
|
||||
import jsprit.core.problem.job.Shipment;
|
||||
import jsprit.core.util.Coordinate;
|
||||
import jsprit.core.util.CrowFlyCosts;
|
||||
import jsprit.core.util.Locations;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import util.Coordinate;
|
||||
import util.CrowFlyCosts;
|
||||
import util.Locations;
|
||||
import basics.Service;
|
||||
import basics.Shipment;
|
||||
|
||||
public class AverageJobDistanceTest {
|
||||
|
||||
|
|
@ -39,13 +40,13 @@ public class AverageJobDistanceTest {
|
|||
Shipment s1 = Shipment.Builder.newInstance("s1", 1).setPickupLocation("0,0").setDeliveryLocation("10,10").build();
|
||||
Shipment s2 = Shipment.Builder.newInstance("s2", 1).setPickupLocation("0,0").setDeliveryLocation("10,10").build();
|
||||
|
||||
double dist = new AvgJobDistance(routingCosts).getDistance(s1, s2);
|
||||
double dist = new AvgServiceAndShipmentDistance(routingCosts).getDistance(s1, s2);
|
||||
|
||||
for(int i=0;i<10;i++){
|
||||
for(int j=0;j<10;j++){
|
||||
Shipment other1 = Shipment.Builder.newInstance("s1", 1).setPickupLocation("0,0").setDeliveryLocation(i+","+j).build();
|
||||
Shipment other2 = Shipment.Builder.newInstance("s2", 1).setPickupLocation("0,0").setDeliveryLocation("10,10").build();
|
||||
double dist2 = new AvgJobDistance(routingCosts).getDistance(other1, other2);
|
||||
double dist2 = new AvgServiceAndShipmentDistance(routingCosts).getDistance(other1, other2);
|
||||
System.out.println("("+i+","+j+"), dist=" + dist + ", dist2=" + dist2);
|
||||
assertTrue(dist<=dist2+dist2*0.001);
|
||||
}
|
||||
|
|
@ -59,7 +60,7 @@ public class AverageJobDistanceTest {
|
|||
Service s1 = Service.Builder.newInstance("s1", 1).setLocationId("10,0").build();
|
||||
Service s2 = Service.Builder.newInstance("s2", 1).setLocationId("10,0").build();
|
||||
|
||||
double dist = new AvgJobDistance(routingCosts).getDistance(s1, s2);
|
||||
double dist = new AvgServiceAndShipmentDistance(routingCosts).getDistance(s1, s2);
|
||||
assertEquals(0.0,dist,0.01);
|
||||
}
|
||||
}
|
||||
|
|
@ -14,14 +14,16 @@
|
|||
* 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 algorithms;
|
||||
package jsprit.core.algorithm.ruin.distance;
|
||||
|
||||
import jsprit.core.algorithm.ruin.distance.AvgServiceDistance;
|
||||
import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||
import jsprit.core.problem.driver.Driver;
|
||||
import jsprit.core.problem.job.Service;
|
||||
import jsprit.core.problem.vehicle.Vehicle;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import basics.Service;
|
||||
import basics.costs.VehicleRoutingTransportCosts;
|
||||
import basics.route.Driver;
|
||||
import basics.route.Vehicle;
|
||||
|
||||
public class TestJobDistanceAvgCosts {
|
||||
|
||||
|
|
@ -55,7 +57,7 @@ public class TestJobDistanceAvgCosts {
|
|||
return 0;
|
||||
}
|
||||
};
|
||||
JobDistanceAvgCosts c = new JobDistanceAvgCosts(costs);
|
||||
AvgServiceDistance c = new AvgServiceDistance(costs);
|
||||
c.getDistance(Service.Builder.newInstance("1", 1).setLocationId("foo").build(), Service.Builder.newInstance("2", 2).setLocationId("foo").build());
|
||||
}
|
||||
|
||||
|
|
@ -91,7 +93,7 @@ public class TestJobDistanceAvgCosts {
|
|||
return 0;
|
||||
}
|
||||
};
|
||||
JobDistanceAvgCosts c = new JobDistanceAvgCosts(costs);
|
||||
AvgServiceDistance c = new AvgServiceDistance(costs);
|
||||
c.getDistance(Service.Builder.newInstance("1", 1).setLocationId("loc").build(), Service.Builder.newInstance("2", 2).setLocationId("loc").build());
|
||||
}
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package algorithms.selectors;
|
||||
package jsprit.core.algorithm.selector;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
|
@ -25,9 +25,11 @@ import static org.mockito.Mockito.when;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import jsprit.core.algorithm.selector.SelectBest;
|
||||
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import basics.VehicleRoutingProblemSolution;
|
||||
|
||||
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package algorithms.selectors;
|
||||
package jsprit.core.algorithm.selector;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
|
@ -26,9 +26,11 @@ import java.util.Arrays;
|
|||
import java.util.Collections;
|
||||
import java.util.Random;
|
||||
|
||||
import jsprit.core.algorithm.selector.SelectRandomly;
|
||||
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import basics.VehicleRoutingProblemSolution;
|
||||
|
||||
|
||||
public class SelectRandomlyTest {
|
||||
|
|
@ -1,19 +1,24 @@
|
|||
package algorithms;
|
||||
package jsprit.core.algorithm.state;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import jsprit.core.algorithm.state.StateManager;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.constraint.PickupAndDeliverShipmentLoadActivityLevelConstraint;
|
||||
import jsprit.core.problem.constraint.HardActivityStateLevelConstraint.ConstraintsStatus;
|
||||
import jsprit.core.problem.job.Service;
|
||||
import jsprit.core.problem.job.Shipment;
|
||||
import jsprit.core.problem.misc.JobInsertionContext;
|
||||
import jsprit.core.problem.solution.route.activity.DeliverShipment;
|
||||
import jsprit.core.problem.solution.route.activity.PickupService;
|
||||
import jsprit.core.problem.solution.route.activity.PickupShipment;
|
||||
import jsprit.core.problem.solution.route.state.StateFactory;
|
||||
import jsprit.core.problem.vehicle.Vehicle;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import algorithms.HardActivityStateLevelConstraint.ConstraintsStatus;
|
||||
import basics.Service;
|
||||
import basics.Shipment;
|
||||
import basics.route.DeliverShipment;
|
||||
import basics.route.PickupService;
|
||||
import basics.route.PickupShipment;
|
||||
import basics.route.Vehicle;
|
||||
|
||||
public class HardPickupAndDeliveryShipmentActivityConstraintTest {
|
||||
|
||||
|
|
@ -25,16 +30,16 @@ public class HardPickupAndDeliveryShipmentActivityConstraintTest {
|
|||
|
||||
PickupAndDeliverShipmentLoadActivityLevelConstraint constraint;
|
||||
|
||||
InsertionContext iFacts;
|
||||
JobInsertionContext iFacts;
|
||||
|
||||
@Before
|
||||
public void doBefore(){
|
||||
vehicle = mock(Vehicle.class);
|
||||
when(vehicle.getCapacity()).thenReturn(2);
|
||||
stateManager = new StateManager();
|
||||
stateManager = new StateManager(mock(VehicleRoutingProblem.class));
|
||||
shipment = mock(Shipment.class);
|
||||
when(shipment.getCapacityDemand()).thenReturn(1);
|
||||
iFacts = new InsertionContext(null, null, vehicle, null, 0.0);
|
||||
iFacts = new JobInsertionContext(null, null, vehicle, null, 0.0);
|
||||
constraint = new PickupAndDeliverShipmentLoadActivityLevelConstraint(stateManager);
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +58,8 @@ public class HardPickupAndDeliveryShipmentActivityConstraintTest {
|
|||
PickupService anotherService = new PickupService(mock(Service.class));
|
||||
PickupShipment pickupShipment = new PickupShipment(shipment);
|
||||
|
||||
stateManager.putActivityState(pickupService, StateFactory.LOAD, StateFactory.createState(2));
|
||||
stateManager.putInternalActivityState(pickupService, StateFactory.LOAD, StateFactory.createState(2));
|
||||
// when(stateManager.getActivityState(pickupService, StateFactory.LOAD)).thenReturn(StateFactory.createState(2.0));
|
||||
assertEquals(ConstraintsStatus.NOT_FULFILLED,constraint.fulfilled(iFacts, pickupService, pickupShipment, anotherService, 0.0));
|
||||
}
|
||||
|
||||
|
|
@ -63,7 +69,7 @@ public class HardPickupAndDeliveryShipmentActivityConstraintTest {
|
|||
PickupService anotherService = new PickupService(mock(Service.class));
|
||||
DeliverShipment pickupShipment = new DeliverShipment(shipment);
|
||||
|
||||
stateManager.putActivityState(pickupService, StateFactory.LOAD, StateFactory.createState(2));
|
||||
stateManager.putInternalActivityState(pickupService, StateFactory.LOAD, StateFactory.createState(2));
|
||||
assertEquals(ConstraintsStatus.NOT_FULFILLED_BREAK,constraint.fulfilled(iFacts, pickupService, pickupShipment, anotherService, 0.0));
|
||||
}
|
||||
|
||||
|
|
@ -73,7 +79,7 @@ public class HardPickupAndDeliveryShipmentActivityConstraintTest {
|
|||
PickupService anotherService = new PickupService(mock(Service.class));
|
||||
DeliverShipment pickupShipment = new DeliverShipment(shipment);
|
||||
|
||||
stateManager.putActivityState(pickupService, StateFactory.LOAD, StateFactory.createState(1));
|
||||
stateManager.putInternalActivityState(pickupService, StateFactory.LOAD, StateFactory.createState(1));
|
||||
assertEquals(ConstraintsStatus.FULFILLED,constraint.fulfilled(iFacts, pickupService, pickupShipment, anotherService, 0.0));
|
||||
}
|
||||
|
||||
|
|
@ -14,30 +14,34 @@
|
|||
* 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 algorithms;
|
||||
package jsprit.core.algorithm.state;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.cost.VehicleRoutingTransportCosts;
|
||||
import jsprit.core.problem.driver.Driver;
|
||||
import jsprit.core.problem.driver.DriverImpl;
|
||||
import jsprit.core.problem.job.Job;
|
||||
import jsprit.core.problem.job.Service;
|
||||
import jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import jsprit.core.problem.solution.route.activity.ServiceActivity;
|
||||
import jsprit.core.problem.solution.route.activity.TimeWindow;
|
||||
import jsprit.core.problem.solution.route.activity.TourActivities;
|
||||
import jsprit.core.problem.solution.route.state.StateFactory;
|
||||
import jsprit.core.problem.vehicle.Vehicle;
|
||||
import jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
import jsprit.core.util.Coordinate;
|
||||
import jsprit.core.util.ManhattanDistanceCalculator;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import util.Coordinate;
|
||||
import util.ManhattanDistanceCalculator;
|
||||
import basics.Job;
|
||||
import basics.Service;
|
||||
import basics.costs.VehicleRoutingTransportCosts;
|
||||
import basics.route.Driver;
|
||||
import basics.route.DriverImpl;
|
||||
import basics.route.ServiceActivity;
|
||||
import basics.route.TimeWindow;
|
||||
import basics.route.TourActivities;
|
||||
import basics.route.Vehicle;
|
||||
import basics.route.VehicleImpl;
|
||||
import basics.route.VehicleRoute;
|
||||
import basics.route.VehicleTypeImpl;
|
||||
|
||||
|
||||
public class TestTourStateUpdaterWithService {
|
||||
|
|
@ -50,7 +54,6 @@ public class TestTourStateUpdaterWithService {
|
|||
|
||||
TourActivities anotherTour;
|
||||
|
||||
UpdateStates updateStates;
|
||||
|
||||
StateManager states;
|
||||
|
||||
|
|
@ -99,32 +102,36 @@ public class TestTourStateUpdaterWithService {
|
|||
services.add(firstService);
|
||||
services.add(secondService);
|
||||
|
||||
states = new StateManager();
|
||||
|
||||
VehicleTypeImpl type = VehicleTypeImpl.Builder.newInstance("test", 10).build();
|
||||
vehicle = VehicleImpl.Builder.newInstance("testvehicle").setType(type).setLocationId("0,0")
|
||||
.setEarliestStart(0.0).setLatestArrival(50.0).build();
|
||||
|
||||
|
||||
VehicleRoutingProblem vrp = VehicleRoutingProblem.Builder.newInstance().addAllJobs(services).addVehicle(vehicle).setRoutingCost(cost).build();
|
||||
|
||||
states = new StateManager(vrp);
|
||||
states.updateLoadStates();
|
||||
states.updateTimeWindowStates();
|
||||
states.addStateUpdater(new UpdateVariableCosts(vrp.getActivityCosts(), vrp.getTransportCosts(), states));
|
||||
states.addStateUpdater(new UpdateActivityTimes(vrp.getTransportCosts()));
|
||||
|
||||
tour = new TourActivities();
|
||||
tour.addActivity(ServiceActivity.newInstance(firstService));
|
||||
tour.addActivity(ServiceActivity.newInstance(secondService));
|
||||
|
||||
|
||||
updateStates = new UpdateStates(states, cost, new ExampleActivityCostFunction());
|
||||
|
||||
vehicleRoute = VehicleRoute.newInstance(tour,DriverImpl.noDriver(),vehicle);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculatedCost() {
|
||||
updateStates.update(vehicleRoute);
|
||||
states.informInsertionStarts(Arrays.asList(vehicleRoute), null);
|
||||
assertEquals(40.0, states.getRouteState(vehicleRoute,StateFactory.COSTS).toDouble(), 0.05);
|
||||
assertEquals(10, states.getRouteState(vehicleRoute, StateFactory.LOAD_AT_END).toDouble(), 0.05);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStatesOfAct0(){
|
||||
updateStates.update(vehicleRoute);
|
||||
states.informInsertionStarts(Arrays.asList(vehicleRoute), null);
|
||||
assertEquals(0.0, vehicleRoute.getStart().getEndTime(),0.05);
|
||||
assertEquals(vehicleRoute.getVehicle().getLocationId(), vehicleRoute.getStart().getLocationId());
|
||||
assertEquals(vehicleRoute.getVehicle().getEarliestDeparture(), vehicleRoute.getStart().getTheoreticalEarliestOperationStartTime(),0.05);
|
||||
|
|
@ -134,7 +141,7 @@ public class TestTourStateUpdaterWithService {
|
|||
|
||||
@Test
|
||||
public void testStatesOfAct1(){
|
||||
updateStates.update(vehicleRoute);
|
||||
states.informInsertionStarts(Arrays.asList(vehicleRoute), null);
|
||||
assertEquals(10.0, states.getActivityState(tour.getActivities().get(0), StateFactory.COSTS).toDouble(),0.05);
|
||||
assertEquals(5.0, states.getActivityState(tour.getActivities().get(0), StateFactory.LOAD).toDouble(),0.05);
|
||||
// assertEquals(10.0, states.getActivityState(tour.getActivities().get(0), StateTypes.EARLIEST_OPERATION_START_TIME).toDouble(),0.05);
|
||||
|
|
@ -143,7 +150,7 @@ public class TestTourStateUpdaterWithService {
|
|||
|
||||
@Test
|
||||
public void testStatesOfAct2(){
|
||||
updateStates.update(vehicleRoute);
|
||||
states.informInsertionStarts(Arrays.asList(vehicleRoute), null);
|
||||
|
||||
assertEquals(30.0, states.getActivityState(tour.getActivities().get(1), StateFactory.COSTS).toDouble(),0.05);
|
||||
assertEquals(10.0, states.getActivityState(tour.getActivities().get(1), StateFactory.LOAD).toDouble(),0.05);
|
||||
|
|
@ -153,8 +160,7 @@ public class TestTourStateUpdaterWithService {
|
|||
|
||||
@Test
|
||||
public void testStatesOfAct3(){
|
||||
updateStates.update(vehicleRoute);
|
||||
|
||||
states.informInsertionStarts(Arrays.asList(vehicleRoute), null);
|
||||
assertEquals(40.0, states.getRouteState(vehicleRoute, StateFactory.COSTS).toDouble(), 0.05);
|
||||
assertEquals(40.0, vehicleRoute.getEnd().getArrTime(),0.05);
|
||||
assertEquals(50.0, vehicleRoute.getEnd().getTheoreticalLatestOperationStartTime(),0.05);
|
||||
|
|
@ -14,16 +14,19 @@
|
|||
* 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 basics;
|
||||
package jsprit.core.problem;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
||||
import jsprit.core.problem.job.Job;
|
||||
import jsprit.core.problem.job.Shipment;
|
||||
import jsprit.core.problem.vehicle.Vehicle;
|
||||
import jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import basics.VehicleRoutingProblem.FleetSize;
|
||||
import basics.route.Vehicle;
|
||||
import basics.route.VehicleImpl;
|
||||
import basics.route.VehicleTypeImpl;
|
||||
|
||||
public class VehicleRoutingProblemBuilderTest {
|
||||
|
||||
|
|
@ -14,7 +14,10 @@
|
|||
* 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 basics.io;
|
||||
package jsprit.core.problem.io;
|
||||
|
||||
import jsprit.core.algorithm.io.AlgorithmConfig;
|
||||
import jsprit.core.algorithm.io.AlgorithmConfigXmlReader;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package basics.io;
|
||||
package jsprit.core.problem.io;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
|
@ -22,15 +22,17 @@ import static org.junit.Assert.assertTrue;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.VehicleRoutingProblem.Builder;
|
||||
import jsprit.core.problem.io.VrpXMLReader;
|
||||
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import jsprit.core.problem.solution.route.activity.DeliverShipment;
|
||||
import jsprit.core.problem.solution.route.activity.PickupService;
|
||||
import jsprit.core.problem.solution.route.activity.PickupShipment;
|
||||
import jsprit.core.problem.solution.route.activity.TourActivity;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblem.Builder;
|
||||
import basics.VehicleRoutingProblemSolution;
|
||||
import basics.route.DeliverShipment;
|
||||
import basics.route.PickupService;
|
||||
import basics.route.PickupShipment;
|
||||
import basics.route.TourActivity;
|
||||
|
||||
public class ReaderTest {
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package basics.io;
|
||||
package jsprit.core.problem.io;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
|
@ -25,16 +25,18 @@ import java.util.Arrays;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.VehicleRoutingProblem.FleetComposition;
|
||||
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
||||
import jsprit.core.problem.io.VrpXMLReader;
|
||||
import jsprit.core.problem.job.Job;
|
||||
import jsprit.core.problem.job.Service;
|
||||
import jsprit.core.problem.job.Shipment;
|
||||
import jsprit.core.problem.vehicle.Vehicle;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import basics.Job;
|
||||
import basics.Service;
|
||||
import basics.Shipment;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblem.FleetComposition;
|
||||
import basics.VehicleRoutingProblem.FleetSize;
|
||||
import basics.route.Vehicle;
|
||||
|
||||
public class VrpReaderV2Test {
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
package basics.io;
|
||||
package jsprit.core.problem.io;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
|
@ -22,22 +22,25 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import jsprit.core.problem.VehicleRoutingProblem;
|
||||
import jsprit.core.problem.VehicleRoutingProblem.Builder;
|
||||
import jsprit.core.problem.VehicleRoutingProblem.FleetComposition;
|
||||
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
||||
import jsprit.core.problem.io.VrpXMLReader;
|
||||
import jsprit.core.problem.io.VrpXMLWriter;
|
||||
import jsprit.core.problem.job.Service;
|
||||
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||
import jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import jsprit.core.problem.solution.route.activity.End;
|
||||
import jsprit.core.problem.solution.route.activity.ServiceActivity;
|
||||
import jsprit.core.problem.solution.route.activity.Start;
|
||||
import jsprit.core.problem.vehicle.Vehicle;
|
||||
import jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import basics.Service;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblem.Builder;
|
||||
import basics.VehicleRoutingProblem.FleetComposition;
|
||||
import basics.VehicleRoutingProblem.FleetSize;
|
||||
import basics.VehicleRoutingProblemSolution;
|
||||
import basics.route.End;
|
||||
import basics.route.ServiceActivity;
|
||||
import basics.route.Start;
|
||||
import basics.route.Vehicle;
|
||||
import basics.route.VehicleImpl;
|
||||
import basics.route.VehicleRoute;
|
||||
import basics.route.VehicleTypeImpl;
|
||||
|
||||
public class VrpWriterV2Test {
|
||||
|
||||
|
|
@ -141,57 +144,6 @@ public class VrpWriterV2Test {
|
|||
assertEquals(2.0,s1_read.getServiceDuration(),0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenWritingSolutions_itWritesThemCorrectly(){
|
||||
VehicleRoutingProblem.Builder builder = VehicleRoutingProblem.Builder.newInstance();
|
||||
builder.setFleetComposition(FleetComposition.HETEROGENEOUS);
|
||||
builder.setFleetSize(FleetSize.FINITE);
|
||||
VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("vehType", 20).build();
|
||||
VehicleTypeImpl type2 = VehicleTypeImpl.Builder.newInstance("vehType2", 200).build();
|
||||
Vehicle v1 = VehicleImpl.Builder.newInstance("v1").setLocationId("loc").setType(type1).build();
|
||||
Vehicle v2 = VehicleImpl.Builder.newInstance("v2").setLocationId("loc").setType(type2).build();
|
||||
builder.addVehicleType(type1);
|
||||
builder.addVehicleType(type2);
|
||||
builder.addVehicle(v1);
|
||||
builder.addVehicle(v2);
|
||||
|
||||
Service s1 = Service.Builder.newInstance("1", 1).setLocationId("loc").setServiceTime(2.0).build();
|
||||
Service s2 = Service.Builder.newInstance("2", 1).setLocationId("loc2").setServiceTime(4.0).build();
|
||||
builder.addService(s1).addService(s2);
|
||||
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
|
||||
Collection<VehicleRoute> routes = new ArrayList<VehicleRoute>();
|
||||
Start start = Start.newInstance("start", 0.0, Double.MAX_VALUE);
|
||||
start.setEndTime(10.0);
|
||||
End end = End.newInstance("end", 0.0, Double.MAX_VALUE);
|
||||
end.setArrTime(100);
|
||||
VehicleRoute.Builder routebuilder = VehicleRoute.Builder.newInstance(start, end);
|
||||
|
||||
ServiceActivity act1 = ServiceActivity.newInstance(s1);
|
||||
ServiceActivity act2 = ServiceActivity.newInstance(s2);
|
||||
act1.setArrTime(20.0);
|
||||
act1.setEndTime(30.0);
|
||||
|
||||
act2.setArrTime(40.0);
|
||||
act2.setEndTime(80.0);
|
||||
|
||||
routebuilder.addActivity(act1).addActivity(act2).setVehicle(v1);
|
||||
VehicleRoute route = routebuilder.build();
|
||||
routes.add(route);
|
||||
|
||||
VehicleRoutingProblemSolution solution = new VehicleRoutingProblemSolution(routes, 100);
|
||||
|
||||
new VrpXMLWriter(vrp, Arrays.asList(solution)).write(infileName);
|
||||
|
||||
VehicleRoutingProblem.Builder vrpToReadBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||
Collection<VehicleRoutingProblemSolution> solutions = new ArrayList<VehicleRoutingProblemSolution>();
|
||||
new VrpXMLReader(vrpToReadBuilder, solutions).read(infileName);
|
||||
|
||||
VehicleRoutingProblem readVrp = vrpToReadBuilder.build();
|
||||
|
||||
assertEquals(1, solutions.size());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -14,13 +14,15 @@
|
|||
* 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 basics;
|
||||
package jsprit.core.problem.job;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import jsprit.core.problem.job.Service;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
|
|
@ -1,12 +1,13 @@
|
|||
package basics;
|
||||
package jsprit.core.problem.job;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import jsprit.core.problem.job.Shipment;
|
||||
import jsprit.core.problem.solution.route.activity.TimeWindow;
|
||||
import jsprit.core.util.Coordinate;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import util.Coordinate;
|
||||
import basics.route.TimeWindow;
|
||||
|
||||
public class ShipmentTest {
|
||||
|
||||
|
|
@ -14,18 +14,28 @@
|
|||
* 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 basics.route;
|
||||
package jsprit.core.problem.solution.route;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import jsprit.core.problem.driver.DriverImpl;
|
||||
import jsprit.core.problem.driver.DriverImpl.NoDriver;
|
||||
import jsprit.core.problem.job.Service;
|
||||
import jsprit.core.problem.solution.route.VehicleRoute;
|
||||
import jsprit.core.problem.solution.route.activity.ServiceActivity;
|
||||
import jsprit.core.problem.solution.route.activity.Start;
|
||||
import jsprit.core.problem.solution.route.activity.TourActivities;
|
||||
import jsprit.core.problem.solution.route.activity.TourActivity;
|
||||
import jsprit.core.problem.vehicle.Vehicle;
|
||||
import jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import basics.Service;
|
||||
import basics.route.DriverImpl.NoDriver;
|
||||
|
||||
public class TestVehicleRoute {
|
||||
|
||||
|
|
@ -1,25 +1,27 @@
|
|||
package basics.route;
|
||||
package jsprit.core.problem.solution.route;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import jsprit.core.problem.driver.Driver;
|
||||
import jsprit.core.problem.job.Shipment;
|
||||
import jsprit.core.problem.vehicle.Vehicle;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import basics.Shipment;
|
||||
|
||||
public class VehicleRouteBuilderTest {
|
||||
|
||||
@Test(expected=IllegalStateException.class)
|
||||
public void whenDeliveryIsAddedBeforePickup_throwsException(){
|
||||
Shipment s = mock(Shipment.class);
|
||||
VehicleRouteBuilder builder = new VehicleRouteBuilder(mock(Vehicle.class), mock(Driver.class));
|
||||
VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(mock(Vehicle.class), mock(Driver.class));
|
||||
builder.addDelivery(s);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalStateException.class)
|
||||
public void whenPickupIsAddedTwice_throwsException(){
|
||||
Shipment s = mock(Shipment.class);
|
||||
VehicleRouteBuilder builder = new VehicleRouteBuilder(mock(Vehicle.class), mock(Driver.class));
|
||||
VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(mock(Vehicle.class), mock(Driver.class));
|
||||
builder.addPickup(s);
|
||||
builder.addPickup(s);
|
||||
}
|
||||
|
|
@ -27,7 +29,7 @@ public class VehicleRouteBuilderTest {
|
|||
@Test(expected=IllegalStateException.class)
|
||||
public void whenShipmentIsPickedDeliveredAndDeliveredAgain_throwsException(){
|
||||
Shipment s = mock(Shipment.class);
|
||||
VehicleRouteBuilder builder = new VehicleRouteBuilder(mock(Vehicle.class), mock(Driver.class));
|
||||
VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(mock(Vehicle.class), mock(Driver.class));
|
||||
builder.addPickup(s);
|
||||
builder.addDelivery(s);
|
||||
builder.addDelivery(s);
|
||||
|
|
@ -36,7 +38,7 @@ public class VehicleRouteBuilderTest {
|
|||
@Test(expected=IllegalStateException.class)
|
||||
public void whenShipmentIsPickedUpThoughButHasNotBeenDeliveredAndRouteIsBuilt_throwsException(){
|
||||
Shipment s = mock(Shipment.class);
|
||||
VehicleRouteBuilder builder = new VehicleRouteBuilder(mock(Vehicle.class), mock(Driver.class));
|
||||
VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(mock(Vehicle.class), mock(Driver.class));
|
||||
builder.addPickup(s);
|
||||
builder.addPickup(mock(Shipment.class));
|
||||
builder.addDelivery(s);
|
||||
|
|
@ -47,7 +49,7 @@ public class VehicleRouteBuilderTest {
|
|||
public void whenTwoShipmentsHaveBeenAdded_nuOfActivitiesMustEqualFour(){
|
||||
Shipment s = mock(Shipment.class);
|
||||
Shipment s2 = mock(Shipment.class);
|
||||
VehicleRouteBuilder builder = new VehicleRouteBuilder(mock(Vehicle.class), mock(Driver.class));
|
||||
VehicleRoute.Builder builder = VehicleRoute.Builder.newInstance(mock(Vehicle.class), mock(Driver.class));
|
||||
builder.addPickup(s);
|
||||
builder.addPickup(s2);
|
||||
builder.addDelivery(s);
|
||||
|
|
@ -14,14 +14,15 @@
|
|||
* 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 basics.route;
|
||||
package jsprit.core.problem.solution.route.activity;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import jsprit.core.problem.job.Service;
|
||||
import jsprit.core.problem.solution.route.activity.ServiceActivity;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import basics.Service;
|
||||
|
||||
public class ServiceActTest {
|
||||
|
||||
|
|
@ -14,16 +14,17 @@
|
|||
* 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 algorithms;
|
||||
package jsprit.core.problem.solution.route.activity;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import jsprit.core.problem.solution.route.activity.Start;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import basics.route.Start;
|
||||
|
||||
public class TestRefs {
|
||||
|
||||
|
|
@ -14,17 +14,22 @@
|
|||
* 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 basics.route;
|
||||
package jsprit.core.problem.solution.route.activity;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import jsprit.core.problem.job.Service;
|
||||
import jsprit.core.problem.job.Shipment;
|
||||
import jsprit.core.problem.solution.route.activity.DefaultShipmentActivityFactory;
|
||||
import jsprit.core.problem.solution.route.activity.ServiceActivity;
|
||||
import jsprit.core.problem.solution.route.activity.TourActivities;
|
||||
import jsprit.core.problem.solution.route.activity.TourActivity;
|
||||
import jsprit.core.problem.solution.route.activity.TourShipmentActivityFactory;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import basics.Service;
|
||||
import basics.Shipment;
|
||||
|
||||
|
||||
public class TestTour {
|
||||
|
|
@ -14,19 +14,19 @@
|
|||
* 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 algorithms;
|
||||
package jsprit.core.problem.vehicle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import jsprit.core.problem.vehicle.FiniteFleetManagerFactory;
|
||||
import jsprit.core.problem.vehicle.PenaltyVehicleType;
|
||||
import jsprit.core.problem.vehicle.Vehicle;
|
||||
import jsprit.core.problem.vehicle.VehicleFleetManager;
|
||||
import jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
import junit.framework.TestCase;
|
||||
import basics.route.FiniteFleetManagerFactory;
|
||||
import basics.route.PenaltyVehicleType;
|
||||
import basics.route.Vehicle;
|
||||
import basics.route.VehicleFleetManager;
|
||||
import basics.route.VehicleImpl;
|
||||
import basics.route.VehicleTypeImpl;
|
||||
|
||||
public class TestVehicleFleetManager extends TestCase{
|
||||
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
<problem xmlns="http://www.w3schools.com"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd">
|
||||
<problemType>
|
||||
<fleetSize>FINITE</fleetSize>
|
||||
<fleetComposition>HETEROGENEOUS</fleetComposition>
|
||||
<fleetSize>INFINITE</fleetSize>
|
||||
<fleetComposition>HOMOGENEOUS</fleetComposition>
|
||||
</problemType>
|
||||
<vehicles>
|
||||
<vehicle>
|
||||
|
|
@ -73,28 +73,4 @@
|
|||
</timeWindows>
|
||||
</service>
|
||||
</services>
|
||||
<solutions>
|
||||
<solution>
|
||||
<cost>100.0</cost>
|
||||
<routes>
|
||||
<route>
|
||||
<cost>0.0</cost>
|
||||
<driverId>noDriver</driverId>
|
||||
<vehicleId>v1</vehicleId>
|
||||
<start>10.0</start>
|
||||
<act type="service">
|
||||
<serviceId>1</serviceId>
|
||||
<arrTime>20.0</arrTime>
|
||||
<endTime>30.0</endTime>
|
||||
</act>
|
||||
<act type="service">
|
||||
<serviceId>2</serviceId>
|
||||
<arrTime>40.0</arrTime>
|
||||
<endTime>80.0</endTime>
|
||||
</act>
|
||||
<end>100.0</end>
|
||||
</route>
|
||||
</routes>
|
||||
</solution>
|
||||
</solutions>
|
||||
</problem>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue