mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
fix example
This commit is contained in:
parent
b3af33ccf9
commit
ffd720216f
3 changed files with 63 additions and 35 deletions
|
|
@ -2,24 +2,9 @@
|
||||||
<problem xmlns="http://www.w3schools.com"
|
<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">
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com vrp_xml_schema.xsd">
|
||||||
<problemType>
|
<problemType>
|
||||||
<fleetSize>FINITE</fleetSize>
|
<fleetSize>INFINITE</fleetSize>
|
||||||
</problemType>
|
</problemType>
|
||||||
<vehicles>
|
<vehicles>
|
||||||
<vehicle>
|
|
||||||
<id>v2</id>
|
|
||||||
<typeId>vehType2</typeId>
|
|
||||||
<startLocation>
|
|
||||||
<id>loc</id>
|
|
||||||
</startLocation>
|
|
||||||
<endLocation>
|
|
||||||
<id>loc</id>
|
|
||||||
</endLocation>
|
|
||||||
<timeSchedule>
|
|
||||||
<start>0.0</start>
|
|
||||||
<end>1.7976931348623157E308</end>
|
|
||||||
</timeSchedule>
|
|
||||||
<returnToDepot>true</returnToDepot>
|
|
||||||
</vehicle>
|
|
||||||
<vehicle>
|
<vehicle>
|
||||||
<id>v1</id>
|
<id>v1</id>
|
||||||
<typeId>vehType</typeId>
|
<typeId>vehType</typeId>
|
||||||
|
|
@ -48,16 +33,58 @@
|
||||||
<time>0.0</time>
|
<time>0.0</time>
|
||||||
</costs>
|
</costs>
|
||||||
</type>
|
</type>
|
||||||
<type>
|
|
||||||
<id>vehType2</id>
|
|
||||||
<capacity-dimensions>
|
|
||||||
<dimension index="0">200</dimension>
|
|
||||||
</capacity-dimensions>
|
|
||||||
<costs>
|
|
||||||
<fixed>0.0</fixed>
|
|
||||||
<distance>1.0</distance>
|
|
||||||
<time>0.0</time>
|
|
||||||
</costs>
|
|
||||||
</type>
|
|
||||||
</vehicleTypes>
|
</vehicleTypes>
|
||||||
|
<services>
|
||||||
|
<service id="1" type="service">
|
||||||
|
<location>
|
||||||
|
<id>loc</id>
|
||||||
|
</location>
|
||||||
|
<capacity-dimensions>
|
||||||
|
<dimension index="0">1</dimension>
|
||||||
|
</capacity-dimensions>
|
||||||
|
<duration>2.0</duration>
|
||||||
|
<timeWindows>
|
||||||
|
<timeWindow>
|
||||||
|
<start>0.0</start>
|
||||||
|
<end>1.7976931348623157E308</end>
|
||||||
|
</timeWindow>
|
||||||
|
</timeWindows>
|
||||||
|
</service>
|
||||||
|
<service id="2" type="service">
|
||||||
|
<location>
|
||||||
|
<id>loc2</id>
|
||||||
|
</location>
|
||||||
|
<capacity-dimensions>
|
||||||
|
<dimension index="0">1</dimension>
|
||||||
|
</capacity-dimensions>
|
||||||
|
<duration>4.0</duration>
|
||||||
|
<timeWindows>
|
||||||
|
<timeWindow>
|
||||||
|
<start>0.0</start>
|
||||||
|
<end>1.7976931348623157E308</end>
|
||||||
|
</timeWindow>
|
||||||
|
</timeWindows>
|
||||||
|
</service>
|
||||||
|
</services>
|
||||||
|
<solutions>
|
||||||
|
<solution>
|
||||||
|
<cost>10.0</cost>
|
||||||
|
<routes>
|
||||||
|
<route>
|
||||||
|
<driverId>noDriver</driverId>
|
||||||
|
<vehicleId>v1</vehicleId>
|
||||||
|
<start>0.0</start>
|
||||||
|
<act type="service">
|
||||||
|
<serviceId>1</serviceId>
|
||||||
|
<arrTime>0.0</arrTime>
|
||||||
|
<endTime>0.0</endTime>
|
||||||
|
</act>
|
||||||
|
<end>0.0</end>
|
||||||
|
</route>
|
||||||
|
</routes>
|
||||||
|
<unassignedJobs>
|
||||||
|
<job id="2"/>
|
||||||
|
</unassignedJobs>
|
||||||
|
</solution>
|
||||||
|
</solutions>
|
||||||
</problem>
|
</problem>
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,9 @@ import jsprit.analysis.toolbox.GraphStreamViewer;
|
||||||
import jsprit.analysis.toolbox.Plotter;
|
import jsprit.analysis.toolbox.Plotter;
|
||||||
import jsprit.analysis.toolbox.StopWatch;
|
import jsprit.analysis.toolbox.StopWatch;
|
||||||
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||||
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
import jsprit.core.algorithm.box.Jsprit;
|
||||||
import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners.Priority;
|
import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners.Priority;
|
||||||
|
import jsprit.core.problem.Location;
|
||||||
import jsprit.core.problem.VehicleRoutingProblem;
|
import jsprit.core.problem.VehicleRoutingProblem;
|
||||||
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
||||||
import jsprit.core.problem.io.VrpXMLReader;
|
import jsprit.core.problem.io.VrpXMLReader;
|
||||||
|
|
@ -73,7 +74,7 @@ public class MultipleDepotExample {
|
||||||
for(Coordinate depotCoord : Arrays.asList(firstDepotCoord,second,third,fourth)){
|
for(Coordinate depotCoord : Arrays.asList(firstDepotCoord,second,third,fourth)){
|
||||||
for(int i=0;i<nuOfVehicles;i++){
|
for(int i=0;i<nuOfVehicles;i++){
|
||||||
VehicleTypeImpl vehicleType = VehicleTypeImpl.Builder.newInstance(depotCounter + "_type").addCapacityDimension(0, capacity).setCostPerDistance(1.0).build();
|
VehicleTypeImpl vehicleType = VehicleTypeImpl.Builder.newInstance(depotCounter + "_type").addCapacityDimension(0, capacity).setCostPerDistance(1.0).build();
|
||||||
VehicleImpl vehicle = VehicleImpl.Builder.newInstance(depotCounter + "_" + (i+1) + "_vehicle").setStartLocationCoordinate(depotCoord).setType(vehicleType).build();
|
VehicleImpl vehicle = VehicleImpl.Builder.newInstance(depotCounter + "_" + (i + 1) + "_vehicle").setStartLocation(Location.newInstance(depotCoord.getX(), depotCoord.getY())).setType(vehicleType).build();
|
||||||
vrpBuilder.addVehicle(vehicle);
|
vrpBuilder.addVehicle(vehicle);
|
||||||
}
|
}
|
||||||
depotCounter++;
|
depotCounter++;
|
||||||
|
|
@ -97,7 +98,7 @@ public class MultipleDepotExample {
|
||||||
/*
|
/*
|
||||||
* solve the problem
|
* solve the problem
|
||||||
*/
|
*/
|
||||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfigWithSchrimpfAcceptance.xml");
|
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.THREADS,"5").buildAlgorithm();
|
||||||
vra.getAlgorithmListeners().addListener(new StopWatch(),Priority.HIGH);
|
vra.getAlgorithmListeners().addListener(new StopWatch(),Priority.HIGH);
|
||||||
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
||||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,11 @@ import jsprit.analysis.toolbox.GraphStreamViewer;
|
||||||
import jsprit.analysis.toolbox.Plotter;
|
import jsprit.analysis.toolbox.Plotter;
|
||||||
import jsprit.analysis.toolbox.StopWatch;
|
import jsprit.analysis.toolbox.StopWatch;
|
||||||
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||||
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
import jsprit.core.algorithm.box.Jsprit;
|
||||||
import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners.Priority;
|
import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners.Priority;
|
||||||
|
import jsprit.core.problem.Location;
|
||||||
import jsprit.core.problem.VehicleRoutingProblem;
|
import jsprit.core.problem.VehicleRoutingProblem;
|
||||||
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
import jsprit.core.problem.VehicleRoutingProblem.FleetSize;
|
||||||
import jsprit.core.problem.io.VrpXMLReader;
|
|
||||||
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
||||||
import jsprit.core.problem.vehicle.VehicleImpl;
|
import jsprit.core.problem.vehicle.VehicleImpl;
|
||||||
import jsprit.core.problem.vehicle.VehicleType;
|
import jsprit.core.problem.vehicle.VehicleType;
|
||||||
|
|
@ -76,7 +76,7 @@ public class MultipleDepotExample2 {
|
||||||
.addCapacityDimension(0, capacity).setCostPerDistance(1.0).build();
|
.addCapacityDimension(0, capacity).setCostPerDistance(1.0).build();
|
||||||
String vehicleId = depotCounter + "_" + (i+1) + "_vehicle";
|
String vehicleId = depotCounter + "_" + (i+1) + "_vehicle";
|
||||||
VehicleImpl.Builder vehicleBuilder = VehicleImpl.Builder.newInstance(vehicleId);
|
VehicleImpl.Builder vehicleBuilder = VehicleImpl.Builder.newInstance(vehicleId);
|
||||||
vehicleBuilder.setStartLocationCoordinate(depotCoord);
|
vehicleBuilder.setStartLocation(Location.newInstance(depotCoord.getX(),depotCoord.getY()));
|
||||||
vehicleBuilder.setType(vehicleType);
|
vehicleBuilder.setType(vehicleType);
|
||||||
vehicleBuilder.setLatestArrival(maxDuration);
|
vehicleBuilder.setLatestArrival(maxDuration);
|
||||||
VehicleImpl vehicle = vehicleBuilder.build();
|
VehicleImpl vehicle = vehicleBuilder.build();
|
||||||
|
|
@ -104,8 +104,8 @@ public class MultipleDepotExample2 {
|
||||||
/*
|
/*
|
||||||
* solve the problem
|
* solve the problem
|
||||||
*/
|
*/
|
||||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp,12, "input/algorithmConfig.xml");
|
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.THREADS,"5").buildAlgorithm();
|
||||||
vra.setMaxIterations(5000);
|
vra.setMaxIterations(2000);
|
||||||
vra.getAlgorithmListeners().addListener(new StopWatch(),Priority.HIGH);
|
vra.getAlgorithmListeners().addListener(new StopWatch(),Priority.HIGH);
|
||||||
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
||||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue