CUTEstProblem.scons

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

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

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

The matrix J or vector Ji is of type scipy.sparse.coo_matrix.

For unconstrained problems, this returns None.

For small problems, problem.cons returns dense matrices.

This calls CUTEst routine CUTEST_ccfsg or CUTEST_ccifsg.

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 sparse Jacobian or gradient of constraint(s) at x

Return type:

numpy.ndarray(m,) or float or (numpy.ndarray(m,), scipy.sparse.coo_matrix(m,n)) or (float, scipy.sparse.coo_matrix(n,))