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:
parent
149c4d4ecb
commit
4c9b7b8e00
2 changed files with 13 additions and 13 deletions
|
|
@ -22,7 +22,7 @@
|
||||||
<algorithm xmlns="http://www.w3schools.com"
|
<algorithm xmlns="http://www.w3schools.com"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com algorithm_schema.xsd">
|
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>
|
<construction>
|
||||||
<insertion name="bestInsertion">
|
<insertion name="bestInsertion">
|
||||||
|
|
@ -36,13 +36,13 @@
|
||||||
<searchStrategy name="radialRuinAndRecreate">
|
<searchStrategy name="radialRuinAndRecreate">
|
||||||
<selector name="selectBest"/>
|
<selector name="selectBest"/>
|
||||||
<acceptor name="schrimpfAcceptance">
|
<acceptor name="schrimpfAcceptance">
|
||||||
<alpha>0.01</alpha>
|
<alpha>0.1</alpha>
|
||||||
<warmup>40</warmup>
|
<warmup>40</warmup>
|
||||||
</acceptor>
|
</acceptor>
|
||||||
<modules>
|
<modules>
|
||||||
<module name="ruin_and_recreate">
|
<module name="ruin_and_recreate">
|
||||||
<ruin name="randomRuin">
|
<ruin name="randomRuin">
|
||||||
<share>0.3</share>
|
<share>0.5</share>
|
||||||
</ruin>
|
</ruin>
|
||||||
<insertion name="bestInsertion"/>
|
<insertion name="bestInsertion"/>
|
||||||
</module>
|
</module>
|
||||||
|
|
@ -53,12 +53,11 @@
|
||||||
|
|
||||||
<searchStrategy name="radialRuinAndRecreate">
|
<searchStrategy name="radialRuinAndRecreate">
|
||||||
<selector name="selectBest"/>
|
<selector name="selectBest"/>
|
||||||
<acceptor name="acceptNewRemoveWorst"/>
|
<acceptor name="schrimpfAcceptance"/>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module name="ruin_and_recreate">
|
<module name="ruin_and_recreate">
|
||||||
<ruin id="1" name="radialRuin">
|
<ruin id="1" name="radialRuin">
|
||||||
<share>0.2</share>
|
<share>0.3</share>
|
||||||
</ruin>
|
</ruin>
|
||||||
<insertion name="bestInsertion"/>
|
<insertion name="bestInsertion"/>
|
||||||
</module>
|
</module>
|
||||||
|
|
|
||||||
|
|
@ -186,8 +186,9 @@ public class BicycleMessenger {
|
||||||
stateManager.addStateUpdater(new UpdateLatestActivityStartTimes(stateManager, routingCosts, nearestMessengers));
|
stateManager.addStateUpdater(new UpdateLatestActivityStartTimes(stateManager, routingCosts, nearestMessengers));
|
||||||
|
|
||||||
VehicleRoutingAlgorithm algorithm = VehicleRoutingAlgorithms.readAndCreateAlgorithm(bicycleMessengerProblem,"input/algorithmConfig_open.xml", stateManager);
|
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.addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
||||||
|
// algorithm.setNuOfIterations(5000);
|
||||||
Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions();
|
Collection<VehicleRoutingProblemSolution> solutions = algorithm.searchSolutions();
|
||||||
|
|
||||||
SolutionPrinter.print(Solutions.bestOf(solutions));
|
SolutionPrinter.print(Solutions.bestOf(solutions));
|
||||||
|
|
@ -198,9 +199,9 @@ public class BicycleMessenger {
|
||||||
|
|
||||||
|
|
||||||
Plotter plotter1 = new Plotter(bicycleMessengerProblem, Solutions.bestOf(solutions));
|
Plotter plotter1 = new Plotter(bicycleMessengerProblem, Solutions.bestOf(solutions));
|
||||||
plotter1.plotShipments(false);
|
plotter1.plotShipments(true);
|
||||||
plotter1.setShowFirstActivity(true);
|
plotter1.setShowFirstActivity(true);
|
||||||
// plotter1.setBoundingBox(10000, 47500, 20000, 67500);
|
plotter1.setBoundingBox(5000, 45500, 25000, 66500);
|
||||||
plotter1.plot("output/bicycleMessengerSolution.png", "bicycleMessenger");
|
plotter1.plot("output/bicycleMessengerSolution.png", "bicycleMessenger");
|
||||||
|
|
||||||
new VrpXMLWriter(bicycleMessengerProblem, solutions).write("output/bicycleMessenger.xml");
|
new VrpXMLWriter(bicycleMessengerProblem, solutions).write("output/bicycleMessenger.xml");
|
||||||
|
|
@ -249,16 +250,16 @@ public class BicycleMessenger {
|
||||||
String line = null;
|
String line = null;
|
||||||
boolean firstLine = true;
|
boolean firstLine = true;
|
||||||
VehicleType messengerType = VehicleTypeImpl.Builder.newInstance("messengerType", 15).setCostPerDistance(1).build();
|
VehicleType messengerType = VehicleTypeImpl.Builder.newInstance("messengerType", 15).setCostPerDistance(1).build();
|
||||||
VehicleType penaltyType = VehicleTypeImpl.Builder.newInstance("messengerType", 15).setFixedCost(200).setCostPerDistance(4).build();
|
VehicleType penaltyType = VehicleTypeImpl.Builder.newInstance("messengerType", 15).setFixedCost(50000).setCostPerDistance(4).build();
|
||||||
PenaltyVehicleType penaltyVehicleType = new PenaltyVehicleType(penaltyType);
|
PenaltyVehicleType penaltyVehicleType = new PenaltyVehicleType(penaltyType,4);
|
||||||
|
|
||||||
while((line = reader.readLine()) != null){
|
while((line = reader.readLine()) != null){
|
||||||
if(firstLine) { firstLine = false; continue; }
|
if(firstLine) { firstLine = false; continue; }
|
||||||
String[] tokens = line.split("\\s+");
|
String[] tokens = line.split("\\s+");
|
||||||
Vehicle vehicle = VehicleImpl.Builder.newInstance(tokens[1]).setLocationCoord(Coordinate.newInstance(Double.parseDouble(tokens[2]), Double.parseDouble(tokens[3])))
|
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);
|
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();
|
.setReturnToDepot(true).setType(penaltyVehicleType).build();
|
||||||
problemBuilder.addVehicle(penaltyVehicle);
|
problemBuilder.addVehicle(penaltyVehicle);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue