|
|
||
|---|---|---|
| .. | ||
| Diophantine.ipynb | ||
| Genetic.ipynb | ||
| README.md | ||
README.md
Genetic Algorithms
Pre-lecture quiz
Genetic Algorithms (GA) na method wey dey use evolutionary approach for AI, wey dey use how population dey evolve to find better solution for one problem. Na John Henry Holland propose am for 1975.
Genetic Algorithms dey base on dis ideas:
- Correct solutions for di problem fit dey represent as genes
- Crossover dey allow us join two solutions together to get new correct solution
- Selection dey help us choose better solutions using one fitness function
- Mutations dey help scatter optimization small so we fit comot from di local minimum
If you wan do Genetic Algorithm, you go need dis things:
- Find way to code di problem solutions using genes g∈Γ
- For di set of genes Γ, you go need define fitness function fit: Γ→R. Di smaller di function value, di better di solution.
- Define crossover method to join two genes together to get new correct solution crossover: Γ2→Γ.
- Define mutation method mutate: Γ→Γ.
Most times, crossover and mutation na simple algorithms wey dey manipulate genes as number sequence or bit vectors.
Di way wey Genetic Algorithm dey work fit change from one case to another, but di general structure be like dis:
- Choose one initial population G⊂Γ
- Randomly choose one operation wey go happen for dis step: crossover or mutation
- Crossover:
- Randomly choose two genes g1, g2 ∈ G
- Calculate crossover g=crossover(g1,g2)
- If fit(g)<fit(g1) or fit(g)<fit(g2) - replace di gene for di population with g.
- Mutation - choose random gene g∈G and replace am with mutate(g)
- Repeat from step 2, until we get one small value of fit, or until di limit for di number of steps don reach.
Typical Tasks
Di kind tasks wey Genetic Algorithms dey solve na:
- Schedule optimization
- Better packing
- Better cutting
- Make exhaustive search fast
✍️ Exercises: Genetic Algorithms
Continue your learning for di notebooks wey dey here:
Check dis notebook to see two examples of how Genetic Algorithms dey work:
- How to share treasure well
- 8 Queens Problem
Conclusion
Genetic Algorithms dey solve plenty problems, like logistics and search problems. Di field dey inspired by research wey join Psychology and Computer Science together.
🚀 Challenge
"Genetic algorithms dey easy to do, but how dem dey behave dey hard to understand." source Do small research to find one Genetic Algorithm wey dey solve something like Sudoku puzzle, and explain how e dey work as sketch or flowchart.
Post-lecture quiz
Review & Self Study
Watch dis better video wey dey talk about how computer fit learn to play Super Mario using neural networks wey Genetic Algorithms train. We go learn more about how computer dey learn to play games like dat for di next section.
Assignment: Diophantine Equation
Your goal na to solve di Diophantine equation - equation wey get integer roots. For example, check di equation a+2b+3c+4d=30. You go need find di integer roots wey go make di equation correct.
Dis assignment dey inspired by dis post.
Hints:
- You fit think say di roots dey for di interval [0;30]
- As gene, you fit use di list of root values
Use Diophantine.ipynb as your starting point.
Disclaimer:
Dis docu wey you dey see don use AI translation service Co-op Translator take translate am. Even though we dey try make sure say e correct, abeg no forget say machine translation fit get mistake or no too accurate. Di original docu for di language wey dem first write am na di main correct one. If na important matter, e go better make you use professional human translation. We no go fit take blame for any misunderstanding or wrong interpretation wey fit happen because you use dis translation.