pysolvegn.build_fixed_parametrization#

build_fixed_parametrization(n_p_outputs, optimized_indices, fixed_parameters=None, *, sparse=False)[source]#

Build a parametrization that fixes some output parameters while optimizing only a selected subset of them.

The transformation is defined as:

\[\mathbf{p}_{out} = P(\mathbf{p}_{in})\]

where the values at optimized_indices are taken from \(\mathbf{p}_{in}\) and all other values are fixed.

The Jacobian is the constant selection matrix \(S\) of shape (n_p_outputs, len(optimized_indices)), with \(S_{i, j} = 1\) if optimized_indices[j] == i.

Warning

The dense selection matrix has n_p_outputs * len(optimized_indices) entries. For large problems (e.g. displacements of the vertices of a mesh), use sparse=True: the matrix has then one entry per optimized parameter.

Parameters:
  • n_p_outputs (int) – Number of output parameters.

  • optimized_indices (Sequence[int]) – Indices of the output parameters that are optimized. The order defines the order of the input parameters.

  • fixed_parameters (Optional[ArrayLike], optional) – Initial/fixed values of all output parameters, with shape (n_p_outputs,). If None, all fixed parameters are initialized to zero.

  • sparse (bool, optional (default: False)) – If True, the Jacobian is a scipy.sparse.csr_matrix, otherwise a dense numpy.ndarray.

Returns:

The resulting parametrization.

Return type:

Parametrization

Examples

For three output parameters, with only parameters 0 and 2 optimized:

parametrization = build_fixed_parametrization(
    n_p_outputs=3,
    optimized_indices=[0, 2],
    fixed_parameters=[1.0, 2.0, 3.0],
)

Then:

\[\begin{split}\mathbf{p}_{out} = \begin{bmatrix} p_{in,0} \\ 2 \\ p_{in,1} \end{bmatrix}\end{split}\]

and the Jacobian has shape (3, 2).