Class Capacity
java.lang.Object
com.graphhopper.jsprit.core.problem.Capacity
Capacity with an arbitrary number of capacity-dimension.
Note that this assumes the the values of each capacity dimension can be added up and subtracted
- Author:
- schroeder
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic CapacityAdds up two capacities, i.e.static CapacityMakes a deep copy of Capacity.static doubleDivides every dimension of numerator capacity by the corresponding dimension of denominator capacity, , and averages each quotient.booleanintget(int index) Returns value of capacity-dimension with specified index.intReturns the number of specified capacity dimensions.inthashCode()static CapacityReturns the inverted capacity, i.e.booleanisGreaterOrEqual(Capacity toCompare) Returns true if this capacity is greater or equal than the capacity toComparebooleanisLessOrEqual(Capacity toCompare) Returns true if this capacity is less or equal than the capacity toCompare, i.e.booleanisZero()Check if this is a zero capacity (all dimensions are zero)static CapacityReturn the maximum, i.e.static CapacityReturn the minimum, i.e.static CapacitySubtracts cap2subtract from cap and returns the resulting Capacity.toString()
-
Method Details
-
addup
Adds up two capacities, i.e. sums up each and every capacity dimension, and returns the resulting Capacity.Note that this assumes that capacity dimension can be added up.
- Parameters:
cap1- capacity to be added upcap2- capacity to be added up- Returns:
- new capacity
- Throws:
NullPointerException- if one of the args is null
-
subtract
Subtracts cap2subtract from cap and returns the resulting Capacity.- Parameters:
cap- capacity to be subtracted fromcap2subtract- capacity to subtract- Returns:
- new capacity
- Throws:
NullPointerException- if one of the args is null
-
invert
Returns the inverted capacity, i.e. it multiplies all capacity dimensions with -1.- Parameters:
cap2invert- capacity to be inverted- Returns:
- inverted capacity
- Throws:
NullPointerException- if one of the args is null
-
divide
Divides every dimension of numerator capacity by the corresponding dimension of denominator capacity, , and averages each quotient.If both nominator.get(i) and denominator.get(i) equal to 0, dimension i is ignored.
If both capacities are have only dimensions with dimensionVal=0, it returns 0.0
- Parameters:
numerator- the numeratordenominator- the denominator- Returns:
- quotient
- Throws:
IllegalStateException- if numerator.get(i) != 0 and denominator.get(i) == 0
-
copyOf
Makes a deep copy of Capacity.- Parameters:
capacity- capacity to be copied- Returns:
- copy
-
getNuOfDimensions
public int getNuOfDimensions()Returns the number of specified capacity dimensions.- Returns:
- noDimensions
-
get
public int get(int index) Returns value of capacity-dimension with specified index.If capacity dimension does not exist, it returns 0 (rather than IndexOutOfBoundsException).
- Parameters:
index- dimension index of the capacity value to be retrieved- Returns:
- the according dimension value
-
isLessOrEqual
Returns true if this capacity is less or equal than the capacity toCompare, i.e. if none of the capacity dimensions > than the corresponding dimension in toCompare.- Parameters:
toCompare- the capacity to compare- Returns:
- true if this capacity is less or equal than toCompare
- Throws:
NullPointerException- if one of the args is null
-
isGreaterOrEqual
Returns true if this capacity is greater or equal than the capacity toCompare- Parameters:
toCompare- the capacity to compare- Returns:
- true if this capacity is greater or equal than toCompare
- Throws:
NullPointerException- if one of the args is null
-
isZero
public boolean isZero()Check if this is a zero capacity (all dimensions are zero)- Returns:
- true if all dimensions are zero
-
toString
-
max
Return the maximum, i.e. the maximum of each capacity dimension.- Parameters:
cap1- first capacity to comparecap2- second capacity to compare- Returns:
- capacity maximum of each capacity dimension
-
min
Return the minimum, i.e. the minimum of each capacity dimension.- Parameters:
cap1- first capacity to comparecap2- second capacity to compare- Returns:
- capacity minimum of each capacity dimension
-
equals
-
hashCode
public int hashCode()
-