1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00
This commit is contained in:
oblonski 2016-05-09 22:29:48 +02:00
parent c4c7de152f
commit ee3b1589ba
73 changed files with 223 additions and 211 deletions

View file

@ -64,17 +64,17 @@ import java.util.Map;
/**
* This class provides the/a solution to the following problem:
* <p/>
* <p>
* Statement of the problem (see Stackoverflow: http://stackoverflow.com/questions/19080537/bicycle-messenger-tsppd-with-optaplanner/20412598#20412598):
* <p/>
* <p>
* Optimize the routes for a bicycle messenger service!
* Assume 5 messengers that have to pick up 30 envelopes distributed through the city. These 5 messengers are distributed through the city as well. Thus
* there is no single depot and they do not need to go back to their original starting location.
* <p/>
* <p>
* Additional hard constraints:
* 1) Every messenger can carry up to fifteen envelopes
* 2) The way an evelopes travels should be less than three times the direct route (so delivery does not take too long)
* <p/>
* <p>
* Thus this problem is basically a Capacitated VRP with Pickups and Deliveries, Multiple Depots, Open Routes and Time Windows/Restrictions.
*
* @author stefan schroeder
@ -144,7 +144,7 @@ public class BicycleMessenger {
/**
* When inserting the activities of an envelope which are pickup and deliver envelope, this constraint makes insertion procedure to ignore messengers that are too far away to meet the 3*directTime-Constraint.
* <p/>
* <p>
* <p>one does not need this constraint. but it is faster. the earlier the solution-space can be constraint the better/faster.
*
* @author schroeder
@ -172,7 +172,7 @@ public class BicycleMessenger {
/**
* updates the state "latest-activity-start-time" (required above) once route/activity states changed, i.e. when removing or inserting an envelope-activity
* <p/>
* <p>
* <p>thus once either the insertion-procedure starts or an envelope has been inserted, this visitor runs through the route in reverse order (i.e. starting with the end of the route) and
* calculates the latest-activity-start-time (or latest-activity-arrival-time) which is the time to just meet the constraints of subsequent activities.
*

View file

@ -54,7 +54,7 @@ import java.util.Collection;
* 18 9 56 13
* 19 62 48 15
* 20 66 14 22
* <p/>
* <p>
* vehicles (id,cap,fixed costs, perDistance, #vehicles) at location (40,40)
* 1 120 1000 1.0 2
* 2 160 1500 1.1 1

View file

@ -43,7 +43,7 @@ import java.util.Collection;
/**
* Illustrates dependencies between jobs.
* <p/>
* <p>
* The hard requirement here is that three jobs with name "get key", "use key" and "deliver key" need to
* be not only in loose sequence in one particular route but also one after another (without any other activities
* between them).

View file

@ -47,12 +47,12 @@ import java.util.Collection;
/**
* Illustrates a VRP with multiple products.
* <p/>
* <p>
* It has the hard requirements that no two different products can be transported in the same vehicle at the same time.
* This might be important if products require different temperatures. For example, if a vehicle transports
* apples then no bananas can be loaded (and the other way around). Once all apples have been unloaded, bananas can
* be loaded.
* <p/>
* <p>
* See also the discussion here: https://groups.google.com/forum/#!topic/jsprit-mailing-list/2JQqY4loC0U
*/
public class MultipleProductsWithLoadConstraintExample {

View file

@ -16,9 +16,8 @@
******************************************************************************/
package com.graphhopper.jsprit.examples;
import com.graphhopper.jsprit.analysis.toolbox.GraphStreamViewer;
import com.graphhopper.jsprit.analysis.toolbox.GraphStreamViewer.Label;
import com.graphhopper.jsprit.analysis.toolbox.Plotter;
import com.graphhopper.jsprit.analysis.toolbox.AlgorithmEventsRecorder;
import com.graphhopper.jsprit.analysis.toolbox.AlgorithmEventsViewer;
import com.graphhopper.jsprit.core.algorithm.VehicleRoutingAlgorithm;
import com.graphhopper.jsprit.core.algorithm.box.Jsprit;
import com.graphhopper.jsprit.core.algorithm.selector.SelectBest;
@ -56,7 +55,11 @@ public class SolomonOpenExample {
*/
VehicleRoutingProblem vrp = vrpBuilder.build();
new Plotter(vrp).plot("output/solomon_C101_open.png", "C101");
// new Plotter(vrp).plot("output/solomon_C101_open.png", "C101");
AlgorithmEventsRecorder eventsRecorder = new AlgorithmEventsRecorder(vrp, "output/events.dgs.gz");
eventsRecorder.setRecordingRange(0, 50);
/*
* Define the required vehicle-routing algorithms to solve the above problem.
@ -65,9 +68,13 @@ public class SolomonOpenExample {
*/
// VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
// VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfig_fix.xml");
VehicleRoutingAlgorithm vra = Jsprit.createAlgorithm(vrp);
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.THREADS, "4")
.setProperty(Jsprit.Parameter.FAST_REGRET, "true")
.setProperty(Jsprit.Parameter.CONSTRUCTION, Jsprit.Construction.BEST_INSERTION.toString()).buildAlgorithm();
// vra.setPrematureBreak(100);
// vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/sol_progress.png"));
vra.addListener(eventsRecorder);
vra.setMaxIterations(200);
/*
* Solve the problem.
*
@ -91,9 +98,14 @@ public class SolomonOpenExample {
// SolutionPlotter.plotSolutionAsPNG(vrp, solution, "output/solomon_C101_open_solution.png","C101");
new GraphStreamViewer(vrp, solution).setRenderDelay(150).labelWith(Label.ID).display();
// new GraphStreamViewer(vrp, solution).setRenderDelay(100).labelWith(Label.ID).display();
AlgorithmEventsViewer viewer = new AlgorithmEventsViewer();
viewer.setRuinDelay(8);
viewer.setRecreationDelay(2);
viewer.display("output/events.dgs.gz");
}
}