Skip to content

← Back to tools

FiniteDifferencesJacobian

Source: Distributed_Design_Optimizer/subsystem/tools/FiniteDifferencesJacobian.py

Finite differences Jacobian computation module.

This module provides utilities for computing Jacobians using finite difference approximations.

Classes

FiniteDifferencesJacobian

Compute finite differences Jacobian approximations.

Methods

init(self) → None

Instantiates placeholders for Jacobians / gradient of local constraints and local objective.

get_Gradient_LocalObjective(self) → List[float | None] | None

Returns the gradient approximation of the local objective.

Returns:

List[float]: description

set_Gradient_LocalObjective(self, gradient_localobjective_in: List[float | None])

Sets the gradient approximation of the local objective.

Args:

gradient_localobjective_in (List[float]): description

get_Gradient_CoordinationObjective(self) → List[float | None] | None

Returns the gradient approximation of the local objective.

Returns:

List[float | None] | None: description

set_Gradient_CoordinationObjective(self, gradient_coordinationobjective_in: List[float | None])

Sets the gradient approximation of the coordination objective.

Args:

gradient_coordinationobjective_in (List[float | None]): description

get_Jacobian_LocalEqualityConstraints(self) → List[List[float | None]] | None

Returns the Jacobian approximation of the local equality constraints.

Returns:

List[List[float]]: description

set_Jacobian_LocalEqualityConstraints(self, jacobian_localequalityconstraints_in: List[List[float | None]]) → None

Sets the Jacobian approximation of the local equality constraints.

Args:

jacobian_localequalityconstraints_in (List[List[float]]): description

get_Jacobian_CoordinationEqualityConstraints(self) → List[List[float | None]] | None

Returns the Jacobian approximation of the coordination equality constraints.

Returns:

List[List[float | None]] | None: description

set_Jacobian_CoordinationEqualityConstraints(self, jacobian_coordinationequalityconstraints_in: List[List[float | None]]) → None

Sets the Jacobian approximation of the coordination equality constraints.

Args:

jacobian_coordinationequalityconstraints_in (List[List[float | None]]): description

get_Jacobian_LocalInEqualityConstraints(self) → List[List[float | None]] | None

Returns the Jacobian approximation of the local inequality constraints.

Returns:

List[List[float]]: description

set_Jacobian_LocalInEqualityConstraints(self, jacobian_localinequalityconstraints_in: List[List[float | None]]) → None

Sets the Jacobian approximation of the local inequality constraints.

Args:

jacobian_localinequalityconstraints_in (List[List[float]]): description

get_Jacobian_CoordinationInEqualityConstraints(self) → List[List[float | None]] | None

Returns the Jacobian approximation of the coordination inequality constraints.

Returns:

List[List[float | None]] | None: description

set_Jacobian_CoordinationInEqualityConstraints(self, jacobian_coordinationinequalityconstraints_in: List[List[float | None]]) → None

Sets the Jacobian approximation of the coordination inequality constraints.

Args:

jacobian_coordinationinequalityconstraints_in (List[List[float | None]]): description

get_Jacobians_MappedResponses(self) → Dict[str, List[List[float | None]]] | None

Get the Jacobian approximation of the mapped responses.

Returns:

Dict[str, List[List[float | None]]]: description

set_Jacobians_MappedResponses(self, jacobians_mappedresponses_in: Dict[str, List[List[float | None]]]) → None

Sets the Jacobian approximation of the mapped responses.

Args:

jacobians_mappedresponses_in (Dict[str, List[List[float | None]]]): description

run(self, subsystem: SubSystemBasis, perturbation_directions_indices_list: List[int]) → None

Computes the finite difference jacobian approximations and stores them.

This is needed of all the following quantities: - Gradient of local objective - Jacobian of local equality constraints - Jacobian of local inequality constraints - Jacobian of mapped responses

Args:

subsystem (SubSystemBasis): The subsystem to compute Jacobians for.
perturbation_directions_indices_list (List[int]): Indices of design
variable directions in which to compute finite differences.

differencequotient(self, function_left: float, function_right: float, stepsize: float)

Compute the difference quotient of two function values.

If stepsize > 0: - Takes the difference quotient 'function_left - function_right / stepsize' If stepsize = 0: - Returns 0 Otherwise: - Raises error, since stepsize must be >= 0.

Args:

function_left (float): description
function_right (float): description
stepsize (float): description

updateSubsystem(self, subsystem: SubSystemBasis, perturbed_designvariables: List[float])

Updates the subsystem based on the inputted design variables.

Args:

subsystem (SubSystemBasis): description
perturbed_designvariables (List[float]): description

update_state(self, other_finite_differences_jacobian: FiniteDifferencesJacobian) → None

Update the state of this FiniteDifferencesJacobian with values from another instance.

This method is necessary for multiprocessing. When subsystems are executed in parallel using multiprocessing.Pool, they are serialized and deserialized, creating new objects in separate memory spaces. After parallel execution completes, this method updates the original object's attribute values while preserving their memory addresses.

The update preserves memory addresses by modifying list contents in-place rather than reassigning references. This is essential for maintaining object identity across the multiprocessing boundary.

Args:

other_finite_differences_jacobian: The source FiniteDifferencesJacobian containing
updated values from parallel execution.