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

comply with .editorconfig

This commit is contained in:
oblonski 2015-08-29 12:46:52 +02:00
parent 58afc3590d
commit 33075b479f
416 changed files with 29653 additions and 29979 deletions

View file

@ -11,7 +11,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package jsprit.examples;
@ -33,77 +33,77 @@ import java.util.Collection;
public class SolomonExampleWithSpecifiedVehicleEndLocations {
public static void main(String[] args) {
/*
public static void main(String[] args) {
/*
* some preparation - create output folder
*/
File dir = new File("output");
// if the directory does not exist, create it
if (!dir.exists()){
System.out.println("creating directory ./output");
boolean result = dir.mkdir();
if(result) System.out.println("./output created");
}
File dir = new File("output");
// if the directory does not exist, create it
if (!dir.exists()) {
System.out.println("creating directory ./output");
boolean result = dir.mkdir();
if (result) System.out.println("./output created");
}
/*
* Build the problem.
*
*
* But define a problem-builder first.
*/
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
/*
* A solomonReader reads solomon-instance files, and stores the required information in the builder.
*/
new VrpXMLReader(vrpBuilder).read("input/deliveries_solomon_specifiedVehicleEndLocations_c101.xml");
new VrpXMLReader(vrpBuilder).read("input/deliveries_solomon_specifiedVehicleEndLocations_c101.xml");
/*
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
*/
VehicleRoutingProblem vrp = vrpBuilder.build();
Plotter pblmPlotter = new Plotter(vrp);
pblmPlotter.plot("output/solomon_C101_specifiedVehicleEndLocations.png","C101");
VehicleRoutingProblem vrp = vrpBuilder.build();
Plotter pblmPlotter = new Plotter(vrp);
pblmPlotter.plot("output/solomon_C101_specifiedVehicleEndLocations.png", "C101");
/*
* 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_fix.xml");
vra.setMaxIterations(20000);
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfig_fix.xml");
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();
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
/*
* Retrieve best solution.
*/
VehicleRoutingProblemSolution solution = new SelectBest().selectSolution(solutions);
VehicleRoutingProblemSolution solution = new SelectBest().selectSolution(solutions);
/*
* print solution
*/
SolutionPrinter.print(solution);
SolutionPrinter.print(solution);
/*
* Plot solution.
* Plot solution.
*/
// SolutionPlotter.plotSolutionAsPNG(vrp, solution, "output/solomon_C101_specifiedVehicleEndLocations_solution.png","C101");
Plotter solPlotter = new Plotter(vrp, solution);
solPlotter.plot("output/solomon_C101_specifiedVehicleEndLocations_solution.png","C101");
new GraphStreamViewer(vrp, solution).setRenderDelay(50).labelWith(Label.ID).setEnableAutoLayout(true).display();
}
Plotter solPlotter = new Plotter(vrp, solution);
solPlotter.plot("output/solomon_C101_specifiedVehicleEndLocations_solution.png", "C101");
new GraphStreamViewer(vrp, solution).setRenderDelay(50).labelWith(Label.ID).setEnableAutoLayout(true).display();
}
}