src/estimagic/optimization/pounders_auxiliary.py
def interpolate_f(
    history,
    interpolation_set,
    residual_model,
    model_indices,
    n_modelpoints,
    n_maxinterp,
):
    """Interpolate f via the quadratic residual model.

    If the point x_k belongs to the interpolation set, one can show that
    c = f (x_k).

    Args:
        history (class): Class storing history of xs, residuals, and critvals.
        x_sample (np.ndarray): Vector of centered x sample that makes up the
            interpolation set. Shape (maxinterp, n).
        residual_model (dict): Dictionary containing the parameters of the
            residual model, i.e. "intercepts", "linear_terms", and "square terms".
        model_indices (np.ndarray): Indices of the candidates of x that are
            currently in the model. Shape (2 *n* + 1,).
        n_modelpoints (int): Current number of model points.
        n_maxinterp (int): Maximum number of interpolation points.

    Returns:
        (np.ndarray): Interpolated function f. Array of shape (n_obs,).
    """
    n_obs = history.get_residuals(index=-1).shape[0]
    f_interpolated = np.zeros((n_maxinterp, n_obs), dtype=np.float64)

    for j in range(n_obs):
        x_square_terms = np.dot(
            interpolation_set, residual_model["square_terms"][j, :, :]
        )

        for i in range(n_modelpoints):
            center_info = {"residuals": residual_model["intercepts"]}
            residuals = history.get_centered_residuals(
                center_info, index=model_indices[i]
            )

            f_interpolated[i, j] = (
                residuals[j]
                - np.dot(residual_model["linear_terms"][:, j], interpolation_set[i, :])
                - 0.5 * np.dot(x_square_terms[i, :], interpolation_set[i, :])
            )

    return f_interpolated
Interpolate f via the quadratic residual model.

    If the point x_k belongs to the interpolation set, one can show that
    c = f (x_k).

    Args:
        history (class): Class storing history of xs, residuals, and critvals.
        x_sample (np.ndarray): Vector of centered x sample that makes up the
            interpolation set. Shape (maxinterp, n).
        residual_model (dict): Dictionary containing the parameters of the
            residual model, i.e. "intercepts", "linear_terms", and "square terms".
        model_indices (np.ndarray): Indices of the candidates of x that are
            currently in the model. Shape (2 *n* + 1,).
        n_modelpoints (int): Current number of model points.
        n_maxinterp (int): Maximum number of interpolation points.

    Returns:
        (np.ndarray): Interpolated function f. Array of shape (n_obs,).
    
Interpolate f via the quadratic residual model.
If the point x_k belongs to the interpolation set, one can show that
c = f (x_k).
Interpolate f via the quadratic residual model . If the point x_k belongs to the interpolation set one can show that c = f ( x_k ) .
def interpolate_f(
    history,
    interpolation_set,
    residual_model,
    model_indices,
    n_modelpoints,
    n_maxinterp,
):
    n_obs = history.get_residuals(index=-1).shape[0]
    f_interpolated = np.zeros((n_maxinterp, n_obs), dtype=np.float64)
    for j in range(n_obs):
        x_square_terms = np.dot(
            interpolation_set, residual_model["square_terms"][j, :, :]
        )
        for i in range(n_modelpoints):
            center_info = {"residuals": residual_model["intercepts"]}
            residuals = history.get_centered_residuals(
                center_info, index=model_indices[i]
            )
            f_interpolated[i, j] = (
                residuals[j]
                - np.dot(residual_model["linear_terms"][:, j], interpolation_set[i, :])
                - 0.5 * np.dot(x_square_terms[i, :], interpolation_set[i, :])
            )
    return f_interpolated
def interpolate_f ( history , interpolation_set , residual_model , model_indices , n_modelpoints , n_maxinterp , ) : n_obs = history . get_residuals ( index = - 1 ) . shape [ 0 ] f_interpolated = np . zeros ( ( n_maxinterp , n_obs ) , dtype = np . float64 ) for j in range ( n_obs ) : x_square_terms = np . dot ( interpolation_set , residual_model [ "square_terms" ] [ j , : , : ] ) for i in range ( n_modelpoints ) : center_info = { "residuals" : residual_model [ "intercepts" ] } residuals = history . get_centered_residuals ( center_info , index = model_indices [ i ] ) f_interpolated [ i , j ] = ( residuals [ j ] - np . dot ( residual_model [ "linear_terms" ] [ : , j ] , interpolation_set [ i , : ] ) - 0.5 * np . dot ( x_square_terms [ i , : ] , interpolation_set [ i , : ] ) ) return f_interpolated
Interpolate f via the quadratic residual model.
Interpolate f via the quadratic residual model .
"""Interpolate f via the quadratic residual model.

    If the point x_k belongs to the interpolation set, one can show that
    c = f (x_k).

    Args:
        history (class): Class storing history of xs, residuals, and critvals.
        x_sample (np.ndarray): Vector of centered x sample that makes up the
            interpolation set. Shape (maxinterp, n).
        residual_model (dict): Dictionary containing the parameters of the
            residual model, i.e. "intercepts", "linear_terms", and "square terms".
        model_indices (np.ndarray): Indices of the candidates of x that are
            currently in the model. Shape (2 *n* + 1,).
        n_modelpoints (int): Current number of model points.
        n_maxinterp (int): Maximum number of interpolation points.

    Returns:
        (np.ndarray): Interpolated function f. Array of shape (n_obs,).
    """
Interpolated function f. Array of shape (n_obs,).
Interpolated function f . Array of shape ( n_obs ) .
(np.ndarray)
history
Class storing history of xs, residuals, and critvals.
Class storing history of xs residuals and critvals .
interpolation_set
residual_model
Dictionary containing the parameters of the
residual model, i.e. "intercepts", "linear_terms", and "square terms".
Dictionary containing the parameters of the residual model i . e . " intercepts " " linear_terms " and " square terms " .
model_indices
Indices of the candidates of x that are
currently in the model.
Indices of the candidates of x that are currently in the model .
n_modelpoints
Current number of model points.
Current number of model points .
n_maxinterp
Maximum number of interpolation points.
Maximum number of interpolation points .
x_sample
Vector of centered x sample that makes up the
interpolation set. Shape (maxinterp, n).
Vector of centered x sample that makes up the interpolation set . Shape ( maxinterp n ) .