Class QuadraticFunction

java.lang.Object
org.hipparchus.optim.nonlinear.vector.constrained.TwiceDifferentiableFunction
org.hipparchus.optim.nonlinear.vector.constrained.QuadraticFunction
All Implemented Interfaces:
MultivariateFunction

public class QuadraticFunction extends TwiceDifferentiableFunction
Given P, Q, d, implements \(\frac{1}{2}x^T P X + Q^T x + d\). The gradient is P x + Q^T, and the Hessian is P
Since:
3.1
  • Constructor Details

    • QuadraticFunction

      public QuadraticFunction(RealMatrix p, RealVector q, double d)
      Construct quadratic function \(\frac{1}{2}x^T P X + Q^T x + d\).
      Parameters:
      p - square matrix of weights for quadratic terms. Typically expected to be positive definite or positive semi-definite.
      q - vector of weights for linear terms.
      d - constant term
    • QuadraticFunction

      public QuadraticFunction(double[][] h, double[] c, double d)
      Construct quadratic function \(\frac{1}{2}x^T P X + Q^T x + d\).
      Parameters:
      h - square matrix of weights for quadratic terms. Typically expected to be positive definite or positive semi-definite.
      c - vector of weights for linear terms.
      d - constant term
  • Method Details

    • getP

      public RealMatrix getP()
      Get square matrix of weights for quadratic terms.
      Returns:
      square matrix of weights for quadratic terms
    • getQ

      public RealVector getQ()
      Get vector of weights for linear terms.
      Returns:
      vector of weights for linear terms
    • getD

      public double getD()
      Get constant term.
      Returns:
      constant term
    • dim

      public int dim()
      Returns the dimensionality of the function domain. If dim() returns (n) then this function expects an n-vector as its input.
      Specified by:
      dim in class TwiceDifferentiableFunction
      Returns:
      the expected dimension of the function's domain
    • value

      public double value(RealVector x)
      Returns the value of this function at (x)
      Specified by:
      value in class TwiceDifferentiableFunction
      Parameters:
      x - a point to evaluate this function at.
      Returns:
      the value of this function at (x)
    • gradient

      public RealVector gradient(RealVector x)
      Returns the gradient of this function at (x)
      Specified by:
      gradient in class TwiceDifferentiableFunction
      Parameters:
      x - a point to evaluate this gradient at
      Returns:
      the gradient of this function at (x)
    • hessian

      public RealMatrix hessian(RealVector x)
      The Hessian of this function at (x)
      Specified by:
      hessian in class TwiceDifferentiableFunction
      Parameters:
      x - a point to evaluate this Hessian at
      Returns:
      the Hessian of this function at (x)