CUTEstProblem.sobj
- CUTEstProblem.sobj(x, gradient=False)
Evaluate the objective (and optionally its sparse gradient).
# objective f = problem.obj(x) # objective and gradient f, g = problem.obj(x, gradient=True)
The vector g is of type scipy.sparse.coo_matrix. For unconstrained problems, g is formed from a dense matrix due to CUTEst limitations.
For small problems, problem.obj returns dense matrices.
This calls CUTEst routine CUTEst_uofg or CUTEST_cofsg.
- Parameters:
x (numpy.ndarray with shape (n,)) – input vector
gradient (bool, optional) – whether to return objective and gradient, or just objective (default=False; i.e. objective only)
- Returns:
objective value f, or tuple (f,g) of objective and sparse gradient at x
- Return type:
float or (float, scipy.sparse.coo_matrix(n,))