foxes_opt.core.FarmOptProblem.get_gradients(vars_int, vars_float, func=None, components=None, vars=None, pop=False, verbosity=0)

Obtain gradients of a function that is linked to the problem.

The func object typically is a iwopy.core.OptFunctionList object that contains a selection of objectives and/or constraints that were previously added to this problem. By default all objectives and constraints (and all their components) are being considered, cf. class ProblemDefaultFunc.

Parameters

vars_int: np.array

The integer variable values, shape: (n_vars_int,)

vars_float: np.array

The float variable values, shape: (n_vars_float,)

func: iwopy.core.OptFunctionList, optional

The functions to be differentiated, or None for a list of all objectives and all constraints (in that order)

components: list of int, optional

The function’s component selection, or None for all

vars: list of int or str, optional

The float variables wrt which the derivatives are to be calculated, or None for all

verbosity: int

The verbosity level, 0 = silent

pop: bool

Flag for vectorizing calculations via population

Returns

gradients: numpy.ndarray

The gradients of the functions, shape: (n_components, n_vars)