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

play with b-messenger

This commit is contained in:
Stefan Schroeder 2013-12-04 15:08:30 +01:00
parent 149c4d4ecb
commit 4c9b7b8e00
2 changed files with 13 additions and 13 deletions

View file

@ -22,7 +22,7 @@
<algorithm xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com algorithm_schema.xsd">
<iterations>2000</iterations>
<iterations>10000</iterations>
<construction>
<insertion name="bestInsertion">
@ -36,13 +36,13 @@
<searchStrategy name="radialRuinAndRecreate">
<selector name="selectBest"/>
<acceptor name="schrimpfAcceptance">
<alpha>0.01</alpha>
<alpha>0.1</alpha>
<warmup>40</warmup>
</acceptor>
<modules>
<module name="ruin_and_recreate">
<ruin name="randomRuin">
<share>0.3</share>
<share>0.5</share>
</ruin>
<insertion name="bestInsertion"/>
</module>
@ -53,12 +53,11 @@
<searchStrategy name="radialRuinAndRecreate">
<selector name="selectBest"/>
<acceptor name="acceptNewRemoveWorst"/>
<acceptor name="schrimpfAcceptance"/>
<modules>
<module name="ruin_and_recreate">
<ruin id="1" name="radialRuin">
<share>0.2</share>
<share>0.3</share>
</ruin>
<insertion name="bestInsertion"/>
</module>

View file

@ -186,8 +186,9 @@ public class BicycleMessenger {
stateManager.addStateUpdater(new UpdateLatestActivityStartTimes(stateManager, routingCosts, nearestMessengers));
VehicleRoutingAlgorithm algorithm = VehicleRoutingAlgorithms.readAndCreateAlgorithm(bicycleMessengerProblem,"input/algorithmConfig_open.xml", stateManager);
// algorithm.setPrematureAlgorithmTermination(new IterationWithoutImprovementTermination(500));
algorithm.setPrematureAlgorithmTermination(new IterationWithoutImprovementTermination(1000));
algorithm.addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
// algorithm.setNuOfIterations(5000);
Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions();
SolutionPrinter.print(Solutions.bestOf(solutions));
@ -198,9 +199,9 @@ public class BicycleMessenger {
Plotter plotter1 = new Plotter(bicycleMessengerProblem, Solutions.bestOf(solutions));
plotter1.plotShipments(false);
plotter1.plotShipments(true);
plotter1.setShowFirstActivity(true);
// plotter1.setBoundingBox(10000, 47500, 20000, 67500);
plotter1.setBoundingBox(5000, 45500, 25000, 66500);
plotter1.plot("output/bicycleMessengerSolution.png", "bicycleMessenger");
new VrpXMLWriter(bicycleMessengerProblem, solutions).write("output/bicycleMessenger.xml");
@ -249,16 +250,16 @@ public class BicycleMessenger {
String line = null;
boolean firstLine = true;
VehicleType messengerType = VehicleTypeImpl.Builder.newInstance("messengerType", 15).setCostPerDistance(1).build();
VehicleType penaltyType = VehicleTypeImpl.Builder.newInstance("messengerType", 15).setFixedCost(200).setCostPerDistance(4).build();
PenaltyVehicleType penaltyVehicleType = new PenaltyVehicleType(penaltyType);
VehicleType penaltyType = VehicleTypeImpl.Builder.newInstance("messengerType", 15).setFixedCost(50000).setCostPerDistance(4).build();
PenaltyVehicleType penaltyVehicleType = new PenaltyVehicleType(penaltyType,4);
while((line = reader.readLine()) != null){
if(firstLine) { firstLine = false; continue; }
String[] tokens = line.split("\\s+");
Vehicle vehicle = VehicleImpl.Builder.newInstance(tokens[1]).setLocationCoord(Coordinate.newInstance(Double.parseDouble(tokens[2]), Double.parseDouble(tokens[3])))
.setReturnToDepot(true).setType(messengerType).build();
.setReturnToDepot(false).setType(messengerType).build();
problemBuilder.addVehicle(vehicle);
Vehicle penaltyVehicle = VehicleImpl.Builder.newInstance(tokens[1]).setLocationCoord(Coordinate.newInstance(Double.parseDouble(tokens[2]), Double.parseDouble(tokens[3])))
Vehicle penaltyVehicle = VehicleImpl.Builder.newInstance(tokens[1]+"_penalty").setLocationCoord(Coordinate.newInstance(Double.parseDouble(tokens[2]), Double.parseDouble(tokens[3])))
.setReturnToDepot(true).setType(penaltyVehicleType).build();
problemBuilder.addVehicle(penaltyVehicle);
}