The-Shakespeare-and-Monkey-Problem:进化计算-遗传算法

  • c5_422926
    了解作者
  • 5.5KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-13 13:38
    上传日期
莎士比亚与猴子问题 进化计算-遗传算法 为什么需要这种算法? 如果您有一只猴子在打字机上随机打字一段无穷的时间,那么最终,在某个时刻,这只猴子会打字出莎士比亚的完整作品。 好吧,简化问题,假设我们要从猴子身上得到的唯一一件事是 生存还是毁灭 让我们想象一个只有z和空格键的键盘。 随机输入“ t”的可能性为1/27 随机输入“至”的可能性为1/27 * 1/27 输入整个短语的可能性:(1/27)^ 18 58,149,737,003,040,059,690,390,168中的1 每秒100.000个短语的计算机模拟将需要: 〜18,439,160,642,770年 别忘了宇宙的年龄是137.5亿年(估计)。 因此,这是行不通的。 解决方案 解决此问题的一种方法是使用以下算法: 开始随机生成短语。 每一代之后,它都会根据词组的准确度自动进化,从而使每个词组具有适应性。
The-Shakespeare-and-Monkey-Problem-master.zip
  • The-Shakespeare-and-Monkey-Problem-master
  • .gitignore
    9B
  • README.md
    1.6KB
  • LICENSE
    1KB
  • sketch.js
    2.5KB
  • DNA.js
    1.2KB
  • Population.js
    1.8KB
  • index.html
    515B
  • style.css
    216B
内容介绍
# The Shakespeare and Monkey Problem Evolutionary Computing - Genetic Algorithm ![Monkeys](https://blogs.illinois.edu/files/25/14943/268.jpg) ## Why this algorithm is necessary? If you had a monkey typing at a typewriter randomly for an inifinity amount of time, eventually in some moment of the time this monkey would type out the completes works of Shakespeare. Okay, simplifing the problem, let's say the only thing we want from the monkey is ### **to be or not to be** let's imagine a keyboard only with a-z and spacebar character. **likelihood of typing a "t" randomly is 1/27** **likelihood of typing a "to" randomly is 1/27 * 1/27** likelihood of typing the entire phrase: (1/27) ^ 18 1 in **58,149,737,003,040,059,690,390,168** A computer simulation with 100.000 phrases per second would take: ~ 18,439,160,642,770 years Don't forget that the age of universe is 13,750,000,000 years (estimated). So that way is unworkable. ## Solution One way to solve this is with an algorithm that: 1. Starts to generate phrases randomly. 2. After every generation, it autoevolves based in the accurary of phrases giving each phrase a fitness. 3. Select the best ones and mix then based in some rule eg.: as half of one phrase and half of other. 4. After that, we repeat the steps until we get to the target phrase. That concept that we call **Genetic Algorithm** [Try by yourself here](https://jbezerra.github.io/The-Shakespeare-and-Monkey-Problem/index.html) ![Solution](https://media.giphy.com/media/L07I25uEUqkTvVoBe7/giphy.gif) Have some fun and spread the word =P Any questions? josebezerraneto@outlook.com
评论