topicos i artificial

46
Profr. Rubén Machucho Cadena

Upload: manuel-rodriguez

Post on 25-May-2017

215 views

Category:

Documents


0 download

TRANSCRIPT

Profr. Rubén Machucho Cadena

Edward A. FeigenbaumPadre de los Sistemas Expertos.

Desarrolló Dendral, un sistema experto para el análisis de

compuestos químicos.

Genetic algorithms are a class of heuristic search methods and

computational models of adaptation and evolution based on natural selection. In nature,

the search for beneficial adaptations to a continually changing environment (i.e.

evolution) is fostered by the cumulative evolutionary

knowledge that each species possesses of its forebears. This knowledge, which is encoded in

the chromosomes of each member of a species, is passed from one generation to the next

by a mating process in which the chromosomes of "parents"

produce "offspring" chromosomes.

“Genetic Algorithms are good at taking large,

potentially huge search spaces and navigating

them, looking for optimal combinations of

things, solutions you might not otherwise find

in a lifetime.”

- Salvatore ManganoComputer Design, May 1995

Directed search algorithms based on the mechanics of biological evolution

Developed by John Holland, University of Michigan (1970’s)◦ To understand the adaptive processes of natural

systems◦ To design artificial systems software that retains

the robustness of natural systems

Provide efficient, effective techniques for optimization and machine learning applications

Widely-used today in business, scientific and engineering circles

F in on acci N ew ton

D irect m eth ods Indirec t m ethods

C alcu lu s-based tech n iques

Evolu tion ary s trategies

C entra l ized D istribute d

Pa ra l le l

S tea dy-s ta te G enera tiona l

Seque ntia l

G e ne tic a lgori thm s

Evolutiona ry a lgori thm s Sim u lated ann ealin g

G uide d random se arc h te chnique s

D yn am ic program m in g

Enu m erative tech n iqu es

Se arch te chniques

A problem to solve, and ... Encoding technique (gene, chromosome) Initialization procedure (creation) Evaluation function (environment) Selection of parents (reproduction) Genetic operators (mutation, recombination) Parameter settings (practice and art)

{initialize population;evaluate population;while TerminationCriteriaNotSatisfied{

select parents for reproduction;perform recombination and mutation;evaluate population;

}}

reproduction

population evaluation

modification

discard

deleted members

parents

children

modifiedchildren

evaluated children

Chromosomes could be:◦ Bit strings (0101 ... 1100)◦ Real numbers (43.2 -33.1 ... 0.0 89.2) ◦ Permutations of element (E11 E3 E7 ... E1 E15)◦ Lists of rules (R1 R2 R3 ... R22 R23)◦ Program elements (genetic programming)◦ ... any data structure ...

population

reproduction

population

parents

children

Parents are selected at random with selection chances biased in relation to chromosome evaluations.

Modifications are stochastically triggered Operator types are:

◦ Mutation◦ Crossover (recombination)

modificationchildren

modified children

Causes movement in the search space(local or global)

Restores lost information to the population

Before: (1 0 1 1 0 1 1 0)

After: (0 1 1 0 0 1 1 0)

Before: (1.38 -69.4 326.44 0.1)

After: (1.38 -67.5 326.44 0.1)

P1 (0 1 1 0 1 0 0 0) (0 1 0 0 1 0 0 0) C1

P2 (1 1 0 1 1 0 1 0) (1 1 1 1 1 0 1 0) C2

Crossover is a critical feature of geneticalgorithms:

◦ It greatly accelerates search early in evolution of a population

◦ It leads to effective combination of schemata (subsolutions on different chromosomes)

*

The evaluator decodes a chromosome and assigns it a fitness measure

The evaluator is the only link between a classical GA and the problem it is solving

evaluation

evaluatedchildren

modifiedchildren

Generational GA:entire populations replaced with each iteration

Steady-state GA:a few members replaced each generation

population

discard

discarded members

Distribution of Individuals in Generation 0

Distribution of Individuals in Generation N

The Traveling Salesman Problem:

Find a tour of a given set of cities so that ◦ each city is visited only once◦ the total distance traveled is

minimized

Representation is an ordered list of citynumbers known as an order-based GA.

1) London 3) Dunedin 5) Beijing 7) Tokyo2) Venice 4) Singapore 6) Phoenix 8)

Victoria

CityList1 (3 5 7 2 1 6 4 8)CityList2 (2 5 7 6 8 1 3 4)

Crossover combines inversion andrecombination: * *Parent1 (3 5 7 2 1 6 4 8)Parent2 (2 5 7 6 8 1 3 4)

Child (5 8 7 2 1 6 3 4)

This operator is called the Order1 crossover.

Mutation involves reordering of the list:

* *Before: (5 8 7 2 1 6 3 4)

After: (5 8 6 2 1 7 3 4)

0

20

40

60

80

100

120

0 10 20 30 40 50 60 70 80 90 100

y

x

0

20

40

60

80

100

120

0 10 20 30 40 50 60 70 80 90 100

y

x

TSP30 (Performance = 941)

44626967786462544250404038213567606040425099

0

20

40

60

80

100

120

0 10 20 30 40 50 60 70 80 90 100

y

x

TSP30 (Performance = 800)

0

20

40

60

80

100

120

0 10 20 30 40 50 60 70 80 90 100

y

x

TSP30 (Performance = 652)

423835262135327

3846445860697678716967628494

0

20

40

60

80

100

120

0 10 20 30 40 50 60 70 80 90 100

y

x

TSP30 Solution (Performance = 420)

0

200

400

600

800

1000

1200

1400

1600

1800

1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31

Dis

tanc

e

Generations (1000)

TSP30 - Overview of Performance

Best

Worst

Average

Crossover and Mutation Introduction Crossover and mutation are two basic operators of GA. Performance of GA very depends on them. Type and implementation of operators depends on encoding and also on a problem.

Binary Encoding Crossover Single point crossover - one crossover point is selected, binary string from beginning of chromosome to the crossover point is copied from one parent, the rest is copied from the second parent

                                                                                           

11001011+11011111 = 11001111

Two point crossover - two crossover point are selected, binary string from beginning of chromosome to the first crossover point is copied from one parent, the part from the first to the second crossover point is copied from the second parent and the rest is copied from the first parent

                                                                                                                                                                                                                                                                                     

11001011 + 11011111 = 11011111Uniform crossover - bits are randomly copied from the first or from the second parent

                                                                                                                                                                                             

11001011 + 11011101 = 11011111

Arithmetic crossover - some arithmetic operation is performed to make a new offspring

                                                                                                                                                                                 11001011 + 11011111 = 11001001 (AND)

Mutation Bit inversion - selected bits are inverted

                                                                                                                                                     

 11001001 =>  10001001

Crossover Single point crossover - one crossover point is selected, till this point the

permutation is copied from the first parent, then the second parent is scanned and if the number is not yet in the offspring it is addedNote: there are more ways how to produce the rest after crossover point

(1 2 3 4 5 6 7 8 9) + (4 5 3 6 8 9 7 2 1) = (1 2 3 4 5 6 8 9 7)

Mutation Order changing - two numbers are selected and exchanged

(1 2 3 4 5 6 8 9 7) => (1 8 3 4 5 6 2 9 7)

Value Encoding Crossover All crossovers from binary encoding can be used

Mutation

Adding a small number (for real value encoding) - to selected values is added (or subtracted) a small number

(1.29  5.68  2.86  4.11  5.55) => (1.29  5.68  2.73  4.22  5.55)

Permutation Encoding

Tree Encoding Crossover

Tree crossover - in both parent one crossover point is selected, parents are divided in that point and exchange part below crossover point to produce new offspring

                                                                            

                                                                                                                                                                                                           

Mutation Changing operator, number - selected nodes are changed

Binary Encoding Binary encoding is the most common, mainly because first works about GA used this type of encoding

In binary encoding every chromosome is a string of bits, 0 or 1

.

. Example of chromosomes with binary encoding

Binary encoding gives many possible chromosomes even with a small number of alleles. On the other hand, this encoding is often not natural for many problems and sometimes corrections must be made after crossover and/or mutation.

EncodingIntroduction Encoding of chromosomes is one of the problems, when you are starting to solve problem with GA. Encoding very depends on the problem. In this chapter will be introduced some encodings, which have been already used with some success.

Chromosome A 101100101100101011100101Chromosome B 111111100000110000011111

                                                                                                                                          Example of Problem: Knapsack problemThe problem: There are things with given value and size. The knapsack has given capacity. Select things to maximize the value of things in knapsack, but do not extend knapsack capacity.Encoding: Each bit says, if the corresponding thing is in knapsack.                                                                                                                                           

Permutation Encoding

Chromosome A 1  5  3  2  6  4  7  9  8Chromosome B 8  5  6  7  2  3  1  4  9

Permutation encoding can be used in ordering problems, such as travelling salesman problem or task ordering problem. In permutation encoding, every chromosome is a string of numbers, which represents number in a sequence.

Example of chromosomes with permutation encoding

Permutation encoding is only useful for ordering problems. Even for this problems for some types of crossover and mutation corrections must be made to leave the chromosome consistent (i.e. have real sequence in it).

                                                                                                                                          Example of Problem: Travelling salesman problem (TSP)The problem: There are cities and given distances between them.Travelling salesman has to visit all of them, but he does not to travel very much. Find a sequence of cities to minimize travelled distance. Encoding: Chromosome says order of cities, in which salesman will visit them.

Value Encoding Direct value encoding can be used in problems, where some complicated value, such as real numbers, are used. Use of binary encoding for this type of problems would be very difficult. In value encoding, every chromosome is a string of some values. Values can be anything connected to problem, form numbers, real numbers or chars to some complicated objects.

Chromosome A 1.2324  5.3243  0.4556  2.3293  2.4545Chromosome B ABDJEIFJDHDIERJFDLDFLFEGTChromosome C (back), (back), (right), (forward), (left)

Example of chromosomes with value encoding

Value encoding is very good for some special problems. On the other hand, for this encoding is often necessary to develop some new crossover and mutation specific for the problem.

Example of Problem: Finding weights for neural networkThe problem: There is some neural network with given architecture. Find weights for inputs of neurons to train the network for wanted output.Encoding: Real values in chromosomes represent corresponding weights for inputs.                                                                                                                                           

Tree Encoding Tree encoding is used mainly for evolving programs or expressions, for genetic programming. In tree encoding every chromosome is a tree of some objects, such as functions or commands in programming language.                                   

Chromosome A Chromosome B

( +  x  ( /  5  y ) ) ( do_until  step  wall )Example of chromosomes with tree encoding Tree encoding is good for evolving programs. Programing language LISP is often used to this, because programs in it are represented in this form and can be easily parsed as a tree, so the crossover and mutation can be done relatively easily. Example of Problem: Finding a function from given valuesThe problem: Some input and output values are given. Task is to find a function, which will give the best (closest to wanted) output to all inputs.Encoding: Chromosome are functions represented in a tree.

Choosing basic implementation issues:◦ representation◦ population size, mutation rate, ...◦ selection, deletion policies◦ crossover, mutation operators

Termination Criteria Performance, scalability Solution is only as good as the evaluation

function (often hardest part)

Concept is easy to understand Modular, separate from application Supports multi-objective optimization Good for “noisy” environments Always an answer; answer gets better with

time Inherently parallel; easily distributed

Many ways to speed up and improve a GA-based application as knowledge about problem domain is gained

Easy to exploit previous or alternate solutions

Flexible building blocks for hybrid applications

Substantial history and range of use

Alternate solutions are too slow or overly complicated

Need an exploratory tool to examine new approaches

Problem is similar to one that has already been successfully solved by using a GA

Want to hybridize with an existing solution Benefits of the GA technology meet key

problem requirements

Domain Application TypesControl gas pipeline, pole balancing, missile evasion, pursuit

Design semiconductor layout, aircraft design, keyboardconfiguration, communication networks

Scheduling manufacturing, facility scheduling, resource allocation

Robotics trajectory planning

Machine Learning designing neural networks, improving classificationalgorithms, classifier systems

Signal Processing filter design

Game Playing poker, checkers, prisoner’s dilemma

CombinatorialOptimization

set covering, travelling salesman, routing, bin packing,graph colouring and partitioning