Class AbstractLoadCapacity

java.lang.Object
com.dna.jopt.member.unit.pnd.capacity.AbstractLoadCapacity
All Implemented Interfaces:
ILoadCapacity, IPNDItem
Direct Known Subclasses:
DegradingLoadCapacity, SimpleLoadCapacity

public abstract class AbstractLoadCapacity extends Object implements ILoadCapacity
  • Field Details

    • PIECE_FIT_TOLERANCE

      public static final double PIECE_FIT_TOLERANCE
      The 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 within PIECE_FIT_TOLERANCE of 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:
      setLoadPickupTime in interface ILoadCapacity
    • getLoadPickupTime

      public Optional<Long> getLoadPickupTime()
      Description copied from interface: ILoadCapacity
      Gets the load pickup time. In case the capacity accepts a load, the pickup time is saved.
      Specified by:
      getLoadPickupTime in interface ILoadCapacity
      Returns:
      the load pickup time
    • setSearchIndex

      public void setSearchIndex(int searchIndex)
      Description copied from interface: IPNDItem
      Sets the search index.
      Specified by:
      setSearchIndex in interface IPNDItem
      Parameters:
      searchIndex - the new search index
    • getSearchIndex

      public int getSearchIndex()
      Description copied from interface: IPNDItem
      Gets the search index.
      Specified by:
      getSearchIndex in interface IPNDItem
      Returns:
      the search index
    • getId

      public String getId()
      Description copied from interface: IPNDItem
      Gets the id of the PNDItem
      Specified by:
      getId in interface IPNDItem
      Returns:
      the id
    • getCurrentLoad

      public double getCurrentLoad()
      Description copied from interface: ILoadCapacity
      Gets the current load.
      Specified by:
      getCurrentLoad in interface ILoadCapacity
      Returns:
      the current load
    • getMaximalIndividualLoadCapacity

      public double getMaximalIndividualLoadCapacity()
      Description copied from interface: ILoadCapacity
      Gets the maximal individual load capacity.
      Specified by:
      getMaximalIndividualLoadCapacity in interface ILoadCapacity
      Returns:
      the maximal individual load capacity