CUTEstProblem.cons

CUTEstProblem.cons(x, index=None, gradient=False)

Evaluate the constraints (and optionally their Jacobian or gradient).

# constraint vector
c      = problem.cons(x)
# i-th constraint
ci     = problem.cons(x, index=i)
# constraints and Jacobian
c, J   = problem.cons(x, gradient=True)
# i-th constraint and its gradient
ci, Ji = problem.cons(x, index=i, gradient=True)

For unconstrained problems, this returns None.

This calls CUTEst routine CUTEST_ccfg or CUTEST_ccifg.

For large problems, problem.scons returns sparse matrices.

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

  • index (int, optional) – which constraint to evaluate (default=None -> all constraints). Must be in 0..self.m-1.

  • gradient (bool, optional) – whether to return constraint(s) and gradient/Jacobian, or just constraint (default=False; i.e. constraint only)

Returns:

value of constraint(s), and Jacobian or gradient of constraint(s) at x

Return type:

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