diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/util/FastVehicleRoutingTransportCostsMatrix.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/util/FastVehicleRoutingTransportCostsMatrix.java index 80742c4c..5e6a5d1d 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/util/FastVehicleRoutingTransportCostsMatrix.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/util/FastVehicleRoutingTransportCostsMatrix.java @@ -45,6 +45,8 @@ public class FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehic private double[][][] matrix; + private final int noLocations; + /** * Creates a new builder returning the matrix-builder. *
If you want to consider symmetric matrices, set isSymmetric to true. @@ -59,6 +61,7 @@ public class FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehic private Builder(int noLocations, boolean isSymmetric) { this.isSymmetric = isSymmetric; matrix = new double[noLocations][noLocations][2]; + this.noLocations = noLocations; } /** @@ -74,11 +77,11 @@ public class FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehic return this; } - private void add(int fromIndex, int toIndex, int indicatorIndex, double distance) { + private void add(int fromIndex, int toIndex, int indicatorIndex, double value) { if (isSymmetric) { - if (fromIndex < toIndex) matrix[fromIndex][toIndex][indicatorIndex] = distance; - else matrix[toIndex][fromIndex][indicatorIndex] = distance; - } else matrix[fromIndex][toIndex][indicatorIndex] = distance; + if (fromIndex < toIndex) matrix[fromIndex][toIndex][indicatorIndex] = value; + else matrix[toIndex][fromIndex][indicatorIndex] = value; + } else matrix[fromIndex][toIndex][indicatorIndex] = value; } /** @@ -115,9 +118,12 @@ public class FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehic private final double[][][] matrix; + private int noLocations; + private FastVehicleRoutingTransportCostsMatrix(Builder builder) { this.isSymmetric = builder.isSymmetric; matrix = builder.matrix; + noLocations = builder.noLocations; } /** @@ -174,4 +180,9 @@ public class FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehic return costParams.perDistanceUnit * getDistance(from.getIndex(), to.getIndex()) + costParams.perTransportTimeUnit * getTransportTime(from, to, departureTime, driver, vehicle); } + public int getNoLocations() { + return noLocations; + } + + }