src/estimagic/parameters/process_constraints.py
def _replace_increasing_and_decreasing_by_linear(pc):
    """Write increasing and decreasing constraints as linear constraints.

    Args:
        pc (list): Constraints where the selectors have already been processed.

    Returns:
        processed (list)

    """
    increasing_ilocs, other_constraints = [], []

    for constr in pc:
        if constr["type"] == "increasing":
            increasing_ilocs.append(constr["index"])
        elif constr["type"] == "decreasing":
            increasing_ilocs.append(constr["index"][::-1])
        else:
            other_constraints.append(constr)

    linear_constraints = []
    for iloc in increasing_ilocs:
        for smaller, larger in zip(iloc, iloc[1:]):
            linear_constr = {
                "index": [smaller, larger],
                "type": "linear",
                "weights": np.array([-1, 1]),
                "lower_bound": 0,
            }
            linear_constraints.append(linear_constr)

    processed = linear_constraints + other_constraints
    return processed
Write increasing and decreasing constraints as linear constraints.

    Args:
        pc (list): Constraints where the selectors have already been processed.

    Returns:
        processed (list)

    
Write increasing and decreasing constraints as linear constraints.
Write increasing and decreasing constraints as linear constraints .
def _replace_increasing_and_decreasing_by_linear(pc):
    increasing_ilocs, other_constraints = [], []
    for constr in pc:
        if constr["type"] == "increasing":
            increasing_ilocs.append(constr["index"])
        elif constr["type"] == "decreasing":
            increasing_ilocs.append(constr["index"][::-1])
        else:
            other_constraints.append(constr)
    linear_constraints = []
    for iloc in increasing_ilocs:
        for smaller, larger in zip(iloc, iloc[1:]):
            linear_constr = {
                "index": [smaller, larger],
                "type": "linear",
                "weights": np.array([-1, 1]),
                "lower_bound": 0,
            }
            linear_constraints.append(linear_constr)
    processed = linear_constraints + other_constraints
    return processed
def _replace_increasing_and_decreasing_by_linear ( pc ) : increasing_ilocs , other_constraints = [ ] , [ ] for constr in pc : if constr [ "type" ] == "increasing" : increasing_ilocs . append ( constr [ "index" ] ) elif constr [ "type" ] == "decreasing" : increasing_ilocs . append ( constr [ "index" ] [ : : - 1 ] ) else : other_constraints . append ( constr ) linear_constraints = [ ] for iloc in increasing_ilocs : for smaller , larger in zip ( iloc , iloc [ 1 : ] ) : linear_constr = { "index" : [ smaller , larger ] , "type" : "linear" , "weights" : np . array ( [ - 1 , 1 ] ) , "lower_bound" : 0 , } linear_constraints . append ( linear_constr ) processed = linear_constraints + other_constraints return processed
Write increasing and decreasing constraints as linear constraints.
Write increasing and decreasing constraints as linear constraints .
"""Write increasing and decreasing constraints as linear constraints.

    Args:
        pc (list): Constraints where the selectors have already been processed.

    Returns:
        processed (list)

    """
None
pc
Constraints where the selectors have already been processed.
Constraints where the selectors have already been processed .