-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMain.java
More file actions
60 lines (49 loc) · 2.25 KB
/
Copy pathMain.java
File metadata and controls
60 lines (49 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package ai.timefold.solver.benchmarks.competitive.cvrplib;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
import java.util.concurrent.ExecutionException;
import ai.timefold.solver.benchmarks.competitive.AbstractCompetitiveBenchmark;
import ai.timefold.solver.benchmarks.examples.common.persistence.AbstractSolutionImporter;
import ai.timefold.solver.benchmarks.examples.vehiclerouting.domain.VehicleRoutingSolution;
import ai.timefold.solver.benchmarks.examples.vehiclerouting.domain.location.AirLocation;
import ai.timefold.solver.benchmarks.examples.vehiclerouting.persistence.VehicleRoutingImporter;
import ai.timefold.solver.core.api.score.HardSoftScore;
public class Main
extends AbstractCompetitiveBenchmark<CVRPLIBDataset, CVRPLIBConfiguration, VehicleRoutingSolution, HardSoftScore> {
public static void main(String[] args) throws ExecutionException, InterruptedException, IOException {
var benchmark = new Main();
benchmark.run(List.of(CVRPLIBConfiguration.COMMUNITY_EDITION, CVRPLIBConfiguration.ENTERPRISE_EDITION),
CVRPLIBDataset.values());
}
@Override
protected String getLibraryName() {
return "CVRPLIB";
}
@Override
protected HardSoftScore extractScore(VehicleRoutingSolution vehicleRoutingSolution) {
return vehicleRoutingSolution.getScore();
}
@Override
protected BigDecimal extractResult(CVRPLIBDataset dataset, HardSoftScore score) {
return BigDecimal.valueOf(-score.softScore())
.divide(BigDecimal.valueOf(AirLocation.MULTIPLIER), 1, RoundingMode.HALF_EVEN);
}
@Override
protected int countValues(VehicleRoutingSolution vehicleRoutingSolution) {
return vehicleRoutingSolution.getCustomerList().size();
}
@Override
protected int countEntities(VehicleRoutingSolution vehicleRoutingSolution) {
return vehicleRoutingSolution.getVehicleList().size();
}
@Override
protected AbstractSolutionImporter<VehicleRoutingSolution> createImporter() {
return new VehicleRoutingImporter();
}
@Override
public void enrichSolution(VehicleRoutingSolution vehicleRoutingSolution) {
// No changes are applied to the solution
}
}