zoukankan      html  css  js  c++  java
  • 启发式算法:遗传算法 (Genetic algorithm)

    http://www.theprojectspot.com/tutorial-post/creating-a-genetic-algorithm-for-beginners/3

    目录

      GA的过程

      GA的伪代码

      Example

    GA的思想

      模仿生物界进化的过程:适者生存

    GA的过程

    (1)Initialization 

    Create an initial population. This population is usually randomly generated and can be any desired size, from only a few individuals to thousands.

    (2)Evaluation

    Each member of the population is then evaluated and we calculate a 'fitness' for that individual. The fitness value is calculated by how well it fits with our desired requirements. These requirements could be simple, 'faster algorithms are better', or more complex, 'stronger materials are better but they shouldn't be too heavy'.

    (3)Selection

    We want to be constantly improving our populations overall fitness. Selection helps us to do this by discarding the bad designs and only keeping the best individuals in the population.  There are a few different selection methods but the basic idea is the same, make it more likely that fitter individuals will be selected for our next generation.

    (4)Crossover

    During crossover we create new individuals by combining aspects of our selected individuals. We can think of this as mimicking how sex works in nature. The hope is that by combining certain traits from two or more individuals we will create an even 'fitter' offspring which will inherit the best traits from each of it's parents.

    (5)Mutation

    We need to add a little bit randomness into our populations' genetics otherwise every combination of solutions we can create would be in our initial population. Mutation typically works by making very small changes at random to an individuals genome.

    (6)And repeat!

    Now we have our next generation we can start again from step two until we reach a termination condition.

    GA的关键:
    (1)如何表示解?

    (2)如何进行crossover和mutation?

    (3)如何进行优胜劣汰?

    GA的伪代码

     Example: GA for TSP

    https://github.com/xiaolou023/Algorithms/tree/master/TSP/src/simpleGA2

  • 相关阅读:
    win10开机时内存使用率达到99%以上
    https的基本原理,看完你的程序员女朋友再也不和你提分手了
    Tomcat样例安全漏洞
    Linux5355端口被0.0.0.0监听
    jQuery的ajax
    事件委托(事件代理)
    jQuery的事件绑定和解绑
    事件对象
    JS的事件流的概念(重点)
    jQuery的位置信息
  • 原文地址:https://www.cnblogs.com/liuyingsme/p/9859350.html
Copyright © 2011-2022 走看看