Package de.labathome.trustconstr
Class ScalarFunction
java.lang.Object
de.labathome.trustconstr.ScalarFunction
Scalar function and its derivatives.
This class defines a scalar function F: R^n->R and methods for computing or approximating its first and second derivatives.
This class implements a memoization logic. There are methods `fun`, `grad`, hess` and corresponding attributes `f`, `g` and `H`. The following things should be considered: 1. Use only public methods `fun`, `grad` and `hess`. 2. After one of the methods is called, the corresponding attribute will be set. However, a subsequent call with a different argument of *any* of the methods may overwrite the attribute.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ScalarFunction.ScalarFunctionFactoryDefaultScalarFunction.ScalarFunctionFactory; create one and callScalarFunction.ScalarFunctionFactory.build(). -
Method Summary
-
Field Details
-
FACTORY
DefaultScalarFunction.ScalarFunctionFactory; create one and callScalarFunction.ScalarFunctionFactory.build().
-
-
Method Details
-
fun
- Parameters:
x- current iterate (n x 1)- Returns:
- cached objective value
f(x)
-
grad
- Parameters:
x- current iterate (n x 1)- Returns:
- cached gradient
gradf(x)(n x 1)
-
hess
- Parameters:
x- current iterate (n x 1)- Returns:
- cached Hessian
grad^2f(x)(n x n)
-
numFunctionEvals
public int numFunctionEvals()- Returns:
- total number of
funevaluations performed so far
-
numGradientEvals
public int numGradientEvals()- Returns:
- total number of gradient evaluations performed so far
-
numHessianEvals
public int numHessianEvals()- Returns:
- total number of Hessian evaluations performed so far
-
f
public double f()- Returns:
- the most recently cached
f(x)
-
g
DANGER ZONE: returns the live internal gradient buffer; callers must not mutate it.- Returns:
- the most recently cached gradient (
n x 1)
-
H
DANGER ZONE: returns the live internal Hessian buffer; callers must not mutate it.- Returns:
- the most recently cached Hessian (
n x n)
-
lowestF
public double lowestF()- Returns:
- the lowest objective value seen across all evaluations
-
lowestX
- Returns:
- a defensive copy of the iterate that produced
lowestF()
-