Class ScalarWeight

  • All Implemented Interfaces:
    java.lang.Comparable<Weight>, Weight

    public class ScalarWeight
    extends java.lang.Object
    implements Weight
    Weight implementation based on a double value.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static ScalarWeight NON_VIABLE_WEIGHT
      Instance of scalar weight to mark links/paths which can not be traversed.
    • Constructor Summary

      Constructors 
      Constructor Description
      ScalarWeight​(double value)
      Creates a new scalar weight with the given double value.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(Weight otherWeight)  
      boolean equals​(java.lang.Object obj)  
      int hashCode()  
      boolean isNegative()
      Returns true if the weight is negative (means that aggregated path cost will decrease if we add weighted subject to it).
      boolean isViable()
      Returns true if the weighted subject (link/path) can be traversed; false otherwise.
      Weight merge​(Weight otherWeight)
      Merges the given weight with this one returning a new aggregated weight.
      static double samenessThreshold()
      Returns the current sameness threshold for comparing cost values.
      static void setSamenessThreshold​(double threshold)
      Sets a new sameness threshold for comparing cost values; default is is Double.MIN_VALUE.
      Weight subtract​(Weight otherWeight)
      Subtracts the given weight from this one and produces a new weight.
      java.lang.String toString()  
      static ScalarWeight toWeight​(double value)
      Creates a new scalar weight with the given double value.
      double value()
      Returns inner double value.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • NON_VIABLE_WEIGHT

        public static final ScalarWeight NON_VIABLE_WEIGHT
        Instance of scalar weight to mark links/paths which can not be traversed.
    • Constructor Detail

      • ScalarWeight

        public ScalarWeight​(double value)
        Creates a new scalar weight with the given double value.
        Parameters:
        value - double value
    • Method Detail

      • toWeight

        public static ScalarWeight toWeight​(double value)
        Creates a new scalar weight with the given double value.
        Parameters:
        value - double value
        Returns:
        scalar weight instance
      • merge

        public Weight merge​(Weight otherWeight)
        Description copied from interface: Weight
        Merges the given weight with this one returning a new aggregated weight.
        Specified by:
        merge in interface Weight
        Parameters:
        otherWeight - weight to add
        Returns:
        aggregated weight
      • subtract

        public Weight subtract​(Weight otherWeight)
        Description copied from interface: Weight
        Subtracts the given weight from this one and produces a new weight.
        Specified by:
        subtract in interface Weight
        Parameters:
        otherWeight - weight to subtract
        Returns:
        residual weight
      • isViable

        public boolean isViable()
        Description copied from interface: Weight
        Returns true if the weighted subject (link/path) can be traversed; false otherwise.
        Specified by:
        isViable in interface Weight
        Returns:
        true if weight is adequate, false if weight is infinite
      • compareTo

        public int compareTo​(Weight otherWeight)
        Specified by:
        compareTo in interface java.lang.Comparable<Weight>
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • isNegative

        public boolean isNegative()
        Description copied from interface: Weight
        Returns true if the weight is negative (means that aggregated path cost will decrease if we add weighted subject to it).
        Specified by:
        isNegative in interface Weight
        Returns:
        true if the weight is negative, false otherwise
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • value

        public double value()
        Returns inner double value.
        Returns:
        double value
      • setSamenessThreshold

        public static void setSamenessThreshold​(double threshold)
        Sets a new sameness threshold for comparing cost values; default is is Double.MIN_VALUE.
        Parameters:
        threshold - fractional double value
      • samenessThreshold

        public static double samenessThreshold()
        Returns the current sameness threshold for comparing cost values.
        Returns:
        current threshold