pal.math
Class BoundsCheckedFunction

java.lang.Object
  extended by pal.math.BoundsCheckedFunction
All Implemented Interfaces:
MultivariateFunction

public class BoundsCheckedFunction
extends java.lang.Object
implements MultivariateFunction

returns a very large number instead of the function value if arguments are out of bound (useful for minimization with minimizers that don't check argument boundaries)

Author:
Korbinian Strimmer

Constructor Summary
BoundsCheckedFunction(MultivariateFunction func)
          construct bound-checked multivariate function (a large number will be returned on function evaluation if argument is out of bounds; default is 1000000)
BoundsCheckedFunction(MultivariateFunction func, double largeNumber)
          construct constrained multivariate function
 
Method Summary
 double evaluate(double[] x)
          computes function value, taking into account the constraints on the argument
 double getLowerBound(int n)
          get lower bound of argument n
 int getNumArguments()
          get number of arguments
 OrthogonalHints getOrthogonalHints()
           
 double getUpperBound(int n)
          get upper bound of argument n
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BoundsCheckedFunction

public BoundsCheckedFunction(MultivariateFunction func)
construct bound-checked multivariate function (a large number will be returned on function evaluation if argument is out of bounds; default is 1000000)

Parameters:
func - unconstrained multivariate function
minArg - lower constraint
maxArg - upper constraint

BoundsCheckedFunction

public BoundsCheckedFunction(MultivariateFunction func,
                             double largeNumber)
construct constrained multivariate function

Parameters:
func - unconstrained multivariate function
largeNumber - value returned on function evaluation if argument is out of bounds
Method Detail

evaluate

public double evaluate(double[] x)
computes function value, taking into account the constraints on the argument

Specified by:
evaluate in interface MultivariateFunction
Parameters:
x - function argument
Returns:
function value (if argument is not in the predefined constrained area a very large number is returned instead of the true function value)

getNumArguments

public int getNumArguments()
Description copied from interface: MultivariateFunction
get number of arguments

Specified by:
getNumArguments in interface MultivariateFunction
Returns:
number of arguments

getLowerBound

public double getLowerBound(int n)
Description copied from interface: MultivariateFunction
get lower bound of argument n

Specified by:
getLowerBound in interface MultivariateFunction
Parameters:
n - argument number
Returns:
lower bound

getUpperBound

public double getUpperBound(int n)
Description copied from interface: MultivariateFunction
get upper bound of argument n

Specified by:
getUpperBound in interface MultivariateFunction
Parameters:
n - argument number
Returns:
upper bound

getOrthogonalHints

public OrthogonalHints getOrthogonalHints()
Specified by:
getOrthogonalHints in interface MultivariateFunction
Returns:
null