Skip to contents

constraint_residual(cstr) is the expression r such that an equation constraint reads 0 ~ r and an inequality constraint 0 >= r: lhs - rhs, with the sides exchanged for >=. canonical_constraints(sys) returns the residuals of all constraints of a system, one per row of the constraint function, in the order of constraints(sys).

Usage

constraint_residual(cstr)

canonical_constraints(sys, scalarize = TRUE)

Arguments

cstr

An Equation or Inequality.

sys

A System.

scalarize

Unused; constraints are always scalar here.

Value

A sym expression, or a list of them.

Examples

x <- Variable("x"); y <- Variable("y")
constraint_residual(Inequality(x^2 + y^2, 1, ">="))
#> -x^2 - y^2 + 1
sys <- complete(System(list(), costs = list(x^2 + y^2), name = "opt",
                       constraints = list(x + y ~ 1, Inequality(x, 0.8))))
canonical_constraints(sys)
#> [[1]]
#> x + y - 1
#> 
#> [[2]]
#> x - 0.8
#>