SlideShare a Scribd company logo
1 of 49
Download to read offline
Genetic Algorithm
Alexandre Bergel
University of Chile / Object Profile
http://bergel.eu
http://AgileArtificialIntelligence.github.io
2
Premise of Genetic Algorithm
Natural selection is pioneered by Charles Darwin
(1809-1882), biologist who worked on natural
evolution
“On the Origin of Species by Means of Natural
Selection, or the Preservation of Favoured Races in the
Struggle for Life”, 1859
3
“One general low, leading to the advancement of all
organic beings, namely, vary, let the strongest live
and the weakest die”
— Charles Darwin
4
“Guess the 3-letter word I have in mind”
Secret word: cat
5
“Guess the 3-letter word I have in mind”
“For each try, I tell you the number of correct letters”
Secret word: cat
6
Secret word: cat
“cow”
“poz”
“gaz”
1
0
1
7
gaz
cow
8
Using genetic
operators,
the words are
combined and
some letters are
randomly modified
gaz
cow
gow
caz
9
atc
gozgaz
cow
gow
caz
10
gozgaz
cow
gow
caz
1st generation 2nd generation 3rd generation
atc
Flow chart of an evolution algorithm
11
Selection
Population Parents
Offspring
Reproduction
Replacement
Flow chart of an evolution algorithm
12
Selection
Population Parents
Offspring
Reproduction
Replacement
Many EAs are around:
Ant colony optimization,
Artificial immune system,
Cultural algorithms,
Genetic Algorithm,
Genetic Programming,
Grammatical evolution,
…
Flow chart of a genetic algorithm
13
Yes
Initialize
population
Evaluate fitness
Solution
found?
Selection
Reproduction
No
End
Flow chart of a genetic algorithm
14
Yes
Initialize
population
Evaluate fitness
Solution
found?
Selection
Reproduction
No
End
We create a
set of random 3-letter
words
Flow chart of a genetic algorithm
15
Yes
Initialize
population
Evaluate fitness
Solution
found?
Selection
Reproduction
No
End
Compute the
score of each word
Flow chart of a genetic algorithm
16
Yes
Initialize
population
Evaluate fitness
Solution
found?
Selection
Reproduction
No
End
Do we have a word with
score = 3?
Flow chart of a genetic algorithm
17
Yes
Initialize
population
Evaluate fitness
Solution
found?
Selection
Reproduction
No
End
We take the words that
are close to 3
Flow chart of a genetic algorithm
18
Yes
Initialize
population
Evaluate fitness
Solution
found?
Selection
Reproduction
No
End
We combine and
mutate words to form a new
set of words
Flow chart of a genetic algorithm
19
Yes
Initialize
population
Evaluate fitness
Solution
found?
Selection
Reproduction
No
End
We combine and
mutate words to form a new
set of words
DEMO
Genetic Algorithm in a Nutshell
Evolutionary computation technique that automatically
solves problems without specifying the form or structure
of the solution in advance
Generally speaking, genetic algorithms are simulations
of evolution, using biological genetic operations
Finding ! such as ! is maximal, ! is a tuple of
any arbitrary dimension and domain value, !
x f(x) = y x
y ∈ ℝ
20
Terminology: Individual
An individual represents an element in a population
Each individual has a chromosome, composed of
genes
21
Individual
Gene = index in a chromosome
Allele = value of a gene
Terminology: Population
A population is a set of individuals
Generally, the population size is fixed over time.
Individuals are replaced at each generation, but the
number of individuals remains constants.
All individuals of the population have the same size
22
Terminology: Fitness function
The fitness function evaluates how fit an individual is
The whole idea of genetic algorithm is to search for
the individual that maximizes the fitness function
23
f( ) = y y ∈ ℝ
Example: optimizing a server
Consider a server running in Java
The Java virtual machine, which has over 200 options
What are the options that consume the least amount
of memory to answer HTTP requests
is a set of options, e.g., [ -Xgc:parallel, -ms32m,
-mx200m]
is the amount of memory (in bytes)
is computed by launching the server using the
options and sending 1000 requests
24
f(x) = y
x
y
f(x)
Example: optimizing a server
Consider a server running in Java
The Java virtual machine, which has over 200 options
What are the options that consume the least amount
of memory to answer HTTP requests
is a set of options, e.g., [ -Xgc:parallel, -ms32m,
-mx200m]
is the amount of memory (in bytes)
is computed by launching the server using the
options and sending 1000 requests
25
f(x) = y
x
y
f(x)
We look for the optimal x
that minimize f(x)
Example: space antenna
26
Evolved antenna, produced by
NASA in 2006.
Used in 3 satellites that take
measurement Earth
magnetosphere.
Satellites used this antenna to
communicate with the ground
Example: space antenna
27
f(x) = y
https://ti.arc.nasa.gov/m/pub-archive/1244h/1244%20(Hornby).pdf
forward(length, radius)
rotate-x(angle)
rotate-y(angle)
rotate-z(angle)
voltage and impedance
for radio waves
List of commands:
Example: software testing (1/2)
Randomly testing an application has many
applications:
Finding functional bugs (i.e., which actions crashes my application)

Finding dead code (i.e., which part of my application is not used)
28
f(x) = y
Actions on the user interface
(e.g., pressing a button, entering a
value in the text field, clicking on a
menu)
Number of tested
functionalities
Example: software testing (2/2)
Thanks Lam Research for support this effort!
29
f(x) = y
List of Smalltalk statements
(e.g., sending a message,
creating an object)
Number of tested
functionalities
Example: robot testing
30
f(x) = y
List of random inputs of a robot
state
Number of raised
warning/errors
Flow - chart of a genetic algorithm
31
Yes
Initialize
population
Evaluate fitness
Solution
found?
Selection
Reproduction
No
End
Selection phase
Several selections algorithms have been proposed
The two most popular are
Roulette associates a probability of selection to each individual

Tournament between a set of randomly picked individuals

32
Tournament
The tournament selection algorithm:
1 - Choose few individuals (e.g., 5) at random from
the population (a tournament)
2 - The individual with the best fitness (the winner) is
selected for crossover
The main advantage is to be highly parallelizable
across multiple CPU Cores
33
Flow - chart of a genetic algorithm
34
Yes
Initialize
population
Evaluate fitness
Solution
found?
Selection
Reproduction
No
End
Darwinian Natural Selection
In order to have a natural selection, we need to have:
Heredity: a child receives properties of its parents. In particular, if
the parents are robust and can live long enough, then the child
should too

Variation: some variation may be introduced in children. Children
should not be identical copy of their parents

Selection: some members of a population must have the
opportunity to be parents and have offsprings in order to pass their
genetic information. Typically referred to as “survival of the fittest”
35
https://en.wikipedia.org/wiki/Charles_Darwin#/media/File:Charles_Darwin_seated_crop.jpg
Genetic operators: Crossover
Operations that takes two individuals and produces a
new one, result of a combination
36
Genetic operators: Crossover
Operations that takes two individuals and produces a
new one, result of a combination
37
Gene randomly chosen
Genetic operators: Crossover
Operations that takes two individuals and produces a
new one, result of a combination
38
Genetic operators: Crossover
Operations that takes two individuals and produces a
new one, result of a combination
39
New individual
Genetic operators: Variant of
Crossover
Operations that takes two individuals and produces a
new one, result of a combination
40
Two new individuals
Genetic operators: Mutation
Operations that takes two individuals and produces a
new one, result of a combination
41
Genetic operators: Mutation
Operations that takes two individuals and produces a
new one, result of a combination
42
Gene randomly chosen
Genetic operators: Mutation
Operations that takes two individuals and produces a
new one, result of a combination
43
New random allele
Flow - chart of a genetic algorithm
44
Yes
Initialize
population
Evaluate fitness
Solution
found?
Selection
Reproduction
No
End
Configuring the algorithm
Mutation rate: % to change a gene when creating a
child
Population size: number of individual to consider each
time
Number of genes: how many genes contains each
individual
Fitness function: Function that tells how good / far an
individual is from the (ideal) solution
45
Some benefits of Genetic Algorithm
GA provides a compelling way to not be trapped in
local optima
GA allows optimization of systems in which variables
may be discrete or categorical, and not only
continuous
e.g., direction of a robot or characterization of an antenna segment
GA can be combined with other AI techniques
46
Some benefits of Genetic Algorithm
GA provides a compelling way to not be trapped in
local optima
GA allows optimization of systems in which variables
may be discrete or categorical, and not only
continuous
e.g., direction of a robot or characterization of an antenna segment
GA can be combined with other AI techniques
47
DEMO!
Artificial Intelligence Landscape
GA is often used to solve AI problems in terms of
optimization
GA just need a way to say how good a solution is
Deep learning requires many examples
GA is easy to learn and implements
https://agileartificialintelligence.github.io
48
Artificial Intelligence Landscape
GA is often used to solve AI problems in terms of
optimization
GA just need a way to say how good a solution is
Deep learning requires many examples
GA is easy to learn and implements
https://agileartificialintelligence.github.io
Thanks

More Related Content

What's hot

Genetic Algorithm by Example
Genetic Algorithm by ExampleGenetic Algorithm by Example
Genetic Algorithm by ExampleNobal Niraula
 
GENETIC ALGORITHM
GENETIC ALGORITHMGENETIC ALGORITHM
GENETIC ALGORITHMHarsh Sinha
 
Class GA. Genetic Algorithm,Genetic Algorithm
Class GA. Genetic Algorithm,Genetic AlgorithmClass GA. Genetic Algorithm,Genetic Algorithm
Class GA. Genetic Algorithm,Genetic Algorithmraed albadri
 
Genetic algorithm fitness function
Genetic algorithm fitness functionGenetic algorithm fitness function
Genetic algorithm fitness functionProf Ansari
 
Genetic algorithms
Genetic algorithmsGenetic algorithms
Genetic algorithmsguest9938738
 
Genetic algorithms in Data Mining
Genetic algorithms in Data MiningGenetic algorithms in Data Mining
Genetic algorithms in Data MiningAtul Khanna
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithmJari Abbas
 
Introduction to the Genetic Algorithm
Introduction to the Genetic AlgorithmIntroduction to the Genetic Algorithm
Introduction to the Genetic AlgorithmQiang Hao
 
Evolutionary Algorithms
Evolutionary AlgorithmsEvolutionary Algorithms
Evolutionary AlgorithmsReem Alattas
 
MACHINE LEARNING - GENETIC ALGORITHM
MACHINE LEARNING - GENETIC ALGORITHMMACHINE LEARNING - GENETIC ALGORITHM
MACHINE LEARNING - GENETIC ALGORITHMPuneet Kulyana
 
Genetic algorithm ppt
Genetic algorithm pptGenetic algorithm ppt
Genetic algorithm pptMayank Jain
 
Genetic programming
Genetic programmingGenetic programming
Genetic programmingMeghna Singh
 
Genetic Algorithm
Genetic AlgorithmGenetic Algorithm
Genetic AlgorithmSHIMI S L
 

What's hot (20)

Genetic Algorithm by Example
Genetic Algorithm by ExampleGenetic Algorithm by Example
Genetic Algorithm by Example
 
Genetic Algorithm
Genetic AlgorithmGenetic Algorithm
Genetic Algorithm
 
Soft computing06
Soft computing06Soft computing06
Soft computing06
 
GENETIC ALGORITHM
GENETIC ALGORITHMGENETIC ALGORITHM
GENETIC ALGORITHM
 
Class GA. Genetic Algorithm,Genetic Algorithm
Class GA. Genetic Algorithm,Genetic AlgorithmClass GA. Genetic Algorithm,Genetic Algorithm
Class GA. Genetic Algorithm,Genetic Algorithm
 
Genetic Algorithm
Genetic Algorithm Genetic Algorithm
Genetic Algorithm
 
Genetic Algorithm
Genetic AlgorithmGenetic Algorithm
Genetic Algorithm
 
Genetic algorithm fitness function
Genetic algorithm fitness functionGenetic algorithm fitness function
Genetic algorithm fitness function
 
Genetic algorithms
Genetic algorithmsGenetic algorithms
Genetic algorithms
 
Genetic algorithms in Data Mining
Genetic algorithms in Data MiningGenetic algorithms in Data Mining
Genetic algorithms in Data Mining
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithm
 
Introduction to the Genetic Algorithm
Introduction to the Genetic AlgorithmIntroduction to the Genetic Algorithm
Introduction to the Genetic Algorithm
 
Evolutionary Algorithms
Evolutionary AlgorithmsEvolutionary Algorithms
Evolutionary Algorithms
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithm
 
MACHINE LEARNING - GENETIC ALGORITHM
MACHINE LEARNING - GENETIC ALGORITHMMACHINE LEARNING - GENETIC ALGORITHM
MACHINE LEARNING - GENETIC ALGORITHM
 
Genetic algorithm ppt
Genetic algorithm pptGenetic algorithm ppt
Genetic algorithm ppt
 
Genetic programming
Genetic programmingGenetic programming
Genetic programming
 
Genetic Algorithms
Genetic AlgorithmsGenetic Algorithms
Genetic Algorithms
 
Genetic Algorithm
Genetic AlgorithmGenetic Algorithm
Genetic Algorithm
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithm
 

Similar to Genetic Algorithm

Data Science - Part XIV - Genetic Algorithms
Data Science - Part XIV - Genetic AlgorithmsData Science - Part XIV - Genetic Algorithms
Data Science - Part XIV - Genetic AlgorithmsDerek Kane
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithmRespa Peter
 
Flowchart of GA
Flowchart of GAFlowchart of GA
Flowchart of GAIshucs
 
Genetic-Algorithms.ppt
Genetic-Algorithms.pptGenetic-Algorithms.ppt
Genetic-Algorithms.pptNipun85
 
AI_PPT_Genetic-Algorithms.ppt
AI_PPT_Genetic-Algorithms.pptAI_PPT_Genetic-Algorithms.ppt
AI_PPT_Genetic-Algorithms.pptHotTea
 
Genetic-Algorithms-computersciencepptnew.ppt
Genetic-Algorithms-computersciencepptnew.pptGenetic-Algorithms-computersciencepptnew.ppt
Genetic-Algorithms-computersciencepptnew.pptFitnessfreaksfam
 
Genetic-Algorithms forv artificial .ppt
Genetic-Algorithms forv artificial  .pptGenetic-Algorithms forv artificial  .ppt
Genetic-Algorithms forv artificial .pptneelamsanjeevkumar
 
Genetic-Algorithms for machine learning and ai.ppt
Genetic-Algorithms for machine learning and ai.pptGenetic-Algorithms for machine learning and ai.ppt
Genetic-Algorithms for machine learning and ai.pptneelamsanjeevkumar
 
Genetic-Algorithms.ppt
Genetic-Algorithms.pptGenetic-Algorithms.ppt
Genetic-Algorithms.pptssuser2e437f
 
generic optimization techniques lecture slides
generic optimization techniques  lecture slidesgeneric optimization techniques  lecture slides
generic optimization techniques lecture slidesSardarHamidullah
 
Evolutionary computing - soft computing
Evolutionary computing - soft computingEvolutionary computing - soft computing
Evolutionary computing - soft computingSakshiMahto1
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithmgarima931
 
CSA 3702 machine learning module 4
CSA 3702 machine learning module 4CSA 3702 machine learning module 4
CSA 3702 machine learning module 4Nandhini S
 
Genetic algorithms
Genetic algorithmsGenetic algorithms
Genetic algorithmsAmna Saeed
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithmMegha V
 
Genetic algorithms full lecture
Genetic algorithms full lectureGenetic algorithms full lecture
Genetic algorithms full lecturesadiacs
 

Similar to Genetic Algorithm (20)

Data Science - Part XIV - Genetic Algorithms
Data Science - Part XIV - Genetic AlgorithmsData Science - Part XIV - Genetic Algorithms
Data Science - Part XIV - Genetic Algorithms
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithm
 
Flowchart of GA
Flowchart of GAFlowchart of GA
Flowchart of GA
 
Genetic-Algorithms.ppt
Genetic-Algorithms.pptGenetic-Algorithms.ppt
Genetic-Algorithms.ppt
 
AI_PPT_Genetic-Algorithms.ppt
AI_PPT_Genetic-Algorithms.pptAI_PPT_Genetic-Algorithms.ppt
AI_PPT_Genetic-Algorithms.ppt
 
Genetic-Algorithms-computersciencepptnew.ppt
Genetic-Algorithms-computersciencepptnew.pptGenetic-Algorithms-computersciencepptnew.ppt
Genetic-Algorithms-computersciencepptnew.ppt
 
Genetic-Algorithms forv artificial .ppt
Genetic-Algorithms forv artificial  .pptGenetic-Algorithms forv artificial  .ppt
Genetic-Algorithms forv artificial .ppt
 
Genetic-Algorithms for machine learning and ai.ppt
Genetic-Algorithms for machine learning and ai.pptGenetic-Algorithms for machine learning and ai.ppt
Genetic-Algorithms for machine learning and ai.ppt
 
Genetic-Algorithms.ppt
Genetic-Algorithms.pptGenetic-Algorithms.ppt
Genetic-Algorithms.ppt
 
Genetic Algorithm
Genetic AlgorithmGenetic Algorithm
Genetic Algorithm
 
generic optimization techniques lecture slides
generic optimization techniques  lecture slidesgeneric optimization techniques  lecture slides
generic optimization techniques lecture slides
 
Evolutionary computing - soft computing
Evolutionary computing - soft computingEvolutionary computing - soft computing
Evolutionary computing - soft computing
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithm
 
Gadoc
GadocGadoc
Gadoc
 
Genetic algorithms
Genetic algorithms Genetic algorithms
Genetic algorithms
 
CSA 3702 machine learning module 4
CSA 3702 machine learning module 4CSA 3702 machine learning module 4
CSA 3702 machine learning module 4
 
Genetic algorithms
Genetic algorithmsGenetic algorithms
Genetic algorithms
 
Genetic algorithm
Genetic algorithmGenetic algorithm
Genetic algorithm
 
CI_L02_Optimization_ag2_eng.pdf
CI_L02_Optimization_ag2_eng.pdfCI_L02_Optimization_ag2_eng.pdf
CI_L02_Optimization_ag2_eng.pdf
 
Genetic algorithms full lecture
Genetic algorithms full lectureGenetic algorithms full lecture
Genetic algorithms full lecture
 

More from ESUG

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingESUG
 
Technical documentation support in Pharo
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in PharoESUG
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapESUG
 
Sequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoESUG
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...ESUG
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsESUG
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6ESUG
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationESUG
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingESUG
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesESUG
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportESUG
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsESUG
 
Garbage Collector Tuning
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector TuningESUG
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseESUG
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FutureESUG
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the DebuggerESUG
 
Websockets for Fencing Score
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing ScoreESUG
 
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptESUG
 
Advanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocESUG
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsESUG
 

More from ESUG (20)

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programming
 
Technical documentation support in Pharo
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in Pharo
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and Roadmap
 
Sequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in Pharo
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early results
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test Generation
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic Programming
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience Report
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIs
 
Garbage Collector Tuning
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector Tuning
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and Future
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the Debugger
 
Websockets for Fencing Score
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing Score
 
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
 
Advanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design Mooc
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and Transformations
 

Recently uploaded

Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Recently uploaded (20)

Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Genetic Algorithm

  • 1. Genetic Algorithm Alexandre Bergel University of Chile / Object Profile http://bergel.eu http://AgileArtificialIntelligence.github.io
  • 2. 2
  • 3. Premise of Genetic Algorithm Natural selection is pioneered by Charles Darwin (1809-1882), biologist who worked on natural evolution “On the Origin of Species by Means of Natural Selection, or the Preservation of Favoured Races in the Struggle for Life”, 1859 3 “One general low, leading to the advancement of all organic beings, namely, vary, let the strongest live and the weakest die” — Charles Darwin
  • 4. 4 “Guess the 3-letter word I have in mind” Secret word: cat
  • 5. 5 “Guess the 3-letter word I have in mind” “For each try, I tell you the number of correct letters” Secret word: cat
  • 8. 8 Using genetic operators, the words are combined and some letters are randomly modified gaz cow gow caz
  • 10. 10 gozgaz cow gow caz 1st generation 2nd generation 3rd generation atc
  • 11. Flow chart of an evolution algorithm 11 Selection Population Parents Offspring Reproduction Replacement
  • 12. Flow chart of an evolution algorithm 12 Selection Population Parents Offspring Reproduction Replacement Many EAs are around: Ant colony optimization, Artificial immune system, Cultural algorithms, Genetic Algorithm, Genetic Programming, Grammatical evolution, …
  • 13. Flow chart of a genetic algorithm 13 Yes Initialize population Evaluate fitness Solution found? Selection Reproduction No End
  • 14. Flow chart of a genetic algorithm 14 Yes Initialize population Evaluate fitness Solution found? Selection Reproduction No End We create a set of random 3-letter words
  • 15. Flow chart of a genetic algorithm 15 Yes Initialize population Evaluate fitness Solution found? Selection Reproduction No End Compute the score of each word
  • 16. Flow chart of a genetic algorithm 16 Yes Initialize population Evaluate fitness Solution found? Selection Reproduction No End Do we have a word with score = 3?
  • 17. Flow chart of a genetic algorithm 17 Yes Initialize population Evaluate fitness Solution found? Selection Reproduction No End We take the words that are close to 3
  • 18. Flow chart of a genetic algorithm 18 Yes Initialize population Evaluate fitness Solution found? Selection Reproduction No End We combine and mutate words to form a new set of words
  • 19. Flow chart of a genetic algorithm 19 Yes Initialize population Evaluate fitness Solution found? Selection Reproduction No End We combine and mutate words to form a new set of words DEMO
  • 20. Genetic Algorithm in a Nutshell Evolutionary computation technique that automatically solves problems without specifying the form or structure of the solution in advance Generally speaking, genetic algorithms are simulations of evolution, using biological genetic operations Finding ! such as ! is maximal, ! is a tuple of any arbitrary dimension and domain value, ! x f(x) = y x y ∈ ℝ 20
  • 21. Terminology: Individual An individual represents an element in a population Each individual has a chromosome, composed of genes 21 Individual Gene = index in a chromosome Allele = value of a gene
  • 22. Terminology: Population A population is a set of individuals Generally, the population size is fixed over time. Individuals are replaced at each generation, but the number of individuals remains constants. All individuals of the population have the same size 22
  • 23. Terminology: Fitness function The fitness function evaluates how fit an individual is The whole idea of genetic algorithm is to search for the individual that maximizes the fitness function 23 f( ) = y y ∈ ℝ
  • 24. Example: optimizing a server Consider a server running in Java The Java virtual machine, which has over 200 options What are the options that consume the least amount of memory to answer HTTP requests is a set of options, e.g., [ -Xgc:parallel, -ms32m, -mx200m] is the amount of memory (in bytes) is computed by launching the server using the options and sending 1000 requests 24 f(x) = y x y f(x)
  • 25. Example: optimizing a server Consider a server running in Java The Java virtual machine, which has over 200 options What are the options that consume the least amount of memory to answer HTTP requests is a set of options, e.g., [ -Xgc:parallel, -ms32m, -mx200m] is the amount of memory (in bytes) is computed by launching the server using the options and sending 1000 requests 25 f(x) = y x y f(x) We look for the optimal x that minimize f(x)
  • 26. Example: space antenna 26 Evolved antenna, produced by NASA in 2006. Used in 3 satellites that take measurement Earth magnetosphere. Satellites used this antenna to communicate with the ground
  • 27. Example: space antenna 27 f(x) = y https://ti.arc.nasa.gov/m/pub-archive/1244h/1244%20(Hornby).pdf forward(length, radius) rotate-x(angle) rotate-y(angle) rotate-z(angle) voltage and impedance for radio waves List of commands:
  • 28. Example: software testing (1/2) Randomly testing an application has many applications: Finding functional bugs (i.e., which actions crashes my application) Finding dead code (i.e., which part of my application is not used) 28 f(x) = y Actions on the user interface (e.g., pressing a button, entering a value in the text field, clicking on a menu) Number of tested functionalities
  • 29. Example: software testing (2/2) Thanks Lam Research for support this effort! 29 f(x) = y List of Smalltalk statements (e.g., sending a message, creating an object) Number of tested functionalities
  • 30. Example: robot testing 30 f(x) = y List of random inputs of a robot state Number of raised warning/errors
  • 31. Flow - chart of a genetic algorithm 31 Yes Initialize population Evaluate fitness Solution found? Selection Reproduction No End
  • 32. Selection phase Several selections algorithms have been proposed The two most popular are Roulette associates a probability of selection to each individual Tournament between a set of randomly picked individuals 32
  • 33. Tournament The tournament selection algorithm: 1 - Choose few individuals (e.g., 5) at random from the population (a tournament) 2 - The individual with the best fitness (the winner) is selected for crossover The main advantage is to be highly parallelizable across multiple CPU Cores 33
  • 34. Flow - chart of a genetic algorithm 34 Yes Initialize population Evaluate fitness Solution found? Selection Reproduction No End
  • 35. Darwinian Natural Selection In order to have a natural selection, we need to have: Heredity: a child receives properties of its parents. In particular, if the parents are robust and can live long enough, then the child should too Variation: some variation may be introduced in children. Children should not be identical copy of their parents Selection: some members of a population must have the opportunity to be parents and have offsprings in order to pass their genetic information. Typically referred to as “survival of the fittest” 35 https://en.wikipedia.org/wiki/Charles_Darwin#/media/File:Charles_Darwin_seated_crop.jpg
  • 36. Genetic operators: Crossover Operations that takes two individuals and produces a new one, result of a combination 36
  • 37. Genetic operators: Crossover Operations that takes two individuals and produces a new one, result of a combination 37 Gene randomly chosen
  • 38. Genetic operators: Crossover Operations that takes two individuals and produces a new one, result of a combination 38
  • 39. Genetic operators: Crossover Operations that takes two individuals and produces a new one, result of a combination 39 New individual
  • 40. Genetic operators: Variant of Crossover Operations that takes two individuals and produces a new one, result of a combination 40 Two new individuals
  • 41. Genetic operators: Mutation Operations that takes two individuals and produces a new one, result of a combination 41
  • 42. Genetic operators: Mutation Operations that takes two individuals and produces a new one, result of a combination 42 Gene randomly chosen
  • 43. Genetic operators: Mutation Operations that takes two individuals and produces a new one, result of a combination 43 New random allele
  • 44. Flow - chart of a genetic algorithm 44 Yes Initialize population Evaluate fitness Solution found? Selection Reproduction No End
  • 45. Configuring the algorithm Mutation rate: % to change a gene when creating a child Population size: number of individual to consider each time Number of genes: how many genes contains each individual Fitness function: Function that tells how good / far an individual is from the (ideal) solution 45
  • 46. Some benefits of Genetic Algorithm GA provides a compelling way to not be trapped in local optima GA allows optimization of systems in which variables may be discrete or categorical, and not only continuous e.g., direction of a robot or characterization of an antenna segment GA can be combined with other AI techniques 46
  • 47. Some benefits of Genetic Algorithm GA provides a compelling way to not be trapped in local optima GA allows optimization of systems in which variables may be discrete or categorical, and not only continuous e.g., direction of a robot or characterization of an antenna segment GA can be combined with other AI techniques 47 DEMO!
  • 48. Artificial Intelligence Landscape GA is often used to solve AI problems in terms of optimization GA just need a way to say how good a solution is Deep learning requires many examples GA is easy to learn and implements https://agileartificialintelligence.github.io 48
  • 49. Artificial Intelligence Landscape GA is often used to solve AI problems in terms of optimization GA just need a way to say how good a solution is Deep learning requires many examples GA is easy to learn and implements https://agileartificialintelligence.github.io Thanks