CUTEstProblem.grad

CUTEstProblem.grad(x, index=None)

Evaluate the gradient of the objective function or gradient of the i-th constraint.

# gradient of objective
g = problem.grad(x)
# gradient of i-th constraint
g = problem.grad(x, index=i)

This calls CUTEst routine CUTEST_ugr or CUTEST_cigr.

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

  • index (int, optional) – which constraint to evaluate. Must be in 0..self.m-1.

Returns:

gradient of objective or gradient of i-th constraint at x

Return type:

numpy.ndarray(n,)