optimization_in_scilab.pdf

Func rastrigin deffyfxy funcx popsize 100 probacross

  • No School
  • AA 1
  • 70

This preview shows page 32 - 34 out of 70 pages.

such as the size of the population, are defined in the following sample Scilab script. func = ’rastrigin’; deff(’y=f(x)’,’y = ’+func+’(x)’); PopSize = 100; Proba_cross = 0.7; Proba_mut = 0.1; NbGen = 10; NbCouples = 110; Log = %T; nb_disp = 10; pressure = 0.05; Genetic Algorithms require many settings, which are cleanly handled by the ”parameters” module. This module provides the nit_param function, which returns a new, empty, set of pa- rameters. The add_param function allows to set individual named parameters, which are configure with key-value pairs. 1 ga params = init param ( ) ; 2 // Parameters to adapt to the shape of the optimization problem 3 ga params = add param ( ga params , ’minbound ’ , eval ( ’min bd +func+ ’ () ’ ) ) ; 4 ga params = add param ( ga params , ’maxbound’ , eval ( ’max bd +func+ ’ () ’ ) ) ; 5 ga params = add param ( ga params , ’dimension ’ , 2 ) ; 6 ga params = add param ( ga params , ’beta ’ , 0 ) ; 7 ga params = add param ( ga params , ’ delta ’ , 0 . 1 ) ; 8 // Parameters to fine tune the Genetic algorithm . 9 ga params = add param ( ga params , ’ init func ’ , i n i t g a d e f a u l t ) ; 10 ga params = add param ( ga params , ’ crossover func ’ , c r o s s o v e r g a d e f a u l t ) ; 11 ga params = add param ( ga params , ’mutation func ’ , mutation ga default ) ; 12 ga params = add param ( ga params , ’ codage func ’ , coding ga identity ) ; 29
Image of page 32

Subscribe to view the full document.

13 ga params = add param ( ga params , ’ selection func ’ , s e l e c t i o n g a e l i t i s t ) ; 14 ga params = add param ( ga params , ’ nb couples ’ , NbCouples ) ; 15 ga params = add param ( ga params , ’ pressure ’ , pressure ) ; The optim_ga function search a population solution of a single-objective problem with bound constraints. 1 [ pop opt , fobj pop opt , pop init , f o b j p o p i n i t ] = . . . 2 optim ga ( f , PopSize , NbGen, Proba mut , Proba cross , Log , ga params ) ; The following are the messages which are displayed in the Scilab console : optim_ga: Initialization of the population optim_ga: iteration 1 / 10 - min / max value found = -1.682413 / 0.081632 optim_ga: iteration 2 / 10 - min / max value found = -1.984184 / -0.853613 optim_ga: iteration 3 / 10 - min / max value found = -1.984184 / -1.314217 optim_ga: iteration 4 / 10 - min / max value found = -1.984543 / -1.513463 optim_ga: iteration 5 / 10 - min / max value found = -1.998183 / -1.691332 optim_ga: iteration 6 / 10 - min / max value found = -1.999551 / -1.871632 optim_ga: iteration 7 / 10 - min / max value found = -1.999977 / -1.980356 optim_ga: iteration 8 / 10 - min / max value found = -1.999979 / -1.994628 optim_ga: iteration 9 / 10 - min / max value found = -1.999989 / -1.998123 optim_ga: iteration 10 / 10 - min / max value found = -1.999989 / -1.999534 The initial and final populations for this simulation are shown in 5.1 . The following script is a loop over the optimum individuals of the population. 1 printf ( ’Genetic Algorithm : %d points from pop opt \ n ’ , nb disp ) ; 2 for i =1: nb disp 3 printf ( ’ Individual %d: x(1) = %f x(2) = %f - > f = %f \ n ’ , . . . 4 i , pop opt ( i ) ( 1 ) , pop opt ( i ) ( 2 ) , fobj pop opt ( i ) ) ; 5 end The previous script make the following lines appear in the Scilab console. Individual 1: x(1) = -0.000101 x(2) = 0.000252 -> f = -1.999989 Individual 2: x(1) = -0.000118 x(2) = 0.000268 -> f = -1.999987 Individual 3: x(1) = 0.000034 x(2) = -0.000335 -> f = -1.999982 Individual 4: x(1) = -0.000497 x(2) = -0.000136 -> f = -1.999979 Individual 5: x(1) = 0.000215 x(2) = -0.000351 -> f = -1.999977 Individual 6: x(1) = -0.000519 x(2) = -0.000197 -> f = -1.999974 Individual 7: x(1) = 0.000188 x(2) = -0.000409 -> f = -1.999970 Individual 8: x(1) = -0.000193 x(2) = -0.000427 -> f = -1.999968 Individual 9: x(1) = 0.000558 x(2) = 0.000260 -> f = -1.999966 Individual 10: x(1) = 0.000235 x(2) = -0.000442 -> f = -1.999964 5.3 Support functions In this section, we analyze the GA services to configure a GA computation.
Image of page 33
Image of page 34

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern