Beispiel #1
0
def convert_constraint(constraint):
    if isinstance(constraint, EqConstraint):
        return expression.eq_constraint(convert_expression(constraint.args[0]),
                                        convert_expression(constraint.args[1]))
    elif isinstance(constraint, PSDConstraint):
        return expression.psd_constraint(
            convert_expression(constraint.args[0]),
            convert_expression(constraint.args[1]))
    elif isinstance(constraint, LeqConstraint):
        return expression.leq_constraint(
            convert_expression(constraint.args[0]),
            convert_expression(constraint.args[1]))
    elif isinstance(constraint, SOC_Elemwise):
        return expression.soc_elemwise_constraint(
            convert_expression(constraint.t),
            *[convert_expression(x) for x in constraint.x_elems])
    elif isinstance(constraint, SOC):
        return expression.soc_contraint(
            convert_expression(constraint.t),
            expression.vstack(
                *[convert_expression(x) for x in constraint.x_elems]))

    raise RuntimeError("Unknown constraint: %s" % type(constraint))
Beispiel #2
0
def convert_constraint(constraint):
    if isinstance(constraint, EqConstraint):
        return expression.eq_constraint(
            convert_expression(constraint.args[0]),
            convert_expression(constraint.args[1]))
    elif isinstance(constraint, PSDConstraint):
        return expression.psd_constraint(
            convert_expression(constraint.args[0]),
            convert_expression(constraint.args[1]))
    elif isinstance(constraint, LeqConstraint):
        return expression.leq_constraint(
            convert_expression(constraint.args[0]),
            convert_expression(constraint.args[1]))
    elif isinstance(constraint, SOC_Elemwise):
        return expression.soc_elemwise_constraint(
            convert_expression(constraint.t),
            *[convert_expression(x) for x in constraint.x_elems])
    elif isinstance(constraint, SOC):
        return expression.soc_contraint(
            convert_expression(constraint.t),
            expression.vstack(
                *[convert_expression(x) for x in constraint.x_elems]))

    raise RuntimeError("Unknown constraint: %s" % type(constraint))
Beispiel #3
0
def transform_lambda_max(expr):
    t = epi_var(expr, "lambda_max", size=(1,1))
    X = only_arg(expr)
    n = dim(X, 0)
    tI = expression.diag_vec(expression.multiply(expression.ones(n, 1), t))
    return t, [expression.psd_constraint(tI, X)]
Beispiel #4
0
def transform_lambda_max(expr):
    t = epi_var(expr, "lambda_max", size=(1, 1))
    X = only_arg(expr)
    n = dim(X, 0)
    tI = expression.diag_vec(expression.multiply(expression.ones(n, 1), t))
    return t, [expression.psd_constraint(tI, X)]