MATLAB Mathematical Modeling (9)-Genetic algorithm tools

Source: Internet
Author: User


Matlab comes with the Genetic algorithm Toolbox is gads, input help GA can see the use of GA, GA function The most complete format is [X,fval,exitflag,output,population,scores]=ga (FITNESSFCN , nvars,a,b,aeq,beq,lb,ub,nonlcon,options),
y=100* (x1^2-x2) ^2 + (1-X2) ^2 maximum value, X1 and X2 are within the range [ -2.048,2.048]:


>> [x,val,flag,output,population,scores]=ga(@(x)-100*(x(1)^2-x(2))^2-(1-x(1))^2, 2, [],[],[],[],[-2.048, -2.048], [2.048, 2.048]) 
Optimization terminated: average change in the fitness value less than options.TolFun.

x =

    2.0480   -2.0466


val =

  -3.8960e+03


flag =

     1


output = 

      problemtype: 'boundconstraints'
         rngstate: [1x1 struct]
      generations: 51
        funccount: 1040
          message: [1x86 char]
    maxconstraint: 0


population =

    2.0480   -2.0466
    2.0480   -2.0466
    2.0480   -2.0466
    2.0480   -2.0466
    2.0480   -2.0466
    2.0480   -2.0466
    2.0480   -2.0466
    2.0480   -2.0434
    2.0480   -2.0466
    2.0480   -2.0466
    2.0480   -2.0466
    2.0480   -2.0466
    2.0480   -2.0466
    2.0480   -2.0466
    2.0480   -2.0466
    2.0480   -2.0466
    2.0480   -2.0427
    2.0441   -2.0463
    2.0480   -2.0466
    2.0475   -2.0427


scores =

   1.0e+03 *

   -3.8960
   -3.8960
   -3.8960
   -3.8960
   -3.8960
   -3.8960
   -3.8960
   -3.8918
   -3.8959
   -3.8960
   -3.8960
   -3.8960
   -3.8959
   -3.8960
   -3.8959
   -3.8960
   -3.8911
   -3.8757
   -3.8959
   -3.8883


In addition, input GA can be manipulated directly on the graphical interface.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.