Package de.labathome.trustconstr
Class LinearVectorFunction
java.lang.Object
de.labathome.trustconstr.LinearVectorFunction
- All Implemented Interfaces:
VectorFunctionLike
- Direct Known Subclasses:
IdentityVectorFunction
Linear vector function
f(x) = A x and its derivatives.
Counterpart to scipy's LinearVectorFunction
(scipy/optimize/_differentiable_functions.py:769). The Jacobian is
the constant matrix A; the Hessian-of-Lagrangian is identically
zero (returned as an n x n sparse zero matrix).
Caches the most recently evaluated point and f so repeated
fun(Matrix) calls at the same x cost a single matvec.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final MatrixConstraint matrix; mirrors scipy'sself.J.protected Matrixprotected booleanprotected final MatrixConstant zero Hessian (n x n); shared across calls.protected final longOutput dimension (A.rows).protected final longInput dimension (A.cols).protected final booleanprotected MatrixMost recently set Lagrange multipliers (fromhess(Matrix, Matrix)).protected MatrixMost recently evaluated point. -
Constructor Summary
ConstructorsConstructorDescriptionLinearVectorFunction(Matrix A, Matrix x0, Optional<Boolean> sparseJacobian) Build a linear vector functionf(x) = A x. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.labathome.trustconstr.interfaces.VectorFunctionLike
numFunctionEvals, numHessianEvals, numJacobianEvals
-
Field Details
-
A
Constraint matrix; mirrors scipy'sself.J. -
m
protected final long mOutput dimension (A.rows). -
n
protected final long nInput dimension (A.cols). -
sparseJacobian
protected final boolean sparseJacobian -
H
Constant zero Hessian (n x n); shared across calls. -
x
Most recently evaluated point. -
f
-
fUpdated
protected boolean fUpdated -
v
Most recently set Lagrange multipliers (fromhess(Matrix, Matrix)). Stored only to mirror scipy's API; not used for any computation.
-
-
Constructor Details
-
LinearVectorFunction
Build a linear vector functionf(x) = A x.- Parameters:
A- constraint matrix (m x n)x0- starting iterate (n x 1)sparseJacobian-Optional.of(true)forces sparse storage,Optional.of(false)forces dense,Optional.empty()preserves whateverAalready is
-
-
Method Details
-
fun
Description copied from interface:VectorFunctionLikeEvaluate the function atx, updating any internal cache.- Specified by:
funin interfaceVectorFunctionLike- Parameters:
newX- current iterate (n x 1)- Returns:
- function value (
m x 1)
-
jac
Description copied from interface:VectorFunctionLikeEvaluate the Jacobian atx, updating any internal cache.- Specified by:
jacin interfaceVectorFunctionLike- Parameters:
newX- current iterate (n x 1)- Returns:
- Jacobian (
m x n)
-
hess
Description copied from interface:VectorFunctionLikeEvaluate the constraint Hessian-of-LagrangianSum_i v[i] * H_{f_i}(x)atxfor the given multiplier vectorv.- Specified by:
hessin interfaceVectorFunctionLike- Parameters:
newX- current iterate (n x 1)newV- multipliers (m x 1)- Returns:
- summed Hessian (
n x n)
-
f
- Specified by:
fin interfaceVectorFunctionLike- Returns:
- most recently computed
f(x)(m x 1), ornullif uncached
-
J
- Specified by:
Jin interfaceVectorFunctionLike- Returns:
- most recently computed Jacobian (
m x n), ornullif uncached
-
m
public long m()- Specified by:
min interfaceVectorFunctionLike- Returns:
- number of output components (
minf : R^n -> R^m)
-
n
public long n()- Specified by:
nin interfaceVectorFunctionLike- Returns:
- number of input components (
ninf : R^n -> R^m)
-
sparseJacobian
public boolean sparseJacobian()- Returns:
trueif the Jacobian is stored as aSparseMatrix
-
v
- Specified by:
vin interfaceVectorFunctionLike- Returns:
- most recently set Lagrange multipliers (from
VectorFunctionLike.hess(Matrix, Matrix)); shapem x 1, ornullif none ever set
-