Class AbstractLoadCapacity
java.lang.Object
com.dna.jopt.member.unit.pnd.capacity.AbstractLoadCapacity
- All Implemented Interfaces:
ILoadCapacity, IPNDItem
- Direct Known Subclasses:
DegradingLoadCapacity, SimpleLoadCapacity
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleThe part of a piece by which the left total capacity of a depot may miss a whole number of pieces and still count as that number. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractLoadCapacity(String loadCapacityId, int maximalIndividualLoadCapacity, int currentLoad) -
Method Summary
Modifier and TypeMethodDescriptiondoubleGets the current load.getId()Gets the id of the PNDItemGets the load pickup time.doubleGets the maximal individual load capacity.intGets the search index.voidsetLoadPickupTime(long loadPickupTimeMillis) voidsetSearchIndex(int searchIndex) Sets the search index.protected static doubletoWholePiecesWithinTolerance(double pieces) Returns a number of pieces as the nearest whole number if it lies withinPIECE_FIT_TOLERANCEof it, otherwise unchanged.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ILoadCapacity
merge, visit
-
Field Details
-
PIECE_FIT_TOLERANCE
public static final double PIECE_FIT_TOLERANCEThe part of a piece by which the left total capacity of a depot may miss a whole number of pieces and still count as that number. Decimal capacity factors leave rounding noise in the left capacity: with a factor of 0.1, a total of 1.0 and 7 pieces on board, 0.29999999999999993 are left instead of 0.3. The noise is a few units in the last place of the total, far below a billionth of a piece as long as a depot holds less than about a million pieces of a good. A billionth of a piece never decides whether a real piece fits.- See Also:
-
-
Constructor Details
-
AbstractLoadCapacity
public AbstractLoadCapacity(String loadCapacityId, int maximalIndividualLoadCapacity, int currentLoad)
-
-
Method Details
-
toWholePiecesWithinTolerance
protected static double toWholePiecesWithinTolerance(double pieces) Returns a number of pieces as the nearest whole number if it lies withinPIECE_FIT_TOLERANCEof it, otherwise unchanged.- Parameters:
pieces- the number of pieces, for example the left total capacity of a depot divided by the capacity factor of a load- Returns:
- the number of pieces, without rounding noise
-
setLoadPickupTime
public void setLoadPickupTime(long loadPickupTimeMillis) - Specified by:
setLoadPickupTimein interfaceILoadCapacity
-
getLoadPickupTime
Description copied from interface:ILoadCapacityGets the load pickup time. In case the capacity accepts a load, the pickup time is saved.- Specified by:
getLoadPickupTimein interfaceILoadCapacity- Returns:
- the load pickup time
-
setSearchIndex
public void setSearchIndex(int searchIndex) Description copied from interface:IPNDItemSets the search index.- Specified by:
setSearchIndexin interfaceIPNDItem- Parameters:
searchIndex- the new search index
-
getSearchIndex
public int getSearchIndex()Description copied from interface:IPNDItemGets the search index.- Specified by:
getSearchIndexin interfaceIPNDItem- Returns:
- the search index
-
getId
-
getCurrentLoad
public double getCurrentLoad()Description copied from interface:ILoadCapacityGets the current load.- Specified by:
getCurrentLoadin interfaceILoadCapacity- Returns:
- the current load
-
getMaximalIndividualLoadCapacity
public double getMaximalIndividualLoadCapacity()Description copied from interface:ILoadCapacityGets the maximal individual load capacity.- Specified by:
getMaximalIndividualLoadCapacityin interfaceILoadCapacity- Returns:
- the maximal individual load capacity
-