Class LinearVectorFunction

java.lang.Object
de.labathome.trustconstr.LinearVectorFunction
All Implemented Interfaces:
VectorFunctionLike
Direct Known Subclasses:
IdentityVectorFunction

public class LinearVectorFunction extends Object implements VectorFunctionLike
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 Details

    • A

      protected final Matrix A
      Constraint matrix; mirrors scipy's self.J.
    • m

      protected final long m
      Output dimension (A.rows).
    • n

      protected final long n
      Input dimension (A.cols).
    • sparseJacobian

      protected final boolean sparseJacobian
      true if A is stored as a SparseMatrix.
    • H

      protected final Matrix H
      Constant zero Hessian (n x n); shared across calls.
    • x

      protected Matrix x
      Most recently evaluated point.
    • f

      protected Matrix f
      Cached A x at x; null until first call.
    • fUpdated

      protected boolean fUpdated
      true when f matches the current x.
    • v

      protected Matrix v
      Most recently set Lagrange multipliers (from hess(Matrix, Matrix)). Stored only to mirror scipy's API; not used for any computation.
  • Constructor Details

    • LinearVectorFunction

      public LinearVectorFunction(Matrix A, Matrix x0, Optional<Boolean> sparseJacobian)
      Build a linear vector function f(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 whatever A already is
  • Method Details

    • fun

      public Matrix fun(Matrix newX)
      Description copied from interface: VectorFunctionLike
      Evaluate the function at x, updating any internal cache.
      Specified by:
      fun in interface VectorFunctionLike
      Parameters:
      newX - current iterate (n x 1)
      Returns:
      function value (m x 1)
    • jac

      public Matrix jac(Matrix newX)
      Description copied from interface: VectorFunctionLike
      Evaluate the Jacobian at x, updating any internal cache.
      Specified by:
      jac in interface VectorFunctionLike
      Parameters:
      newX - current iterate (n x 1)
      Returns:
      Jacobian (m x n)
    • hess

      public Matrix hess(Matrix newX, Matrix newV)
      Description copied from interface: VectorFunctionLike
      Evaluate the constraint Hessian-of-Lagrangian Sum_i v[i] * H_{f_i}(x) at x for the given multiplier vector v.
      Specified by:
      hess in interface VectorFunctionLike
      Parameters:
      newX - current iterate (n x 1)
      newV - multipliers (m x 1)
      Returns:
      summed Hessian (n x n)
    • f

      public Matrix f()
      Specified by:
      f in interface VectorFunctionLike
      Returns:
      most recently computed f(x) (m x 1), or null if uncached
    • J

      public Matrix J()
      Specified by:
      J in interface VectorFunctionLike
      Returns:
      most recently computed Jacobian (m x n), or null if uncached
    • m

      public long m()
      Specified by:
      m in interface VectorFunctionLike
      Returns:
      number of output components (m in f : R^n -> R^m)
    • n

      public long n()
      Specified by:
      n in interface VectorFunctionLike
      Returns:
      number of input components (n in f : R^n -> R^m)
    • sparseJacobian

      public boolean sparseJacobian()
      Returns:
      true if the Jacobian is stored as a SparseMatrix
    • v

      public Matrix v()
      Specified by:
      v in interface VectorFunctionLike
      Returns:
      most recently set Lagrange multipliers (from VectorFunctionLike.hess(Matrix, Matrix)); shape m x 1, or null if none ever set