desc.objectives.ObjectiveFunction

class desc.objectives.ObjectiveFunction(objectives, use_jit=True, deriv_mode='batched', verbose=1)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 ({"batched", "blocked"}) – method for computing derivatives. “batched” is generally faster, “blocked” may use less memory. Note that the “blocked” Hessian will only be block diagonal.

  • verbose (int, optional) – Level of output.

Methods

build([eq, 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.

eq(other)

Compare equivalence between DESC objects.

grad(x[, constants])

Compute gradient vector of scalar form of the objective wrt x.

hess(x[, constants])

Compute Hessian matrix of scalar form of the objective wrt x.

jac_scaled(x[, constants])

Compute Jacobian matrix of vector form of the objective wrt x.

jac_unscaled(x[, constants])

Compute Jacobian matrix of vector form of the objective wrt x, unweighted.

jit()

Apply JIT to compute methods, or re-apply after updating self.

jvp_scaled(v, x)

Compute Jacobian-vector product of the objective function.

jvp_unscaled(v, x)

Compute Jacobian-vector product of the objective function.

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.

set_args(*args)

Set which arguments the objective should expect.

unpack_state(x)

Unpack the state vector into its components.

vjp_scaled(v, x)

Compute vector-Jacobian product of the objective function.

vjp_unscaled(v, x)

Compute vector-Jacobian product of the objective function.

x(eq)

Return the full state vector from the Equilibrium eq.

Attributes

args

Names (str) of arguments to the compute functions.

bounds_scaled

lower and upper bounds for residual vector.

built

Whether the objectives have been built or not.

compiled

Whether the functions have been compiled or not.

constants

constant parameters for each sub-objective.

dim_f

Number of objective equations.

dim_x

Dimensional of the state vector.

dimensions

Dimensions of the argument given by the dict keys.

objectives

List of objectives.

scalar

Whether default "compute" method is a scalar or vector.

target_scaled

target vector.

use_jit

Whether to just-in-time compile the objective and derivatives.

weights

weight vector.

x_idx

Indices of the components of the state vector.