Page 310 - MATLAB an introduction with applications
P. 310

Optimization ———  295


                   Optimization terminated: relative infinity-norm of gradient less than
                   options.TolFun.


                   x =
                          0.5000    –1.0000
                   fval =
                          3.6609e–016
                   exitflag =
                        1
                   output =
                          iterations: 8
                           funcCount: 66
                            stepsize: 1
                          firstorderopt: 7.3704e–008
                           algorithm: ‘medium-scale: Quasi-Newton line search’
                             message: ‘Optimization terminated: relative infinity-norm of gradient
                   less than options.TolFun.’

                   Example E5.16: This is a non-linear inequality constrained example. Find x that solves
                                                     2
                                                2
                                  min ( ) x =  e  1 x  (4x + 2x + 4x x + 2x + 0.9)
                                     f
                                                     2
                                                1
                                                          1 2
                                                                2
                                   x
                   subject to the constraints
                                 x x  – x  – x  ≤ –2.0
                                  1 2
                                       1
                                           2
                                 x x  ≥ –10
                                  1 2
                                 0
                   Starting guess: x  = [–1, 1].
                   Solution: The constraints are written in the form c(x) ≤ 0.
                                 x x  – x  – x  + 2 ≤ 0
                                       1
                                           2
                                  1 2
                                 –x x  – 10 ≤ 0
                                   1 2
                   MATLAB Solution [Using built-in function]:
                   Write an m-file objfun.m
                   function f=objfun(x)
                   f=exp(x(1))*(4*x(1)^2+2*x(2)^2+4*x(1)*x(2)+2*x(2)+0.9);
                   Write an m-file confun.m for the constraints:
                   function [c,ceq]=confun(x)
                   %Nonlinear inequality constraints
                   c=[2+x(1)*x(2)–x(1)–x(2);–x(1)*x(2)–10];
                   %Nonlinear inequality constraints
                   ceq=[];
   305   306   307   308   309   310   311   312   313   314   315