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:
parent
185980d8c0
commit
562be55ae6
1 changed files with 15 additions and 4 deletions
|
|
@ -45,6 +45,8 @@ public class FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehic
|
||||||
|
|
||||||
private double[][][] matrix;
|
private double[][][] matrix;
|
||||||
|
|
||||||
|
private final int noLocations;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new builder returning the matrix-builder.
|
* Creates a new builder returning the matrix-builder.
|
||||||
* <p>If you want to consider symmetric matrices, set isSymmetric to true.
|
* <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) {
|
private Builder(int noLocations, boolean isSymmetric) {
|
||||||
this.isSymmetric = isSymmetric;
|
this.isSymmetric = isSymmetric;
|
||||||
matrix = new double[noLocations][noLocations][2];
|
matrix = new double[noLocations][noLocations][2];
|
||||||
|
this.noLocations = noLocations;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -74,11 +77,11 @@ public class FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehic
|
||||||
return this;
|
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 (isSymmetric) {
|
||||||
if (fromIndex < toIndex) matrix[fromIndex][toIndex][indicatorIndex] = distance;
|
if (fromIndex < toIndex) matrix[fromIndex][toIndex][indicatorIndex] = value;
|
||||||
else matrix[toIndex][fromIndex][indicatorIndex] = distance;
|
else matrix[toIndex][fromIndex][indicatorIndex] = value;
|
||||||
} else matrix[fromIndex][toIndex][indicatorIndex] = distance;
|
} else matrix[fromIndex][toIndex][indicatorIndex] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -115,9 +118,12 @@ public class FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehic
|
||||||
|
|
||||||
private final double[][][] matrix;
|
private final double[][][] matrix;
|
||||||
|
|
||||||
|
private int noLocations;
|
||||||
|
|
||||||
private FastVehicleRoutingTransportCostsMatrix(Builder builder) {
|
private FastVehicleRoutingTransportCostsMatrix(Builder builder) {
|
||||||
this.isSymmetric = builder.isSymmetric;
|
this.isSymmetric = builder.isSymmetric;
|
||||||
matrix = builder.matrix;
|
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);
|
return costParams.perDistanceUnit * getDistance(from.getIndex(), to.getIndex()) + costParams.perTransportTimeUnit * getTransportTime(from, to, departureTime, driver, vehicle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getNoLocations() {
|
||||||
|
return noLocations;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue