CUTEstProblem.gradhess

CUTEstProblem.gradhess(x, v=None, gradient_of_lagrangian=True)

Evaluate the gradient of objective or Lagrangian, Jacobian of constraints, and Hessian of objective or Lagrangian. For constrained problems, the gradient is L_{x}(x,v) and the Hessian is L_{x,x}(x,v).

# for unconstrained problems
g, H    = problem.gradhess(x)
# for constrained problems (g = grad Lagrangian)
g, J, H = problem.gradhess(x, v=v)
# for constrained problems (g = grad objective)
g, J, H = problem.gradhess(x, v=v, gradient_of_lagrangian=False)

For constrained problems, v must be specified, and the Hessian of the Lagrangian is always returned. For Hessian of the objective, use problem.ihess().

For large problems, problem.gradsphess returns sparse matrices.

This calls CUTEst routine CUTEST_cgrdh or CUTEST_ugrdh.

Note: in CUTEst, the sign convention is such that the Lagrangian = objective + lagrange_multipliers * constraints

Parameters:
  • x (numpy.ndarray with shape (n,)) – input vector

  • v (numpy.ndarray with shape (m,), optional) – vector of Lagrange multipliers (must be specified for constrained problems)

  • gradient_of_lagrangian (bool, optional) – for constrained problems, return gradient of objective or Lagrangian?

Returns:

gradient of objective or Lagrangian, (Jacobian of constraints), and Hessian of objective or Lagrangian at x

Return type:

(numpy.ndarray(n,), numpy.ndarray(n,n)) or (numpy.ndarray(n,), numpy.ndarray(m,n), numpy.ndarray(n,n))