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

replace get/setDeliveryLocation(...) with get/setDeliveryLocationId(...)

replace get/setPickupLocation(...) with get/setPickupLocationId(...)
This commit is contained in:
oblonski 2014-09-04 14:02:43 +02:00
parent 9971d3d349
commit afe98c1051
22 changed files with 278 additions and 308 deletions

View file

@ -340,8 +340,8 @@ public class BicycleMessenger {
static double getTimeOfDirectRoute(Job job, Vehicle v, VehicleRoutingTransportCosts routingCosts) {
Shipment envelope = (Shipment) job;
return routingCosts.getTransportTime(v.getStartLocationId(), envelope.getPickupLocation(), 0.0, DriverImpl.noDriver(), v) +
routingCosts.getTransportTime(envelope.getPickupLocation(), envelope.getDeliveryLocation(), 0.0, DriverImpl.noDriver(), v);
return routingCosts.getTransportTime(v.getStartLocationId(), envelope.getPickupLocationId(), 0.0, DriverImpl.noDriver(), v) +
routingCosts.getTransportTime(envelope.getPickupLocationId(), envelope.getDeliveryLocationId(), 0.0, DriverImpl.noDriver(), v);
}
private static void readEnvelopes(Builder problemBuilder) throws IOException {

View file

@ -50,18 +50,7 @@ import java.util.Collection;
public class RefuseCollectionExample {
static class RelationKey {
// static RelationKey newKey(String from, String to){
// int fromInt = Integer.parseInt(from);
// int toInt = Integer.parseInt(to);
// if(fromInt < toInt){
// return new RelationKey(from, to);
// }
// else {
// return new RelationKey(to, from);
// }
// }
final String from;
final String to;
@ -108,39 +97,6 @@ public class RefuseCollectionExample {
return true;
}
}
// static class RoutingCosts implements VehicleRoutingTransportCosts {
//
// private Map<RelationKey,Integer> distances;
//
// public RoutingCosts(Map<RelationKey, Integer> distances) {
// super();
// this.distances = distances;
// }
//
// @Override
// public double getTransportTime(String fromId, String toId, double departureTime, Driver driver, Vehicle vehicle) {
// return getTransportCost(fromId, toId, departureTime, driver, vehicle);
// }
//
// @Override
// public double getBackwardTransportTime(String fromId, String toId, double arrivalTime, Driver driver, Vehicle vehicle) {
// return getTransportCost(fromId, toId, arrivalTime, driver, vehicle);
// }
//
// @Override
// public double getTransportCost(String fromId, String toId,double departureTime, Driver driver, Vehicle vehicle) {
// if(fromId.equals(toId)) return 0.0;
// RelationKey key = RelationKey.newKey(fromId, toId);
// return distances.get(key);
// }
//
// @Override
// public double getBackwardTransportCost(String fromId, String toId,double arrivalTime, Driver driver, Vehicle vehicle) {
// return getTransportCost(fromId, toId, arrivalTime, driver, vehicle);
// }
//
// }
public static void main(String[] args) throws IOException {
/*

View file

@ -16,77 +16,80 @@
******************************************************************************/
package jsprit.examples;
import jsprit.analysis.toolbox.Plotter;
import jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener;
import jsprit.analysis.toolbox.GraphStreamViewer;
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
import jsprit.core.algorithm.selector.SelectBest;
import jsprit.core.problem.VehicleRoutingProblem;
import jsprit.core.problem.io.VrpXMLReader;
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
import jsprit.core.reporting.SolutionPrinter;
import jsprit.instance.reader.SolomonReader;
import jsprit.util.Examples;
import java.util.Collection;
public class SolomonR101Example {
public static void main(String[] args) {
/*
* some preparation - create output folder
*/
Examples.createOutputFolder();
/*
* Build the problem.
*
*
* But define a problem-builder first.
*/
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
/*
* A solomonReader reads solomon-instance files, and stores the required information in the builder.
*/
new SolomonReader(vrpBuilder).read("input/R101.txt");
// new SolomonReader(vrpBuilder).read("/Users/schroeder/IdeaProjects/jsprit/jsprit-instances/instances/solomon/R211.txt");
new VrpXMLReader(vrpBuilder).read("output/R211.xml");
/*
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
*/
VehicleRoutingProblem vrp = vrpBuilder.build();
new Plotter(vrp).plot("output/solomon_R101.png", "R101");
// new VrpXMLWriter(vrp).write("output/R211.xml");
// new Plotter(vrp).plot("output/solomon_R101.png", "R101");
/*
* Define the required vehicle-routing algorithms to solve the above problem.
*
*
* The algorithm can be defined and configured in an xml-file.
*/
// VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfig.xml");
vra.setMaxIterations(100);
vra.setMaxIterations(20000);
// vra.setPrematureBreak(100);
// vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/sol_progress.png"));
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/sol_progress.png"));
/*
* Solve the problem.
*
*
*
*/
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
/*
* Retrieve best solution.
*/
VehicleRoutingProblemSolution solution = new SelectBest().selectSolution(solutions);
/*
* print solution
*/
SolutionPrinter.print(solution);
SolutionPrinter.print(vrp,solution, SolutionPrinter.Print.VERBOSE);
new GraphStreamViewer(vrp,solution).display();
/*
* Plot solution.
* Plot solution.
*/
new Plotter(vrp,solution).plot( "output/solomon_R101_solution.png","R101");
// new Plotter(vrp,solution).plot( "output/solomon_R101_solution.png","R101");
}