Class ConstantSwitch

java.lang.Object
ffx.numerics.switching.ConstantSwitch
All Implemented Interfaces:
UnivariateDiffFunction, UnivariateSwitchingFunction

public class ConstantSwitch extends Object implements UnivariateSwitchingFunction
The ConstantSwitch returns a constant value for all input values x. This is useful for having a single code path that accommodates both "real" switching behavior and no switching behavior. The default value is 1.0.
Author:
Jacob M. Litman, Michael J. Schnieders
  • Constructor Details

    • ConstantSwitch

      public ConstantSwitch()
      Default constructor: constant 1.0 value.
    • ConstantSwitch

      public ConstantSwitch(double value)
      Permits specification of a value.
      Parameters:
      value - Value this ConstantSwitch should maintain.
  • Method Details

    • constantOutsideBounds

      public boolean constantOutsideBounds()
      Remains 0 below the lower bound, and 1 above the upper bound (i.e. a multiplicative switch).
      Specified by:
      constantOutsideBounds in interface UnivariateSwitchingFunction
      Returns:
      df(x)/dx is zero outside range lb-ub.
    • firstDerivative

      public double firstDerivative(double x)
      First derivative at a point.
      Specified by:
      firstDerivative in interface UnivariateDiffFunction
      Parameters:
      x - a double.
      Returns:
      f'(x)
    • getHighestOrderZeroDerivative

      public int getHighestOrderZeroDerivative()
      The highest-order derivative that is zero at the bounds.
      Specified by:
      getHighestOrderZeroDerivative in interface UnivariateSwitchingFunction
      Returns:
      Maximum order zero derivative at bounds.
    • getOneBound

      public double getOneBound()
      Gets the one bound, where f(x) becomes one.
      Specified by:
      getOneBound in interface UnivariateSwitchingFunction
      Returns:
      One bound
    • getZeroBound

      public double getZeroBound()
      Gets the zero bound, where f(x) becomes zero.
      Specified by:
      getZeroBound in interface UnivariateSwitchingFunction
      Returns:
      Zero bound
    • nthDerivative

      public double nthDerivative(double x, int order) throws IllegalArgumentException
      N'th order derivative at a point. Should be relatively optional for any order above 2.
      Specified by:
      nthDerivative in interface UnivariateDiffFunction
      Parameters:
      x - a double.
      order - Derivative order (>= 1)
      Returns:
      d^nf(x)/dx^n
      Throws:
      IllegalArgumentException - If derivative undefined at x.
    • secondDerivative

      public double secondDerivative(double x)
      Second derivative at a point.
      Specified by:
      secondDerivative in interface UnivariateDiffFunction
      Parameters:
      x - a double.
      Returns:
      f''(x)
    • symmetricToUnity

      public boolean symmetricToUnity()
      True if f(lb + delta) + f(ub - delta) = 1 for all delta between 0 and (ub - lb). For example, a power switch with beta 1 is symmetric to unity, as f(l) + f(1-l) = 1, but beta 2 produces a non-unity result, where f(0.5) + f(0.5) = 0.5.
      Specified by:
      symmetricToUnity in interface UnivariateSwitchingFunction
      Returns:
      If symmetry produces unity result.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • validOutsideBounds

      public boolean validOutsideBounds()
      Remains in the range 0-1 outside the bounds. Implied to be true if constantOutsideBounds is true.
      Specified by:
      validOutsideBounds in interface UnivariateSwitchingFunction
      Returns:
      min(f ( x)) = 0 and max(f(x)) = 1.
    • valueAt

      public double valueAt(double x) throws IllegalArgumentException
      Value at a point
      Specified by:
      valueAt in interface UnivariateDiffFunction
      Parameters:
      x - a double.
      Returns:
      f(x)
      Throws:
      IllegalArgumentException - If f(x) is undefined at x.