Linear Constraints

Linear Inequality Constraints

Linear inequality constraints have the form A·x ≤ b. When A is m-by-n, there are m constraints on a variable x with n components. You supply the m-by-n matrix A and the m-component vector b.

Even if you pass an initial point x0 as a matrix, solvers pass the current point x as a column vector to linear constraints. See Matrix Arguments.

For example, suppose that you have the following linear inequalities as constraints:

x1 + x3 ≤ 4,
2x2x3 ≥ –2,
x1x2 + x3x4 ≥ 9.

Here m = 3 and n = 4.

Write these using the following matrix A and vector b:

A=[101002101111],b=[429].

Notice that the “greater than” inequalities were first multiplied by –1 in order to get them into “less than” inequality form. In MATLAB® syntax:

A = [1 0 1 0;
    0 -2 1 0;
    -1 1 -1 1];
b = [4;2;-9];

You do not need to give gradients for linear constraints; solvers calculate them automatically. Linear constraints do not affect Hessians.

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

Linear Equality Constraints

Linear equalities have the form Aeq·x = beq, which represents m equations with n-component vector x. You supply the m-by-n matrix Aeq and the m-component vector beq.

You do not need to give gradients for linear constraints; solvers calculate them automatically. Linear constraints do not affect Hessians. The form of this type of constraint is the same as for Linear Inequality Constraints.

Was this topic helpful?