mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
some json stuff
This commit is contained in:
parent
dcfba5463d
commit
82899edc97
2 changed files with 13 additions and 2 deletions
|
|
@ -32,7 +32,9 @@ import jsprit.core.problem.vehicle.VehicleType;
|
|||
import jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
import jsprit.core.util.Coordinate;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
|
@ -91,7 +93,12 @@ public class VrpJsonReader {
|
|||
JsonNode node = null;
|
||||
try {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
node = objectMapper.readTree(jsonFile);
|
||||
String jsonContent = "";
|
||||
BufferedReader reader = new BufferedReader(new FileReader(jsonFile));
|
||||
String line;
|
||||
while((line = reader.readLine()) != null) jsonContent += line;
|
||||
reader.close();
|
||||
node = objectMapper.readTree(jsonContent);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
|
|
|
|||
|
|
@ -310,7 +310,11 @@ public class VrpJsonWriter {
|
|||
new VrpJsonWriter(vrp).write(new File("output/vrp.json"));
|
||||
// System.out.println(new VrpJsonWriter(vrp).toString());
|
||||
|
||||
VehicleRoutingAlgorithm vra = new GreedySchrimpfFactory().createAlgorithm(vrp);
|
||||
VehicleRoutingProblem.Builder vrpBuilder_ = VehicleRoutingProblem.Builder.newInstance();
|
||||
new VrpJsonReader(vrpBuilder_).read("output/vpr.json");
|
||||
VehicleRoutingProblem vrp_ = vrpBuilder_.build();
|
||||
|
||||
VehicleRoutingAlgorithm vra = new GreedySchrimpfFactory().createAlgorithm(vrp_);
|
||||
VehicleRoutingProblemSolution solutions = Solutions.bestOf(vra.searchSolutions());
|
||||
|
||||
new VrpJsonWriter(vrp,solutions,new SolutionAnalyser.DistanceCalculator() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue