Minimization with Linear Equality Constraints

The trust-region reflective method for fmincon can handle linear equality constraints if no other constraints exist. Suppose you want to minimize


subject to some linear equality constraints. The objective function is coded in the function brownfgh.m. This example takes n = 1000. Furthermore, the browneq.mat file contains matrices Aeq and beq that represent the linear constraints Aeq·x = beq. Aeq has 100 rows representing 100 linear constraints (so Aeq is a 100-by-1000 matrix).

Step 1: Write a file brownfgh.m that computes the objective function, the gradient of the objective, and the sparse tridiagonal Hessian matrix.

The file is lengthy so is not included here. View the code with the command

type brownfgh

Because brownfgh computes the gradient and Hessian values as well as the objective function, you need to use optimoptions to indicate that this information is available in brownfgh, using the SpecifyObjectiveGradient and Hessian options.

The sparse matrix Aeq and vector beq are available in the file browneq.mat:

load browneq

The linear constraint system is 100-by-1000, has unstructured sparsity (use spy(Aeq) to view the sparsity structure), and is not too badly ill-conditioned:

ans =

Step 2: Call a nonlinear minimization routine with a starting point xstart.

fun = @brownfgh;
load browneq          % Get Aeq and beq, the linear equalities
n = 1000;
xstart = -ones(n,1); xstart(2:2:n) = 1;
options = optimoptions('fmincon','SpecifyObjectiveGradient',true,'HessianFcn','objective',...
[x,fval,exitflag,output] = ...

fmincon prints the following exit message:

Local minimum possible.

fmincon stopped because the final change in function value relative to 
its initial value is less than the default value of the function tolerance.

The exitflag value of 3 also indicates that the algorithm terminated because the change in the objective function value was less than the tolerance FunctionTolerance. The final function value is given by fval. Constraints are satisfied, as you see in output.constrviolation


exitflag =


fval =


ans =


The linear equalities are satisfied at x.


ans =

Related Topics