Package ffx.numerics.switching
Class CompositeSwitch
java.lang.Object
ffx.numerics.switching.CompositeSwitch
- All Implemented Interfaces:
UnivariateDiffFunction
,UnivariateSwitchingFunction
The CompositeSwitch uses a primary switch in the middle, and then two secondary switches at the
ends of the path to smoothly switch to the primary switch. For example, one can smoothly
interpolate from 0/0/0 value/derivative/second derivative to a linear switch by multiplying the
linear switch by a MultiplicativeSwitch in the range 0-0.1.
At present, there is an assumption that x gets linearly scaled when passed to the switch; at the ends, s(x) = f(g(x))*h(x), where h(x) is the primary switch, g(x) = x / (switching range), and f(g(x)) is the secondary switch.
- Author:
- Jacob M. Litman, Michael J. Schnieders
-
Constructor Summary
ConstructorDescriptionBuilds a switch that uses MultiplicativeSwitches at the ends (0-0.1, 0.9-1.0) to smoothly interpolate a linear switch between 0 and 1 with smooth 2'nd and 3'rd derivatives.Builds a switch that uses MultiplicativeSwitches at the ends (0-0.1, 0.9-1.0) to smoothly interpolate a provided switch between 0 and 1 with smooth 2'nd and 3'rd derivatives.CompositeSwitch
(UnivariateSwitchingFunction primary, UnivariateSwitchingFunction start, UnivariateSwitchingFunction end, double lbPrimary, double ubPrimary) Builds a composite switch in .CompositeSwitch
(UnivariateSwitchingFunction primary, UnivariateSwitchingFunction start, UnivariateSwitchingFunction end, double lbPrimary, double ubPrimary, double lb, double ub) Builds a composite switch in . -
Method Summary
Modifier and TypeMethodDescriptionboolean
Remains 0 below the lower bound, and 1 above the upper bound (i.e. a multiplicative switch).double
firstDerivative
(double x) First derivative at a point.int
The highest-order derivative that is zero at the bounds.double
Gets the one bound, where f(x) becomes one.double
Gets the zero bound, where f(x) becomes zero.double
nthDerivative
(double x, int order) N'th order derivative at a point.double
secondDerivative
(double x) Second derivative at a point.boolean
True if f(lb + delta) + f(ub - delta) = 1 for all delta between 0 and (ub - lb).toString()
boolean
Remains in the range 0-1 outside the bounds.double
valueAt
(double x) Value at a pointMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface ffx.numerics.switching.UnivariateSwitchingFunction
highestOrderZeroDerivativeAtZeroBound
-
Constructor Details
-
CompositeSwitch
public CompositeSwitch()Builds a switch that uses MultiplicativeSwitches at the ends (0-0.1, 0.9-1.0) to smoothly interpolate a linear switch between 0 and 1 with smooth 2'nd and 3'rd derivatives. Will not be quite linear from 0-0.1 and 0.9-1.0. -
CompositeSwitch
Builds a switch that uses MultiplicativeSwitches at the ends (0-0.1, 0.9-1.0) to smoothly interpolate a provided switch between 0 and 1 with smooth 2'nd and 3'rd derivatives.- Parameters:
primary
- Primary switch to obey exactly from 0.1-0.9.
-
CompositeSwitch
public CompositeSwitch(UnivariateSwitchingFunction primary, UnivariateSwitchingFunction start, UnivariateSwitchingFunction end, double lbPrimary, double ubPrimary) Builds a composite switch in .- Parameters:
primary
- Primary switch to obey exactly from lbPrimary to ubPrimary.start
- Switch to interpolate from 0 to primary between 0 and lbPrimary; assumed to internally function from 0-1.end
- Switch to interpolate from primary to 1.0 between ubPrimary and 1; assumed to internally function from 0-1.lbPrimary
- Value at which primary should begin to be obeyed exactly.ubPrimary
- Value at which primary should stop being obeyed exactly.
-
CompositeSwitch
public CompositeSwitch(UnivariateSwitchingFunction primary, UnivariateSwitchingFunction start, UnivariateSwitchingFunction end, double lbPrimary, double ubPrimary, double lb, double ub) Builds a composite switch in .- Parameters:
primary
- Primary switch to obey exactly from lbPrimary to ubPrimary.start
- Switch to interpolate from 0 to primary between 0 and lbPrimary; assumed to internally function from 0-1.end
- Switch to interpolate from primary to 1.0 between ubPrimary and 1; assumed to internally function from 0-1.lbPrimary
- Value at which primary should begin to be obeyed exactly.ubPrimary
- Value at which primary should stop being obeyed exactly.lb
- Overall lower bound of the CompositeSwitch.ub
- Overall upper bound of the CompositeSwitch.
-
-
Method Details
-
constantOutsideBounds
public boolean constantOutsideBounds()Description copied from interface:UnivariateSwitchingFunction
Remains 0 below the lower bound, and 1 above the upper bound (i.e. a multiplicative switch).- Specified by:
constantOutsideBounds
in interfaceUnivariateSwitchingFunction
- Returns:
- df(x)/dx is zero outside range lb-ub.
-
firstDerivative
Description copied from interface:UnivariateDiffFunction
First derivative at a point.- Specified by:
firstDerivative
in interfaceUnivariateDiffFunction
- Parameters:
x
- a double.- Returns:
- f'(x)
- Throws:
IllegalArgumentException
- If f'(x) is undefined at x.
-
getHighestOrderZeroDerivative
public int getHighestOrderZeroDerivative()Description copied from interface:UnivariateSwitchingFunction
The highest-order derivative that is zero at the bounds.- Specified by:
getHighestOrderZeroDerivative
in interfaceUnivariateSwitchingFunction
- Returns:
- Maximum order zero derivative at bounds.
-
getOneBound
public double getOneBound()Description copied from interface:UnivariateSwitchingFunction
Gets the one bound, where f(x) becomes one.- Specified by:
getOneBound
in interfaceUnivariateSwitchingFunction
- Returns:
- One bound
-
getZeroBound
public double getZeroBound()Description copied from interface:UnivariateSwitchingFunction
Gets the zero bound, where f(x) becomes zero.- Specified by:
getZeroBound
in interfaceUnivariateSwitchingFunction
- Returns:
- Zero bound
-
nthDerivative
Description copied from interface:UnivariateDiffFunction
N'th order derivative at a point. Should be relatively optional for any order above 2.- Specified by:
nthDerivative
in interfaceUnivariateDiffFunction
- Parameters:
x
- a double.order
- Derivative order (>= 1)- Returns:
- d^nf(x)/dx^n
- Throws:
IllegalArgumentException
- If derivative undefined at x.
-
secondDerivative
Description copied from interface:UnivariateDiffFunction
Second derivative at a point.- Specified by:
secondDerivative
in interfaceUnivariateDiffFunction
- Parameters:
x
- a double.- Returns:
- f''(x)
- Throws:
IllegalArgumentException
- If f''(x) is undefined at x.
-
symmetricToUnity
public boolean symmetricToUnity()Description copied from interface:UnivariateSwitchingFunction
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 interfaceUnivariateSwitchingFunction
- Returns:
- If symmetry produces unity result.
-
toString
-
validOutsideBounds
public boolean validOutsideBounds()Description copied from interface:UnivariateSwitchingFunction
Remains in the range 0-1 outside the bounds. Implied to be true if constantOutsideBounds is true.- Specified by:
validOutsideBounds
in interfaceUnivariateSwitchingFunction
- Returns:
- min(f ( x)) = 0 and max(f(x)) = 1.
-
valueAt
Description copied from interface:UnivariateDiffFunction
Value at a point- Specified by:
valueAt
in interfaceUnivariateDiffFunction
- Parameters:
x
- a double.- Returns:
- f(x)
- Throws:
IllegalArgumentException
- If f(x) is undefined at x.
-