src/estimagic/parameters/process_constraints.py
def _create_unscaled_internal_bounds(lower, upper, pc):
    """Create columns with bounds for the internal parameter vector.

    The columns have the length of the external params and will be reduced later.

    Args:
        lower (pd.Series): Processed and consolidated external lower bounds.
        upper (pd.Series): Processed and consolidated external upper bounds.
        pc (pd.DataFrame): Processed and consolidated constraints.

    Returns:
        int_lower (pd.Series): Lower bound of internal parameters.
        int_upper (pd.Series): Upper bound of internal parameters.

    """
    int_lower, int_upper = lower.copy(), upper.copy()

    for constr in pc:
        if constr["type"] in ["covariance", "sdcorr"]:
            # Note that the diagonal positions are the same for covariance and sdcorr
            # because the internal params contains the Cholesky factor of the implied
            # covariance matrix in both cases.
            dim = number_of_triangular_elements_to_dimension(len(constr["index"]))
            diag_positions = [0] + np.cumsum(range(2, dim + 1)).tolist()
            diag_indices = np.array(constr["index"])[diag_positions].tolist()
            bd = constr.get("bounds_distance", 0)
            bd = np.sqrt(bd) if constr["type"] == "covariance" else bd
            int_lower.iloc[diag_indices] = np.maximum(int_lower.iloc[diag_indices], bd)
        elif constr["type"] == "probability":
            int_lower.iloc[constr["index"]] = 0
        elif constr["type"] == "linear":
            int_lower.iloc[constr["index"]] = -np.inf
            int_upper.iloc[constr["index"]] = np.inf
            int_lower.update(constr["right_hand_side"]["lower_bound"])
            int_upper.update(constr["right_hand_side"]["upper_bound"])
        else:
            raise TypeError("Invalid constraint type {}".format(constr["type"]))

    return int_lower, int_upper
Create columns with bounds for the internal parameter vector.

    The columns have the length of the external params and will be reduced later.

    Args:
        lower (pd.Series): Processed and consolidated external lower bounds.
        upper (pd.Series): Processed and consolidated external upper bounds.
        pc (pd.DataFrame): Processed and consolidated constraints.

    Returns:
        int_lower (pd.Series): Lower bound of internal parameters.
        int_upper (pd.Series): Upper bound of internal parameters.

    
Create columns with bounds for the internal parameter vector.
The columns have the length of the external params and will be reduced later.
Create columns with bounds for the internal parameter vector . The columns have the length of the external params and will be reduced later .
def _create_unscaled_internal_bounds(lower, upper, pc):
    int_lower, int_upper = lower.copy(), upper.copy()
    for constr in pc:
        if constr["type"] in ["covariance", "sdcorr"]:
            dim = number_of_triangular_elements_to_dimension(len(constr["index"]))
            diag_positions = [0] + np.cumsum(range(2, dim + 1)).tolist()
            diag_indices = np.array(constr["index"])[diag_positions].tolist()
            bd = constr.get("bounds_distance", 0)
            bd = np.sqrt(bd) if constr["type"] == "covariance" else bd
            int_lower.iloc[diag_indices] = np.maximum(int_lower.iloc[diag_indices], bd)
        elif constr["type"] == "probability":
            int_lower.iloc[constr["index"]] = 0
        elif constr["type"] == "linear":
            int_lower.iloc[constr["index"]] = -np.inf
            int_upper.iloc[constr["index"]] = np.inf
            int_lower.update(constr["right_hand_side"]["lower_bound"])
            int_upper.update(constr["right_hand_side"]["upper_bound"])
        else:
            raise TypeError("Invalid constraint type {}".format(constr["type"]))
    return int_lower, int_upper
def _create_unscaled_internal_bounds ( lower , upper , pc ) : int_lower , int_upper = lower . copy ( ) , upper . copy ( ) for constr in pc : if constr [ "type" ] in [ "covariance" , "sdcorr" ] : dim = number_of_triangular_elements_to_dimension ( len ( constr [ "index" ] ) ) diag_positions = [ 0 ] + np . cumsum ( range ( 2 , dim + 1 ) ) . tolist ( ) diag_indices = np . array ( constr [ "index" ] ) [ diag_positions ] . tolist ( ) bd = constr . get ( "bounds_distance" , 0 ) bd = np . sqrt ( bd ) if constr [ "type" ] == "covariance" else bd int_lower . iloc [ diag_indices ] = np . maximum ( int_lower . iloc [ diag_indices ] , bd ) elif constr [ "type" ] == "probability" : int_lower . iloc [ constr [ "index" ] ] = 0 elif constr [ "type" ] == "linear" : int_lower . iloc [ constr [ "index" ] ] = - np . inf int_upper . iloc [ constr [ "index" ] ] = np . inf int_lower . update ( constr [ "right_hand_side" ] [ "lower_bound" ] ) int_upper . update ( constr [ "right_hand_side" ] [ "upper_bound" ] ) else : raise TypeError ( "Invalid constraint type {}" . format ( constr [ "type" ] ) ) return int_lower , int_upper
Create columns with bounds for the internal parameter vector.
Create columns with bounds for the internal parameter vector .
"""Create columns with bounds for the internal parameter vector.

    The columns have the length of the external params and will be reduced later.

    Args:
        lower (pd.Series): Processed and consolidated external lower bounds.
        upper (pd.Series): Processed and consolidated external upper bounds.
        pc (pd.DataFrame): Processed and consolidated constraints.

    Returns:
        int_lower (pd.Series): Lower bound of internal parameters.
        int_upper (pd.Series): Upper bound of internal parameters.

    """ # Note that the diagonal positions are the same for covariance and sdcorr # because the internal params contains the Cholesky factor of the implied # covariance matrix in both cases.
int_lower (pd.Series): Lower bound of internal parameters.
int_upper (pd.Series): Upper bound of internal parameters.
int_lower ( pd . Series ) : Lower bound of internal parameters . int_upper ( pd . Series ) : Upper bound of internal parameters .
lower
Processed and consolidated external lower bounds.
Processed and consolidated external lower bounds .
upper
Processed and consolidated external upper bounds.
Processed and consolidated external upper bounds .
pc
Processed and consolidated constraints.
Processed and consolidated constraints .