pysolvegn.Parametrization#

class Parametrization(parametric_func=None, jacobian_func=None, finite_difference=None, finite_difference_epsilon=None)[source]#

A parametric transformation \(P\) that maps input parameters \(\vec{p_{in}}\) from an input parametric space \(\mathbb{R}^{n_{\mathrm{parameters}}}\) to output parameters \(\vec{p_{out}}\) in an output parametric space \(\mathbb{R}^{n_{\mathrm{p\_outputs}}}\).

\[\vec{p_{out}} = \vec{p} = P(\vec{p_{in}})\]

Considering the following least-square problem:

\[\min_{\vec{p_{out}}} \frac{1}{2} \sum_{i} w_i \sum_j \rho_i\left(\| \mathbf{r}_{i,j}(\vec{p_{out}}) \|^2\right)\]

it can be rewritten using the parametric transformation \(P\) as:

\[\min_{\vec{p_{in}}} \frac{1}{2} \sum_{i} w_i \sum_j \rho_i\left( \| \mathbf{r}_{i,j}(P(\vec{p_{in}})) \|^2 \right)\]

The parameters \(\vec{p_{in}}\) are the parameters actually optimized by the Gauss-Newton algorithm, while \(\vec{p_{out}}\) are the parameters passed to the residual functions.

This class is used to store the parametric transformation \(P\) and its first derivative:

\[\mathbf{J}_P = \frac{\partial \vec{p_{out}}} {\partial \vec{p_{in}}}.\]
Parameters:
  • parametric_func (Callable) – The function to compute the parametric transformation \(P\). The function should take as input the parameters (array-like with shape (n_parameters,)) and return the transformed parameters as a 1D numpy array with shape (n_p_outputs,), representing the output parameters \(\mathbf{p}_{out}\).

  • jacobian_func (Optional[Callable] (default=None)) – The function to compute the Jacobian matrix of the parametric transformation \(P\) with respect to the input parameters. The function should take as input the parameters (1D array-like with shape (n_parameters,)) and return the Jacobian matrix as a 2D array-like with shape (n_p_outputs, n_parameters). Each element of the Jacobian is given by \(\mathbf{J}_{P,(j,l)}=\frac{\partial p_{out,j}}{\partial p_{in,l}}\) where \(j=0,...,n_{p_o}-1}\) and \(l=0,...,n_{p}-1}\). If not provided, finite_difference must be specified to numerically compute the Jacobian.

  • finite_difference (Optional[str] (default=None)) – The finite difference method used to numerically compute the Jacobian when jacobian_func is not provided. If None, the Jacobian is not computed numerically. In this case, jacobian_func must be provided. Available methods are "central", "forward", and "backward".

  • finite_difference_epsilon (Optional[Real] (default=None)) – The relative step of the finite differences (only with finite_difference). If None, the default step of the method is used: about 1.5e-8 for "forward" and "backward", about 6.1e-6 for "central" (see pysolvegn.build_numerical_jacobian()).

__init__(parametric_func=None, jacobian_func=None, finite_difference=None, finite_difference_epsilon=None)[source]#
Parameters:
  • parametric_func (Callable)

  • jacobian_func (Callable | None)

  • finite_difference (str | None)

  • finite_difference_epsilon (Real | None)

Methods

__init__([parametric_func, jacobian_func, ...])

Attributes

J_func

jacobian_func

[Get] the Jacobian function \(\mathbf{J}_i: \mathbb{R}^{n_p} \rightarrow :math:\)mathbb{M}_{n_{p_o}, n_p}(mathbb{R})`` of the parametrization.

p_func

parametric_func

[Get] the parametric function \(\P: \mathbb{R}^{n_p} \rightarrow \mathbb{R}^{n_{p_o}}}\) of the parametrization.