Page 359 - Applied Numerical Methods Using MATLAB
P. 359

348    OPTIMIZATION
                                                         
                                                            0
                                           −x 1
                                                            0
                                           −x 2
                                                         
                                                         
                       s.t.  g(x) =  3x 1 − x 1 x 2 + 4x 2 − 7  ≤  0   (E7.3.1b)
                                  
                                                      
                                                           
                                                         
                                       2x 1 + x 2 − 3
                                                         0 
                                             2
                                      3x 1 − 4x − 4x 2      0
                                             2
              According to the penalty function method, we construct a new objective func-
           tion (7.2.6) as
                                   2            2         2              2
                Min l(x) ={(x 1 + 1.5) + 5(x 2 − 1.7) }{(x 1 − 1.4) + 0.6(x 2 − 0.5) }
                               5

                           +     v m ψ m (g m (x))                     (E7.3.2a)
                             m=1
           where
                                        0       if g m (x) ≤ 0 (constraint satisfied)

            v m = 1,  ψ m (g m (x)) =                                        ,
                                   exp(e m g m (x))  if g m (x)> 0 (constraint violated)
                            e m = 1 ∀ m = 1,..., 5                     (E7.3.2b)

            %nm722 for Ex.7.3
            % to solve a constrained optimization problem by penalty ftn method.
            clear, clf
            f =’f722p’;
            x0=[0.4 0.5]
            TolX = 1e-4; TolFun = 1e-9; alpha0 = 1;
            [xo_Nelder,fo_Nelder] = opt_Nelder(f,x0) %Nelder method
            [fc_Nelder,fo_Nelder,co_Nelder] = f722p(xo_Nelder) %its results
            [xo_s,fo_s] = fminsearch(f,x0) %MATLAB built-in fminsearch()
            [fc_s,fo_s,co_s] = f722p(xo_s) %its results
              % including how the constraints are satisfied or violated
            xo_steep = opt_steep(f,x0,TolX,TolFun,alpha0) %steepest descent method
            [fc_steep,fo_steep,co_steep] = f722p(xo_steep) %its results
            [xo_u,fo_u] = fminunc(f,x0); % MATLAB built-in fminunc()
            [fc_u,fo_u,co_u] = f722p(xo_u) %its results
            function [fc,f,c] = f722p(x)
            f=((x(1)+ 1.5)^2 + 5*(x(2)- 1.7)^2)*((x(1)- 1.4)^2 + .6*(x(2)-.5)^2);
            c=[-x(1); -x(2); 3*x(1) - x(1)*x(2) + 4*x(2) - 7;
                 2*x(1)+ x(2) - 3; 3*x(1) - 4*x(2)^2 - 4*x(2)]; %constraint vector
            v=[11111]; e=[1111 1]’; %weighting coefficient vector
            fc = f +v*((c > 0).*exp(e.*c)); %new objective function
   354   355   356   357   358   359   360   361   362   363   364