optimization_in_scilab.pdf

# The other parameters epsf and epsx are not used the

• No School
• AA 1
• 70

This preview shows page 20 - 23 out of 70 pages.

The other parameters epsf and epsx are not used. The termination condition is not based on the gradient, as the name epsg would indicate. The following is a list of termination conditions which are taken into account in the source code. The iteration is greater than the maximum. if (itr.gt.niter) go to 250 The number of function evaluations is greater than the maximum. if (nfun.ge.nsim) go to 250 The directionnal derivative is positive, so that the direction d is not a descent direction for f . if (dga.ge.0.0d+0) go to 240 The cost function set the indic flag (the ind parameter) to 0, indicating that the optimization must terminate. call simul (indic,n,xb,fb,gb,izs,rzs,dzs) [...] go to 250 17

Subscribe to view the full document.

The cost function set the indic flag to a negative value indicating that the function cannot be evaluated for the given x . The step is reduced by a factor 10, but gets below a limit so that the algorithm terminates. call simul (indic,n,xb,fb,gb,izs,rzs,dzs) [...] step=step/10.0d+0 [...] if (stepbd.gt.steplb) goto 170 [...] go to 250 The Armijo condition is not satisfied and step size is below a limit during the line search. if (fb-fa.le.0.10d+0*c*dga) go to 280 [...] if (step.gt.steplb) go to 270 During the line search, a cubic interpolation is computed and the computed minimum is associated with a zero step length. if(c.eq.0.0d+0) goto 250 During the line search, the step length is lesser than a computed limit. if (stmin+step.le.steplb) go to 240 The rank of the approximated Hessian matrix is lesser than n after the update of the Cholesky factors. if (ir.lt.n) go to 250 1.7.5 An example The following script illustrates that the gradient may be very slow, but the algorithm continues. This shows that the termination criteria is not based on the gradient, but on the length of the step. The problem has two parameters so that n = 2. The cost function is the following f ( x ) = x p 1 + x p 2 (1.7) where p 0 is an even integer. Here we choose p = 10. The gradient of the function is g ( x ) = f ( x ) = ( px p - 1 1 , px p - 1 2 ) T (1.8) and the Hessian matrix is H ( x ) = p ( p - 1) x p - 2 1 0 0 p ( p - 1) x p - 2 2 (1.9) 18
The optimum of this optimization problem is at x ? = (0 , 0) T . (1.10) The following Scilab script defines the cost function, checks that the derivatives are correctly computed and performs an optimization. At each iteration, the norm of the gradient of the cost function is displayed so that one can see if the algorithm terminates when the gradient is small. function [ f , g , ind ] = myquadratic ( x , ind ) p = 10 i f ind == 1 | ind == 2 | ind == 4 then f = x (1)ˆp + x (2)ˆp ; end i f ind == 1 | ind == 2 | ind == 4 then g (1) = p * x (1)ˆ( p - 1) g (2) = p * x (2)ˆ( p - 1) end i f ind == 1 then mprintf ( | x | =%e, f=%e, | g | =%e \ n” , norm (x ) , f , norm ( g )) end endfunction function f = quadfornumdiff ( x ) f = myquadratic ( x , 2 ) endfunction x0 = [ - 1.2 1 . 0 ] ; [ f , g ] = myquadratic ( x0 , 4 ) ; mprintf ( ”Computed f (x0) = %f \ n” , f ) ; mprintf ( ”Computed g(x0) = \ n” ) ; disp (g ’ ) ; mprintf ( ”Expected g(x0) = \ n” ) ; disp ( derivative ( quadfornumdiff , x0 ’ ) ) nap = 100 i t e r = 100 epsg = %eps [ fopt , xopt , gradopt ] = optim ( myquadratic , x0 , . . .

Subscribe to view the full document.

• Fall '19

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern