Main Content

Bound Constraints

Lower and upper bounds limit the components of the solution x.

If you know the bounds on the location of an optimum, you can obtain faster and more reliable solutions by explicitly including these bounds in your problem formulation.

Specify bounds as vectors with the same length as x, or as matrices with the same number of elements as x.

  • If a particular component has no lower bound, use –Inf as the bound; similarly, use Inf if a component has no upper bound.

  • If you have only bounds of one type (upper or lower), you do not need to write the other type. For example, if you have no upper bounds, you do not need to supply a vector of Infs.

  • If only the first m out of n components have bounds, then you only need to supply a vector of length m containing bounds. However, this shortcut causes solvers to issue a warning.

For example, suppose your bounds are:

x3 ≥ 8,
x2 ≤ 3.

Write the constraint vectors as

l = [–Inf; –Inf; 8],
u = [Inf; 3] (issues a warning) or u = [Inf; 3; Inf].

Tip

To lower memory usage and increase solver speed, use Inf or –Inf instead of a large, arbitrary bound. For more information, see Use Inf Instead of a Large, Arbitrary Bound.

You do not have to give gradients for bound constraints; solvers calculate them automatically. Bounds do not affect Hessians.

For a more complex example of bounds, see Set Up a Linear Program, Solver-Based.

Related Topics