Optimization Toolbox    

Equality Constrained Example

For routines that permit equality constraints, nonlinear equality constraints must be computed in the M-file with the nonlinear inequality constraints. For linear equalities, the coefficients of the equalities are passed in through the matrix Aeq and the right-hand-side vector beq.

For example, if you have the nonlinear equality constraint and the nonlinear inequality constraint , rewrite them as

and then solve the problem using the following steps.

Step 1: Write an M-file objfun.m.

Step 2: Write an M-file confuneq.m for the nonlinear constraints.

Step 3: Invoke constrained optimization routine.

After 21 function evaluations, the solution produced is

Note that ceq is equal to 0 within the default tolerance on the constraints of 1.0e-006 and that c is less than or equal to zero as desired.


  Gradient Check: Analytic Versus Numeric Maximization