Skip to content

Commit

Permalink
Update project name and set objective value to be the sum of distances
Browse files Browse the repository at this point in the history
  • Loading branch information
larsbeck committed Mar 13, 2024
1 parent 5044c14 commit e009c76
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion routing-java-ortools/routing-java-ortools.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"name": "Main",
"request": "launch",
"mainClass": "com.nextmv.example.Main",
"projectName": "routing-java-ortools",
"projectName": "ORToolsJava",
"args": ["--input", "input.json", "--output", "output.json"]
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ static Output getOutput(
return new Output(
vehicles,
duration,
runDuration,
solution.objectiveValue());
runDuration);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,22 @@ private final class Statistics {
public Output(
List<Vehicle> vehicles,
double duration,
double runDuration,
double value) {
double runDuration) {
this.solutions = new ArrayList<Solution>();
Solution solution = new Solution();
solution.vehicles = vehicles;
solution.value = value;
this.solutions.add(solution);
this.statistics = new Statistics();
this.statistics.run = new StatisticsRun();
this.statistics.run.duration = runDuration;
this.statistics.result = new StatisticsResult();
this.statistics.result.value = value;
this.statistics.result.duration = duration;

// we are using the sum of the route distances as the value
solution.value = vehicles.stream()
.mapToDouble(v -> v.getDistance()).sum();
this.statistics.result.value = solution.value;

// fill custom section
this.statistics.result.custom = new StatisticsResultCustom();

Expand All @@ -69,7 +71,7 @@ public Output(

// find the vehicle with the maximum route distance
this.statistics.result.custom.maxRouteDistance = (int) vehicles.stream()
.mapToDouble(v -> v.getDistance()-2).max().orElse(0);
.mapToDouble(v -> v.getDistance()).max().orElse(0);

// find the vehicle with the maximum number of stops
this.statistics.result.custom.maxStopsInVehicle = (int) vehicles.stream()
Expand Down

0 comments on commit e009c76

Please sign in to comment.