SlideShare a Scribd company logo
1
Genetic Algorithms
CS 561 2
How do you find a solution in a large complex space?
• Ask an expert?
• Adapt existing designs?
• Trial and error?
CS 561 3
Example: Traveling Sales Person (TSP)
• Classic Example: You have N cities, find the shortest route such
that your salesperson will visit each city once and return.
• This problem is known to be NP-Hard
• As a new city is added to the problem, computation time in the classic
solution increases exponentially O(2n
) … (as far as we know)
Dallas
Houston
San Antonio
Austin
Mos Eisley
Is this the shortest path???
A Texas Sales Person
What if………
• Lets create a whole bunch of random sales people and see how
well they do and pick the best one(s).
• Salesperson A
• Houston -> Dallas -> Austin -> San Antonio -> Mos Eisely
• Distance Traveled 780 Km
• Salesperson B
• Houston -> Mos Eisley -> Austin -> San Antonio -> Dallas
• Distance Traveled 820 Km
• Salesperson A is better (more fit) than salesperson B
• Perhaps we would like sales people to be more like A and less like B
• Question:
• do we want to just keep picking random sales people like this and keep
testing them?
CS 561 4
We can get a little closer to the solution in polynomial time
• We might use a heuristic(s) to guide us in creating new sales
people
• So for instance, we might use the triangle inequality to help pick better potential
sales people.
• One can create an initial 2 approximation (at worst the distance is twice the
optimal distance) to TSP using a Nearest Neighbor or other similar efficient
polynomial time method.
• This detail is somewhat unimportant, you can use all kinds of heuristics to help
you create a better initial set of sales people [e.g. Match Twice and Stitch
(Kahng, Reda 2004)].
• Use some sort of incremental improvement make them better
successively.
• The idea is that you start with result(s) closer to where you think the solution is
than one would obtain at random so that the problem converges more quickly.
• Be careful since an initial approximation may be too close to a local extrema
which might actually slow down convergence or throw the solution off.
CS 561 5
However…………
• Sales person A is better than sales person B, but we can imagine
that is would be easy to create a sales person C who is even better.
• We don’t want to create 2n
sales people!
• This is a lecture about genetic algorithms (GA), <sarcasm> what
kind of solution will we use?</sarcasm>
• Should we try a genetic algorithm solution???
• Really? Are you sure? Maybe we should try something else
• It might be that you would prefer another solution
• I mean it might not be a bad idea
- You might learn something new
- However it might not be all the exciting
- I’m kind of not sure
- My mother suggested that I should do something else
- But at any rate I suppose you would like to get on with it
- Ok if you insist, but it’s all on your hands!
CS 561 6
Randomly inserted image
for no reason at all
CS 561 7
Represent problem like a DNA sequence
San Antonio
Dallas
Mos Eisely
Houston
Austin
Dallas
Houston
Mos Eisely
San Antonio
Austin
Each DNA sequence is a
possible solution to the
problem.
DNA - Salesperson A
DNA - Salesperson B
The order of the cities in
the genes is the order of
the cities the TSP will take.
CS 561 8
Ranking by Fitness:
Here we’ve created three
different salespeople. We
then checked to see how
far each one has to travel.
This gives us a measure of
“Fitness”
Note: we need to be able to
measure fitness in polynomial
time, otherwise we are in
trouble.
Travels Shortest Distance
Let’s breed them!
• We have a population of traveling sales people. We also know their
fitness based on how long their trip is. We want to create more, but
we don’t want to create too many.
• We take the notion that the salespeople who perform better are
closer to the optimal salesperson than the ones which performed
more poorly. Could the optimal sales person be a “combination” of
the better sales people?
• We create a population of sales people as solutions to the problem.
• How do we actually mate a population of data???
CS 561 9
CS 561 10
Crossover:
Exchanging information through some part of information (representation)
Once we have found the best sales
people we will in a sense mate
them. We can do this in several
ways. Better sales people should
mate more often and poor sales
people should mate lest often.
Sales People City DNA
Parent 1 F A B | E C G D
Parent 2 D E A | C G B F
Child 1 F A B | C G B F
Child 2 D E A | E C G D
Sales person A (parent 1)
Sales person B (parent 2)
Sales person C (child 1)
Sales person D (child 2)
Crossover Bounds (Houston we have a problem)
• Not all crossed pairs are viable. We can only visit a city once.
• Different GA problems may have different bounds.
CS 561 11
San
Antonio
Dallas
Mos Eisely
Houston
Austin
Dallas
Houston
Austin
San
Antonio
Mos Eisely
Dallas
Houston
Mos Eisely
Houston
Austin
San
Antonio
Dallas
Austin
San
Antonio
Mos Eisely
Parents Children
Not Viable!!
TSP needs some special rules for crossover
• Many GA problems also need special crossover rules.
• Since each genetic sequence contains all the cities in the travel,
crossover is a swapping of travel order.
• Remember that crossover also needs to be efficient.
CS 561 12
San
Antonio
Dallas
Mos Eisely
Houston
Austin
Dallas
Mos Eisely
Houston
San
Antonio
Austin
San
Antonio
Dallas
Houston
Austin
Mos Eisely
Parents Children
Viable 
Dallas
Houston
Austin
San
Antonio
Mos Eisely
What about local extrema?
• With just crossover breading, we are constrained to gene
sequences which are a cross product of our current population.
• Introduce random effects into our population.
• Mutation – Randomly twiddle the genes with some probability.
• Cataclysm – Kill off n% of your population and create fresh new
salespeople if it looks like you are reaching a local minimum.
• Annealing of Mating Pairs – Accept the mating of suboptimal pairs with
some probability.
• Etc…
CS 561 13
CS 561 14
In summation: The GA Cycle
Fitness
Selection
Crossover
Mutation
New Population
GA and TSP: the claims
• Can solve for over 3500 cities (still took over 1 CPU years).
• Maybe holds the record.
• Will get within 2% of the optimal solution.
• This means that it’s not a solution per se, but is an approximation.
CS 561 15
GA Discussion
• We can apply the GA solution to any problem where the we can
represent the problems solution (even very abstractly) as a string.
• We can create strings of:
• Digits
• Labels
• Pointers
• Code Blocks – This creates new programs from strung together blocks
of code. The key is to make sure the code can run.
• Whole Programs – Modules or complete programs can be strung
together in a series. We can also re-arrange the linkages between
programs.
• The last two are examples of Genetic Programming
CS 561 16
Things to consider
• How large is your population?
• A large population will take more time to run (you have to test each
member for fitness!).
• A large population will cover more bases at once.
• How do you select your initial population?
• You might create a population of approximate solutions. However, some
approximations might start you in the wrong position with too much
bias.
• How will you cross bread your population?
• You want to cross bread and select for your best specimens.
• Too strict: You will tend towards local minima
• Too lax: Your problem will converge slower
• How will you mutate your population?
• Too little: your problem will tend to get stuck in local minima
• Too much: your population will fill with noise and not settle.
CS 561 17
GA is a good no clue approach to problem solving
• GA is superb if:
• Your space is loaded with lots of weird bumps and local minima.
• GA tends to spread out and test a larger subset of your space than many
other types of learning/optimization algorithms.
• You don’t quite understand the underlying process of your problem
space.
• NO I DONT: What makes the stock market work??? Don’t know? Me neither!
Stock market prediction might thus be good for a GA.
• YES I DO: Want to make a program to predict people’s height from
personality factors? This might be a Gaussian process and a good candidate
for statistical methods which are more efficient.
• You have lots of processors
• GA’s parallelize very easily!
CS 561 18
Why not use GA?
• Creating generations of samples and cross breading them can be
resource intensive.
• Some problems may be better solved by a general gradient descent
method which uses less resource.
• However, resource-wise, GA is still quite efficient (no computation of
derivatives, etc).
• In general if you know the mathematics, shape or underlying
process of your problem space, there may be a better solution
designed for your specific need.
• Consider Kernel Based Learning and Support Vector Machines?
• Consider Neural Networks?
• Consider Traditional Polynomial Time Algorithms?
• Etc.
CS 561 19
Ad

More Related Content

Similar to Overview of Genetic Algorithms in Computer Science (20)

02LocalSearch.pdf
02LocalSearch.pdf02LocalSearch.pdf
02LocalSearch.pdf
vijaykumar95844
 
Estimation Games – Pascal Van Cauwenberghe
Estimation Games – Pascal Van CauwenbergheEstimation Games – Pascal Van Cauwenberghe
Estimation Games – Pascal Van Cauwenberghe
Agile Tour Beirut
 
Scaling: Old ideas & some new ones....
Scaling: Old ideas & some new ones....Scaling: Old ideas & some new ones....
Scaling: Old ideas & some new ones....
LeanAgileTraining
 
Introduction to Genetic Algorithms 2014
Introduction to Genetic Algorithms 2014Introduction to Genetic Algorithms 2014
Introduction to Genetic Algorithms 2014
Aleksander Stensby
 
Tips and tricks to win kaggle data science competitions
Tips and tricks to win kaggle data science competitionsTips and tricks to win kaggle data science competitions
Tips and tricks to win kaggle data science competitions
Darius Barušauskas
 
Why dashboard design should be (but usually never is) based on cognitive scie...
Why dashboard design should be (but usually never is) based on cognitive scie...Why dashboard design should be (but usually never is) based on cognitive scie...
Why dashboard design should be (but usually never is) based on cognitive scie...
UXPA International
 
DevOps Enterprise Summit Las Vegas 2018: The Problem of Becoming a 3rd-Line S...
DevOps Enterprise Summit Las Vegas 2018: The Problem of Becoming a 3rd-Line S...DevOps Enterprise Summit Las Vegas 2018: The Problem of Becoming a 3rd-Line S...
DevOps Enterprise Summit Las Vegas 2018: The Problem of Becoming a 3rd-Line S...
Jon Stevens-Hall
 
Geneticalgorithms 100403002207-phpapp02
Geneticalgorithms 100403002207-phpapp02Geneticalgorithms 100403002207-phpapp02
Geneticalgorithms 100403002207-phpapp02
Amna Saeed
 
probability.pptx
probability.pptxprobability.pptx
probability.pptx
bisan3
 
Data oriented design and c++
Data oriented design and c++Data oriented design and c++
Data oriented design and c++
Mike Acton
 
Learn to Think Like a Coder
Learn to Think Like a CoderLearn to Think Like a Coder
Learn to Think Like a Coder
Andrew Marks
 
Customer satisfaction for co.opmart’s customer service in ho chi minh
Customer satisfaction for co.opmart’s customer service in ho chi minhCustomer satisfaction for co.opmart’s customer service in ho chi minh
Customer satisfaction for co.opmart’s customer service in ho chi minh
Hỗ Trợ SPSS
 
BrightonSEO - How to do ecommerce keyword research at huge scale
BrightonSEO - How to do ecommerce keyword research at huge scaleBrightonSEO - How to do ecommerce keyword research at huge scale
BrightonSEO - How to do ecommerce keyword research at huge scale
Patrick Reinhart
 
Distributed processing of large graphs in python
Distributed processing of large graphs in pythonDistributed processing of large graphs in python
Distributed processing of large graphs in python
Jose Quesada (hiring)
 
Data Con LA 2022 - Real world consumer segmentation
Data Con LA 2022 - Real world consumer segmentationData Con LA 2022 - Real world consumer segmentation
Data Con LA 2022 - Real world consumer segmentation
Data Con LA
 
MLSEV. Machine Learning: Business Perspective
MLSEV. Machine Learning: Business PerspectiveMLSEV. Machine Learning: Business Perspective
MLSEV. Machine Learning: Business Perspective
BigML, Inc
 
SaaStr Workshop Wednesdays: Territory Assignment Innovation: High-Velocity Te...
SaaStr Workshop Wednesdays: Territory Assignment Innovation: High-Velocity Te...SaaStr Workshop Wednesdays: Territory Assignment Innovation: High-Velocity Te...
SaaStr Workshop Wednesdays: Territory Assignment Innovation: High-Velocity Te...
saastr
 
Why Code Is Cool (And Why You Should Learn It)
Why Code Is Cool (And Why You Should Learn It)Why Code Is Cool (And Why You Should Learn It)
Why Code Is Cool (And Why You Should Learn It)
Andrew Marks
 
Scrum Coach : Estimation
Scrum Coach : EstimationScrum Coach : Estimation
Scrum Coach : Estimation
Anis Bouhachem Djer
 
Explainable AI
Explainable AIExplainable AI
Explainable AI
Wagston Staehler
 
Estimation Games – Pascal Van Cauwenberghe
Estimation Games – Pascal Van CauwenbergheEstimation Games – Pascal Van Cauwenberghe
Estimation Games – Pascal Van Cauwenberghe
Agile Tour Beirut
 
Scaling: Old ideas & some new ones....
Scaling: Old ideas & some new ones....Scaling: Old ideas & some new ones....
Scaling: Old ideas & some new ones....
LeanAgileTraining
 
Introduction to Genetic Algorithms 2014
Introduction to Genetic Algorithms 2014Introduction to Genetic Algorithms 2014
Introduction to Genetic Algorithms 2014
Aleksander Stensby
 
Tips and tricks to win kaggle data science competitions
Tips and tricks to win kaggle data science competitionsTips and tricks to win kaggle data science competitions
Tips and tricks to win kaggle data science competitions
Darius Barušauskas
 
Why dashboard design should be (but usually never is) based on cognitive scie...
Why dashboard design should be (but usually never is) based on cognitive scie...Why dashboard design should be (but usually never is) based on cognitive scie...
Why dashboard design should be (but usually never is) based on cognitive scie...
UXPA International
 
DevOps Enterprise Summit Las Vegas 2018: The Problem of Becoming a 3rd-Line S...
DevOps Enterprise Summit Las Vegas 2018: The Problem of Becoming a 3rd-Line S...DevOps Enterprise Summit Las Vegas 2018: The Problem of Becoming a 3rd-Line S...
DevOps Enterprise Summit Las Vegas 2018: The Problem of Becoming a 3rd-Line S...
Jon Stevens-Hall
 
Geneticalgorithms 100403002207-phpapp02
Geneticalgorithms 100403002207-phpapp02Geneticalgorithms 100403002207-phpapp02
Geneticalgorithms 100403002207-phpapp02
Amna Saeed
 
probability.pptx
probability.pptxprobability.pptx
probability.pptx
bisan3
 
Data oriented design and c++
Data oriented design and c++Data oriented design and c++
Data oriented design and c++
Mike Acton
 
Learn to Think Like a Coder
Learn to Think Like a CoderLearn to Think Like a Coder
Learn to Think Like a Coder
Andrew Marks
 
Customer satisfaction for co.opmart’s customer service in ho chi minh
Customer satisfaction for co.opmart’s customer service in ho chi minhCustomer satisfaction for co.opmart’s customer service in ho chi minh
Customer satisfaction for co.opmart’s customer service in ho chi minh
Hỗ Trợ SPSS
 
BrightonSEO - How to do ecommerce keyword research at huge scale
BrightonSEO - How to do ecommerce keyword research at huge scaleBrightonSEO - How to do ecommerce keyword research at huge scale
BrightonSEO - How to do ecommerce keyword research at huge scale
Patrick Reinhart
 
Distributed processing of large graphs in python
Distributed processing of large graphs in pythonDistributed processing of large graphs in python
Distributed processing of large graphs in python
Jose Quesada (hiring)
 
Data Con LA 2022 - Real world consumer segmentation
Data Con LA 2022 - Real world consumer segmentationData Con LA 2022 - Real world consumer segmentation
Data Con LA 2022 - Real world consumer segmentation
Data Con LA
 
MLSEV. Machine Learning: Business Perspective
MLSEV. Machine Learning: Business PerspectiveMLSEV. Machine Learning: Business Perspective
MLSEV. Machine Learning: Business Perspective
BigML, Inc
 
SaaStr Workshop Wednesdays: Territory Assignment Innovation: High-Velocity Te...
SaaStr Workshop Wednesdays: Territory Assignment Innovation: High-Velocity Te...SaaStr Workshop Wednesdays: Territory Assignment Innovation: High-Velocity Te...
SaaStr Workshop Wednesdays: Territory Assignment Innovation: High-Velocity Te...
saastr
 
Why Code Is Cool (And Why You Should Learn It)
Why Code Is Cool (And Why You Should Learn It)Why Code Is Cool (And Why You Should Learn It)
Why Code Is Cool (And Why You Should Learn It)
Andrew Marks
 

Recently uploaded (20)

AI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamsonAI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamson
UXPA Boston
 
Dark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanizationDark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanization
Jakub Šimek
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Maarten Verwaest
 
Right to liberty and security of a person.pdf
Right to liberty and security of a person.pdfRight to liberty and security of a person.pdf
Right to liberty and security of a person.pdf
danielbraico197
 
ICDCC 2025: Securing Agentic AI - Eryk Budi Pratama.pdf
ICDCC 2025: Securing Agentic AI - Eryk Budi Pratama.pdfICDCC 2025: Securing Agentic AI - Eryk Budi Pratama.pdf
ICDCC 2025: Securing Agentic AI - Eryk Budi Pratama.pdf
Eryk Budi Pratama
 
Longitudinal Benchmark: A Real-World UX Case Study in Onboarding by Linda Bor...
Longitudinal Benchmark: A Real-World UX Case Study in Onboarding by Linda Bor...Longitudinal Benchmark: A Real-World UX Case Study in Onboarding by Linda Bor...
Longitudinal Benchmark: A Real-World UX Case Study in Onboarding by Linda Bor...
UXPA Boston
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
In-App Guidance_ Save Enterprises Millions in Training & IT Costs.pptx
In-App Guidance_ Save Enterprises Millions in Training & IT Costs.pptxIn-App Guidance_ Save Enterprises Millions in Training & IT Costs.pptx
In-App Guidance_ Save Enterprises Millions in Training & IT Costs.pptx
aptyai
 
Secondary Storage for a microcontroller system
Secondary Storage for a microcontroller systemSecondary Storage for a microcontroller system
Secondary Storage for a microcontroller system
fizarcse
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
Build With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdfBuild With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdf
Google Developer Group - Harare
 
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
Toru Tamaki
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
OpenAI Just Announced Codex: A cloud engineering agent that excels in handlin...
OpenAI Just Announced Codex: A cloud engineering agent that excels in handlin...OpenAI Just Announced Codex: A cloud engineering agent that excels in handlin...
OpenAI Just Announced Codex: A cloud engineering agent that excels in handlin...
SOFTTECHHUB
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More MachinesRefactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Leon Anavi
 
How Top Companies Benefit from Outsourcing
How Top Companies Benefit from OutsourcingHow Top Companies Benefit from Outsourcing
How Top Companies Benefit from Outsourcing
Nascenture
 
Top 5 Qualities to Look for in Salesforce Partners in 2025
Top 5 Qualities to Look for in Salesforce Partners in 2025Top 5 Qualities to Look for in Salesforce Partners in 2025
Top 5 Qualities to Look for in Salesforce Partners in 2025
Damco Salesforce Services
 
Harmonizing Multi-Agent Intelligence | Open Data Science Conference | Gary Ar...
Harmonizing Multi-Agent Intelligence | Open Data Science Conference | Gary Ar...Harmonizing Multi-Agent Intelligence | Open Data Science Conference | Gary Ar...
Harmonizing Multi-Agent Intelligence | Open Data Science Conference | Gary Ar...
Gary Arora
 
AI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamsonAI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamson
UXPA Boston
 
Dark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanizationDark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanization
Jakub Šimek
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Maarten Verwaest
 
Right to liberty and security of a person.pdf
Right to liberty and security of a person.pdfRight to liberty and security of a person.pdf
Right to liberty and security of a person.pdf
danielbraico197
 
ICDCC 2025: Securing Agentic AI - Eryk Budi Pratama.pdf
ICDCC 2025: Securing Agentic AI - Eryk Budi Pratama.pdfICDCC 2025: Securing Agentic AI - Eryk Budi Pratama.pdf
ICDCC 2025: Securing Agentic AI - Eryk Budi Pratama.pdf
Eryk Budi Pratama
 
Longitudinal Benchmark: A Real-World UX Case Study in Onboarding by Linda Bor...
Longitudinal Benchmark: A Real-World UX Case Study in Onboarding by Linda Bor...Longitudinal Benchmark: A Real-World UX Case Study in Onboarding by Linda Bor...
Longitudinal Benchmark: A Real-World UX Case Study in Onboarding by Linda Bor...
UXPA Boston
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
In-App Guidance_ Save Enterprises Millions in Training & IT Costs.pptx
In-App Guidance_ Save Enterprises Millions in Training & IT Costs.pptxIn-App Guidance_ Save Enterprises Millions in Training & IT Costs.pptx
In-App Guidance_ Save Enterprises Millions in Training & IT Costs.pptx
aptyai
 
Secondary Storage for a microcontroller system
Secondary Storage for a microcontroller systemSecondary Storage for a microcontroller system
Secondary Storage for a microcontroller system
fizarcse
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
Toru Tamaki
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
OpenAI Just Announced Codex: A cloud engineering agent that excels in handlin...
OpenAI Just Announced Codex: A cloud engineering agent that excels in handlin...OpenAI Just Announced Codex: A cloud engineering agent that excels in handlin...
OpenAI Just Announced Codex: A cloud engineering agent that excels in handlin...
SOFTTECHHUB
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More MachinesRefactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Leon Anavi
 
How Top Companies Benefit from Outsourcing
How Top Companies Benefit from OutsourcingHow Top Companies Benefit from Outsourcing
How Top Companies Benefit from Outsourcing
Nascenture
 
Top 5 Qualities to Look for in Salesforce Partners in 2025
Top 5 Qualities to Look for in Salesforce Partners in 2025Top 5 Qualities to Look for in Salesforce Partners in 2025
Top 5 Qualities to Look for in Salesforce Partners in 2025
Damco Salesforce Services
 
Harmonizing Multi-Agent Intelligence | Open Data Science Conference | Gary Ar...
Harmonizing Multi-Agent Intelligence | Open Data Science Conference | Gary Ar...Harmonizing Multi-Agent Intelligence | Open Data Science Conference | Gary Ar...
Harmonizing Multi-Agent Intelligence | Open Data Science Conference | Gary Ar...
Gary Arora
 
Ad

Overview of Genetic Algorithms in Computer Science

  • 2. CS 561 2 How do you find a solution in a large complex space? • Ask an expert? • Adapt existing designs? • Trial and error?
  • 3. CS 561 3 Example: Traveling Sales Person (TSP) • Classic Example: You have N cities, find the shortest route such that your salesperson will visit each city once and return. • This problem is known to be NP-Hard • As a new city is added to the problem, computation time in the classic solution increases exponentially O(2n ) … (as far as we know) Dallas Houston San Antonio Austin Mos Eisley Is this the shortest path??? A Texas Sales Person
  • 4. What if……… • Lets create a whole bunch of random sales people and see how well they do and pick the best one(s). • Salesperson A • Houston -> Dallas -> Austin -> San Antonio -> Mos Eisely • Distance Traveled 780 Km • Salesperson B • Houston -> Mos Eisley -> Austin -> San Antonio -> Dallas • Distance Traveled 820 Km • Salesperson A is better (more fit) than salesperson B • Perhaps we would like sales people to be more like A and less like B • Question: • do we want to just keep picking random sales people like this and keep testing them? CS 561 4
  • 5. We can get a little closer to the solution in polynomial time • We might use a heuristic(s) to guide us in creating new sales people • So for instance, we might use the triangle inequality to help pick better potential sales people. • One can create an initial 2 approximation (at worst the distance is twice the optimal distance) to TSP using a Nearest Neighbor or other similar efficient polynomial time method. • This detail is somewhat unimportant, you can use all kinds of heuristics to help you create a better initial set of sales people [e.g. Match Twice and Stitch (Kahng, Reda 2004)]. • Use some sort of incremental improvement make them better successively. • The idea is that you start with result(s) closer to where you think the solution is than one would obtain at random so that the problem converges more quickly. • Be careful since an initial approximation may be too close to a local extrema which might actually slow down convergence or throw the solution off. CS 561 5
  • 6. However………… • Sales person A is better than sales person B, but we can imagine that is would be easy to create a sales person C who is even better. • We don’t want to create 2n sales people! • This is a lecture about genetic algorithms (GA), <sarcasm> what kind of solution will we use?</sarcasm> • Should we try a genetic algorithm solution??? • Really? Are you sure? Maybe we should try something else • It might be that you would prefer another solution • I mean it might not be a bad idea - You might learn something new - However it might not be all the exciting - I’m kind of not sure - My mother suggested that I should do something else - But at any rate I suppose you would like to get on with it - Ok if you insist, but it’s all on your hands! CS 561 6 Randomly inserted image for no reason at all
  • 7. CS 561 7 Represent problem like a DNA sequence San Antonio Dallas Mos Eisely Houston Austin Dallas Houston Mos Eisely San Antonio Austin Each DNA sequence is a possible solution to the problem. DNA - Salesperson A DNA - Salesperson B The order of the cities in the genes is the order of the cities the TSP will take.
  • 8. CS 561 8 Ranking by Fitness: Here we’ve created three different salespeople. We then checked to see how far each one has to travel. This gives us a measure of “Fitness” Note: we need to be able to measure fitness in polynomial time, otherwise we are in trouble. Travels Shortest Distance
  • 9. Let’s breed them! • We have a population of traveling sales people. We also know their fitness based on how long their trip is. We want to create more, but we don’t want to create too many. • We take the notion that the salespeople who perform better are closer to the optimal salesperson than the ones which performed more poorly. Could the optimal sales person be a “combination” of the better sales people? • We create a population of sales people as solutions to the problem. • How do we actually mate a population of data??? CS 561 9
  • 10. CS 561 10 Crossover: Exchanging information through some part of information (representation) Once we have found the best sales people we will in a sense mate them. We can do this in several ways. Better sales people should mate more often and poor sales people should mate lest often. Sales People City DNA Parent 1 F A B | E C G D Parent 2 D E A | C G B F Child 1 F A B | C G B F Child 2 D E A | E C G D Sales person A (parent 1) Sales person B (parent 2) Sales person C (child 1) Sales person D (child 2)
  • 11. Crossover Bounds (Houston we have a problem) • Not all crossed pairs are viable. We can only visit a city once. • Different GA problems may have different bounds. CS 561 11 San Antonio Dallas Mos Eisely Houston Austin Dallas Houston Austin San Antonio Mos Eisely Dallas Houston Mos Eisely Houston Austin San Antonio Dallas Austin San Antonio Mos Eisely Parents Children Not Viable!!
  • 12. TSP needs some special rules for crossover • Many GA problems also need special crossover rules. • Since each genetic sequence contains all the cities in the travel, crossover is a swapping of travel order. • Remember that crossover also needs to be efficient. CS 561 12 San Antonio Dallas Mos Eisely Houston Austin Dallas Mos Eisely Houston San Antonio Austin San Antonio Dallas Houston Austin Mos Eisely Parents Children Viable  Dallas Houston Austin San Antonio Mos Eisely
  • 13. What about local extrema? • With just crossover breading, we are constrained to gene sequences which are a cross product of our current population. • Introduce random effects into our population. • Mutation – Randomly twiddle the genes with some probability. • Cataclysm – Kill off n% of your population and create fresh new salespeople if it looks like you are reaching a local minimum. • Annealing of Mating Pairs – Accept the mating of suboptimal pairs with some probability. • Etc… CS 561 13
  • 14. CS 561 14 In summation: The GA Cycle Fitness Selection Crossover Mutation New Population
  • 15. GA and TSP: the claims • Can solve for over 3500 cities (still took over 1 CPU years). • Maybe holds the record. • Will get within 2% of the optimal solution. • This means that it’s not a solution per se, but is an approximation. CS 561 15
  • 16. GA Discussion • We can apply the GA solution to any problem where the we can represent the problems solution (even very abstractly) as a string. • We can create strings of: • Digits • Labels • Pointers • Code Blocks – This creates new programs from strung together blocks of code. The key is to make sure the code can run. • Whole Programs – Modules or complete programs can be strung together in a series. We can also re-arrange the linkages between programs. • The last two are examples of Genetic Programming CS 561 16
  • 17. Things to consider • How large is your population? • A large population will take more time to run (you have to test each member for fitness!). • A large population will cover more bases at once. • How do you select your initial population? • You might create a population of approximate solutions. However, some approximations might start you in the wrong position with too much bias. • How will you cross bread your population? • You want to cross bread and select for your best specimens. • Too strict: You will tend towards local minima • Too lax: Your problem will converge slower • How will you mutate your population? • Too little: your problem will tend to get stuck in local minima • Too much: your population will fill with noise and not settle. CS 561 17
  • 18. GA is a good no clue approach to problem solving • GA is superb if: • Your space is loaded with lots of weird bumps and local minima. • GA tends to spread out and test a larger subset of your space than many other types of learning/optimization algorithms. • You don’t quite understand the underlying process of your problem space. • NO I DONT: What makes the stock market work??? Don’t know? Me neither! Stock market prediction might thus be good for a GA. • YES I DO: Want to make a program to predict people’s height from personality factors? This might be a Gaussian process and a good candidate for statistical methods which are more efficient. • You have lots of processors • GA’s parallelize very easily! CS 561 18
  • 19. Why not use GA? • Creating generations of samples and cross breading them can be resource intensive. • Some problems may be better solved by a general gradient descent method which uses less resource. • However, resource-wise, GA is still quite efficient (no computation of derivatives, etc). • In general if you know the mathematics, shape or underlying process of your problem space, there may be a better solution designed for your specific need. • Consider Kernel Based Learning and Support Vector Machines? • Consider Neural Networks? • Consider Traditional Polynomial Time Algorithms? • Etc. CS 561 19

Editor's Notes

  • #2: What has been traditionally done in the heat exchanger world is to take a best “guess” at a design with the help of an expert. Traditional heat exchanger designs are usually fully mathematically described. This initial guess can then be used as a basis, and various parameters are “tweaked”. The performance of the heat exchanger can be recalculated to see if the modified design is an improvement on the original one. Surely there must be a better way? There is - we don’t need to look very far to find examples of optimisation in Nature.
  • #7: One the fitness has been assigned, pairs of chromosomes representing heat exchanger designs can be chosen for mating. The higher the fitness, the greater the probability of the design being selected. Consequently, some of the weaker population members do not mate at all, whilst superior ones are chosen many times. It is even statistically possible for a member to be chosen to mate with itself. This has no advantage, as the offspring will be identical to the parent.
  • #8: One the population has been formed, (either randomly in the initial generation, or by mating in subsequent generations), each population member needs to be assessed against the desired properties - such a rating is called a “fitness”. The design parameters represented by the zeros and ones in the binary code of each chromosome are fed into the mathematical model describing the heat exchanger. The output parameters for each design are used to give the fitness rating. A good design has a high fitness value, and a poor design a lower value.
  • #10: The mating process is analogous to crossover carried out in living cells. A pair of binary strings are used. A site along the length of the string is chosen randomly. In this example it is shown between the 6th and 7th bits, but it could be anywhere. Both members of the pair are severed at that site, and their latter portions are exchanged. Two parents form two children, and these two “daughter” designs become members of the population for the next generation. This process takes place for each pair selected, so the new population has the same number of members as the previous generation.
  • #14: Summary of the previous steps to the model. Populations are continuously produced, going round the outer loop of this diagram, until the desired amount of optimisation has been achieved.
  翻译: