Main Content

Types of Constraints

Optimization Toolbox™ solvers have special forms for constraints:

  • Bound Constraints — Lower and upper bounds on individual components; x ≥ l and x ≤ u.

  • Linear Inequality ConstraintsA·x ≤ b. A is an m-by-n matrix, which represents m constraints for an n-dimensional vector x. b is m-dimensional.

  • Linear Equality ConstraintsAeq·x = beq. Equality constraints have the same form as inequality constraints.

  • Nonlinear Constraintsc(x) ≤ 0 and ceq(x) = 0. Both c and ceq are scalars or vectors representing several constraints.

Optimization Toolbox functions assume that inequality constraints have the form ci(x) ≤ 0 or A·x ≤ b. Express greater-than constraints as less-than constraints by multiplying them by –1. For example, a constraint of the form ci(x) ≥ 0 is equivalent to the constraint –ci(x) ≤ 0. A constraint of the form A·x ≥ b is equivalent to the constraint –A·x ≤ –b. For more information, see Linear Inequality Constraints and Nonlinear Constraints.

You can sometimes write constraints in several ways. For best results, use the lowest numbered constraints possible:

  1. Bounds

  2. Linear equalities

  3. Linear inequalities

  4. Nonlinear equalities

  5. Nonlinear inequalities

For example, with a constraint 5 x ≤ 20, use a bound x ≤ 4 instead of a linear inequality or nonlinear inequality.

For information on how to pass extra parameters to constraint functions, see Passing Extra Parameters.