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

get no. locations

This commit is contained in:
oblonski 2017-03-15 15:20:57 +01:00
parent 185980d8c0
commit 562be55ae6
No known key found for this signature in database
GPG key ID: 179DE487285680D1

View file

@ -45,6 +45,8 @@ public class FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehic
private double[][][] matrix;
private final int noLocations;
/**
* Creates a new builder returning the matrix-builder.
* <p>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;
}
}