desc.objectives.ObjectiveFunction
- class desc.objectives.ObjectiveFunction(objectives, use_jit=True, deriv_mode='auto', name='ObjectiveFunction')Source
Objective function comprised of one or more Objectives.
- Parameters:
objectives (tuple of Objective) – List of objectives to be minimized.
use_jit (bool, optional) – Whether to just-in-time compile the objectives and derivatives.
deriv_mode ({"auto", "batched", "blocked", "looped"}) – Method for computing Jacobian matrices. “batched” uses forward mode, applied to the entire objective at once, and is generally the fastest for vector valued objectives, though most memory intensive. “blocked” builds the Jacobian for each objective separately, using each objective’s preferred AD mode. Generally the most efficient option when mixing scalar and vector valued objectives. “looped” uses forward mode jacobian vector products in a loop to build the Jacobian column by column. Generally the slowest, but most memory efficient. “auto” defaults to “batched” if all sub-objectives are set to “fwd”, otherwise “blocked”.
name (str) – Name of the objective function.
Methods
build
([use_jit, verbose])Build the objective.
compile
([mode, verbose])Call the necessary functions to ensure the function is compiled.
compute_scalar
(x[, constants])Compute the sum of squares error.
compute_scaled
(x[, constants])Compute the objective function and apply weighting and normalization.
compute_scaled_error
(x[, constants])Compute and apply the target/bounds, weighting, and normalization.
compute_unscaled
(x[, constants])Compute the raw value of the objective function.
copy
([deepcopy])Return a (deep)copy of this object.
equiv
(other)Compare equivalence between DESC objects.
grad
(x[, constants])Compute gradient vector of self.compute_scalar wrt x.
hess
(x[, constants])Compute Hessian matrix of self.compute_scalar wrt x.
jac_scaled
(x[, constants])Compute Jacobian matrix of self.compute_scaled wrt x.
jac_scaled_error
(x[, constants])Compute Jacobian matrix of self.compute_scaled_error wrt x.
jac_unscaled
(x[, constants])Compute Jacobian matrix of self.compute_unscaled wrt x.
jit
()Apply JIT to compute methods, or re-apply after updating self.
jvp_scaled
(v, x[, constants])Compute Jacobian-vector product of self.compute_scaled.
jvp_scaled_error
(v, x[, constants])Compute Jacobian-vector product of self.compute_scaled_error.
jvp_unscaled
(v, x[, constants])Compute Jacobian-vector product of self.compute_unscaled.
load
(load_from[, file_format])Initialize from file.
print_value
(x[, constants])Print the value(s) of the objective.
save
(file_name[, file_format, file_mode])Save the object.
unpack_state
(x[, per_objective])Unpack the state vector into its components.
vjp_scaled
(v, x[, constants])Compute vector-Jacobian product of self.compute_scaled.
vjp_scaled_error
(v, x[, constants])Compute vector-Jacobian product of self.compute_scaled_error.
vjp_unscaled
(v, x[, constants])Compute vector-Jacobian product of self.compute_unscaled.
x
(*things)Return the full state vector from the Optimizable objects things.
Attributes
lower and upper bounds for residual vector.
Whether the objectives have been built or not.
Whether the functions have been compiled or not.
constant parameters for each sub-objective.
Number of objective equations.
Dimensional of the state vector.
Name of objective function (str).
List of objectives.
Whether default "compute" method is a scalar or vector.
target vector.
Unique list of optimizable things that this objective is tied to.
Whether to just-in-time compile the objective and derivatives.
weight vector.