Click here to load reader

7. Genetic Algorithms - Iran University of Science and ... Algorithms... · PDF fileGenetic Algorithms: Part 3 Representation of Individuals Depends on the problem The most used encodings:

  • View
    232

  • Download
    1

Embed Size (px)

Text of 7. Genetic Algorithms - Iran University of Science and ... Algorithms... · PDF...

  • 7. Genetic Algorithms

    7.3 The Component of Genetic Algorithms

    Fall 2010

    Instructor: Dr. Masoud Yaghini

  • Genetic Algorithms: Part 3

    Outline

    Representation of Individuals

    Mutation

    Recombination

    Population Models

    Parent Selection

    Survivor Selection

    Glossary

    References

  • Representation of Individuals

  • Genetic Algorithms: Part 3

    Representation of Individuals

    Depends on the problem

    The most used encodings:

    Binary representation

    Integer representation

    Real-valued representation Real-valued representation

    Permutations representation

  • Genetic Algorithms: Part 3

    Binary Representations

    Simplest and most common

    Chromosome: string of bits

    genes: 0 / 1

    Example: binary representation of an integer

    3: 00011

    15: 01111

    16: 10000

  • Genetic Algorithms: Part 3

    Binary Representation

    For those problem concerning Booleandecision variables, the genotype-

    phenotype mapping is natural

    Example: knapsack problem

    Many optimization problems involve

    integer or real numbers and bit string can

    be used to encode these numbers

  • Genetic Algorithms: Part 3

    Mapping Integer Values on Bit Strings

    Integer values can be also binary coded: x = 5 00101

  • Genetic Algorithms: Part 3

    Mapping real values on bit strings

    Real values can be also binary coded

    z [x, y] represented by {a1,,aL} {0,1}L

    [x, y] {0,1}L must be invertible (one phenotype per genotype)

    : {0,1}L [x, y] defines the representation

    Only 2L values out of infinite are represented

    L determines possible maximum precision of solution

    High precision long chromosomes (slow evolution)

    ],[)2(12

    ),...,(1

    0

    1 yxaxy

    xaaj

    L

    j

    jLLL

    +=

    =

  • Genetic Algorithms: Part 3

    Mapping real values on bit strings

    Example: z [1, 10]

    We use L = 8 bits to represent real values in the domain [1, 10] , i.e., we use 256 numbers

    1 00000000 (0)

    10 11111111 (255)10 11111111 (255)

    Convert 00111100, to real value:1 + ((10-1) / (256-1)) * [(0 * 20) + (0 * 21) + (1 * 22) + (1 * 23) + (1 *

    24) + (1 * 25) + (0 * 26) + (0 * 27)] = 3.12

    Convert n = 3.14 to bit string:n = 3.14 (3.14-1)*255/(10-1) = 60 00111100

    0011 1100 3.12 (better precision requires more bits)

  • Genetic Algorithms: Part 3

    Binary Representations

    Hamming distance:

    Number of bits that have to be changed to map one

    string into another one

    E.g. 000 and 001 distance = 1

    Problem: Hamming distance between Problem: Hamming distance between consecutive integers may be > 1

    example: 5 bit binary representation

    14: 01110 15: 01111 16: 10000

    Probability of changing 15 into 16 by independent bit

    flips (mutation) is not same as changing it into 14!

  • Genetic Algorithms: Part 3

    Binary encoding problem

    Remember: small changes in genotype should cause small changes in phenotype

    Gray coding solves problem.

  • Genetic Algorithms: Part 3

    Binary Representation

    Binary coding of 0-7 :

    0102

    0011

    0000 Hamming distance, e.g.:

    000 (0) and 001 (1)

    1106

    1117

    1015

    1004

    0113

    0102 000 (0) and 001 (1)

    Distance = 1 (optimal)

    011 (3) and 100 (4)

    Distance = 3 (max possible)

  • Genetic Algorithms: Part 3

    Binary Representation

    Gray coding of 0-7:

    Gray coding is a representation

    that ensures that consecutive

    integers always have Hamming

    distance one.0103

    0112

    0011

    0000

    Gray coding is a mapping that

    means that small changes in the

    genotype cause small changes in

    the phenotype (unlike binary

    coding).

    1016

    1007

    1115

    1104

    0103

  • Genetic Algorithms: Part 3

    Binary Representation

    Nowadays it is generally accepted that it is

    better to encode numerical variables directly

    as:

    Integers

    Floating point variables

  • Genetic Algorithms: Part 3

    Integer representations

    Some problems naturally have integer variables

    e.g. for optimization of a function with integer

    variables

    Values may be Values may be

    unrestricted (all integers)

    restricted to a finite set

    e.g. {0,1,2,3}

    e.g. {North,East,South,West}

  • Genetic Algorithms: Part 3

    Integer representations

    Any natural relations between possible values?

    obvious for ordinal attributes 2 is more like 3 than it is 389

    small < medium < large small < medium < large

    hot > mild > cool

    maybe no natural ordering for cardinal attributes

    e.g. set of compass points

    e.g. employee ID

  • Genetic Algorithms: Part 3

    Real-valued Representation

    Many problems occur as real valued problems,

    e.g. continuous parameter optimization

    Example: a chromosome can be a pair

    (x, y)

    Vector of real values Vector of real values

    floating point numbers

    Genotype for solution becomes the vector with xi

  • Genetic Algorithms: Part 3

    Permutation Representations

    Deciding on sequence of events

    most natural representation is permutation of a set of integers

    In ordinary GA numbers may occur more than

    once on chromosomeonce on chromosome

    invalid permutations!

    New variation operators needed

  • Genetic Algorithms: Part 3

    Permutation Representations

    Two classes of problems

    based on order of events

    e.g. scheduling of jobs

    Job-Shop Scheduling Problem

    based on adjacenciesbased on adjacencies

    e.g. Travelling Salesperson Problem (TSP)

    finding a complete tour of minimal length between n cities, visiting each city only once

  • Genetic Algorithms: Part 3

    Permutation Representations

    Two ways to encode a permutation

    i th element represents event that happens in that

    location in a sequence

    value of i th element denotes position in sequence

    in which i th event occursin which i th event occurs

    Example (TSP): 4 cities A,B,C,D and permutation [3,1, 2, 4] denotes the tours:

    first encoding type: [CABD]

    second encoding type: [BCAD]

  • Mutation

  • Genetic Algorithms: Part 3

    Mutation

    Mutation is a variation operator

    Create one offspring from one parent

    Occurs at a mutation rate: pm behaviour of a GA depends on pm

  • Genetic Algorithms: Part 3

    Bitwise Mutation

    flips bits

    01 and 10

    setting of pm depends on nature of problem,

    typically between:

    1 / pop_size1 / pop_size

    1 / chromosome_length

  • Genetic Algorithms: Part 3

    Mutation for Integer Representation

    For integers there are two principal forms of

    mutation:

    Random resetting

    Creep Mutation

    Both of them, mutate each gene independently

    with user-defined probability pm

  • Genetic Algorithms: Part 3

    Random Resetting

    A new value is chosen with from the set of permissible integer values

    Most suitable for cardinal attributes

  • Genetic Algorithms: Part 3

    Creep Mutation

    Add small (positive / negative) integer to gene

    value

    random value

    sampled from a distribution

    symmetric around 0 symmetric around 0

    with higher probability of small changes

    Designed for ordinal attributes

    Step size is important

    controlled by parameters

    setting of parameters important

  • Genetic Algorithms: Part 3

    Mutation for Floating-Point Representation

    Allele values come from a continuous distribution

    Change allele values randomly within its

    domain

    upper and lower boundaries, U and L respectively upper and lower boundaries, Ui and Li respectively

    [ ]iiiinn

    ULxxwhere

    xxxxxx

    ,,

    ,...,,,...,, 2121

    >

  • Genetic Algorithms: Part 3

    Mutation for Floating-Point Representation

    According to the probability distribution from

    which the new gene values are drawn, there

    are two types of floating-point mutation:

    Uniform Mutation

    Non-Uniform Mutation with a Fixed Distribution Non-Uniform Mutation with a Fixed Distribution

  • Genetic Algorithms: Part 3

    Uniform Mutation

    Values of xi drawn uniformly randomly from the

    [Li,Ui], Similar to

    bit flipping for binary representations

    random resetting for integer representations

    usually used with positionwise mutation usually used with positionwise mutation

    probability

  • Genetic Algorithms: Part 3

    Non-Uniform Mutation with a Fixed Distribution

    Most common form

    Similar to creep mutation for integer

    representations

    Add an amount to gene value

    Amount randomly drawn from a distribution Amount randomly drawn from a distribution

  • Genetic Algorithms: Part 3

    Non-Uniform Mutation with a Fixed Distribution

    Gaussian distribution (normal distribution)

    with mean 0

    user-specified standard deviation

    may have to adjust to interval [Li,Ui]

    2/3 of samples lie within one standard deviation of 2/3 of samples lie within one standard deviation of

    mean (- to + )

Search related