Genetic

43
5/11/2015 1 By Saurabh Bhardwaj Teaching Cum Research fellow Instrumentation and Control Engineering Department NSIT, New Delhi “Intelligent Tools for Various Engineering Applications” Genetic Algorithm The general idea behind GAs is that we can build a better solution if we somehow combine the "good" parts of other solutions (schemata theory), just like nature does by combining the DNA of living beings.

description

“Intelligent Tools for Various Engineering Applications”

Transcript of Genetic

  • 5/11/2015

    1

    By

    Saurabh BhardwajTeaching Cum Research fellow

    Instrumentation and Control Engineering DepartmentNSIT, New Delhi

    Intelligent Tools for Various Engineering Applications

    Genetic Algorithm

    The general idea behind GAs is that wecan build a better solution if wesomehow combine the "good" parts ofother solutions (schemata theory), justlike nature does by combining theDNA of living beings.

  • 5/11/2015

    2

    Genetic Algorithm

    HOW ARE GENETIC ALGORITHM DIFFERENT

    FROM TRADITIONAL METHODS?

    Classical Algorithm

    Generates a single point at each iteration. The sequence of points approaches an optimal solution.

    Selects the next point in the sequence by a deterministic computation

    Genetic Algorithm

    Generates a population of points at each iteration. The best point in the population approaches an optimal solution.

    GA work with a coding of the parameter set not the parameter themselves.

    GA use payoff ( objective function ) information, not derivatives or other auxiliary knowledge.

    GA use probabilistic transition rules not deterministic rules.

  • 5/11/2015

    3

    Genetic Algorithm

    ADVANTAGES OF GA

    It approaches towards the global optimum

    It can be applied to solve a variety of optimization problems that

    are not well suited for standard optimization algorithms,

    including problems in which the objective function is

    discontinuous, non-differentiable, stochastic, or highly nonlinear

    Genetic Algorithm manipulate decision or control variable

    representation at the string level to exploit similarities among

    high performance strings. Other methods usually deal with

    functions and their control variables directly.

  • 5/11/2015

    4

    Genetic Algorithm

    The general idea behind GAs is that wecan build a better solution if wesomehow combine the "good" parts ofother solutions (schemata theory), justlike nature does by combining theDNA of living beings.

  • 5/11/2015

    5

  • 5/11/2015

    6

  • 5/11/2015

    7

  • 5/11/2015

    8

  • 5/11/2015

    9

    LIMITATIONS OF GAEven though GA is capable of obtaining global optimum withmultiple peaks. For MFD ( Multiple fault diagnosis ) problem theGA exhibits lower reliability than our local search algorithm. Toachieve higher reliability we simply combine the two algorithmsto form a hybrid. This is a straight forward to do with geneticalgorithms via the introduction of local improvement operators.

    Genetic Algorithm

  • 5/11/2015

    10

    Genetic Algorithm

    Genetic Algorithm

  • 5/11/2015

    11

    Genetic Algorithm

    Genetic Algorithm

    plotobjective();

  • 5/11/2015

    12

    Genetic Algorithm

    Genetic Algorithm

  • 5/11/2015

    13

    Genetic Algorithm

    Genetic Algorithm

  • 5/11/2015

    14

    Genetic Algorithm

    Genetic Algorithm

  • 5/11/2015

    15

    Genetic Algorithm

    Genetic Algorithm

  • 5/11/2015

    16

    Genetic Algorithm

    Genetic Algorithm

  • 5/11/2015

    17

    Genetic Algorithm

    Genetic Algorithm

  • 5/11/2015

    18

    Genetic Algorithm

    Genetic Algorithm

  • 5/11/2015

    19

    Genetic Algorithm

    Genetic Algorithm

  • 5/11/2015

    20

    Genetic Algorithm

    Genetic Algorithm

  • 5/11/2015

    21

    Genetic Algorithm

    Genetic Algorithm

  • 5/11/2015

    22

    Genetic Algorithm

    Genetic Algorithm

  • 5/11/2015

    23

    Genetic Algorithm

    Genetic Algorithm

  • 5/11/2015

    24

    Genetic Algorithm

    Genetic Algorithm

  • 5/11/2015

    25

    Number of Design Solutions 4n = 4

    Number of Bits = 8 [25.5 = 255= 8 bits]

  • 5/11/2015

    26

    String

    Number

    Initial

    Pop

    InitialPop

    (Binary)

    Yi Yi/Yi Count Mating Pool

    1 4.2 00101010 110.67 0.286 1 01100101

    2 10.1 01100101 64.95 0.168 2 01100101

    3 16.4 10100100 81.23 0.210 1 00101010

    4 23.5 11101011 129.59 0.335 0 10100100

    Mating Pool Mate Cross

    over

    Site

    New Pop New Pop Yi Yi/Yi Count Mating pol

    01100101 4 4 01100100 10.0 65 0.20 2 01100100

    01100101 3 5 01100010 96 65.12 0.206 1 01100100

    00101010 2 5 00101101 4.5 104.05 0.329 0 01100010

    10100100 1 4 10100101 16.5 81.72 0.259 1 10100101

  • 5/11/2015

    27

    Stri

    ng

    Num

    ber

    Ini

    tial

    Po

    p

    InitialPop

    (Binary)

    Yi Yi/

    Yi

    C

    o

    u

    nt

    Mating

    Pool

    Mat

    e

    Cros

    sover

    Site

    New Pop Ne

    w

    Pop

    Yi Yi/

    Yi

    C

    ou

    nt

    Mating

    pol

    1 4.2 00101010 110.6

    7

    0.28

    6

    1 01100101 4 4 01100100 10.0 65 0.20 2 01100100

    2 10.

    1

    01100101 64.95 0.16

    8

    2 01100101 3 5 01100010 96 65.1

    2

    0.20

    6

    1 01100100

    3 16.

    4

    10100100 81.23 0.21

    0

    1 00101010 2 5 00101101 4.5 104.

    05

    0.32

    9

    0 01100010

    4 23.

    5

    11101011 129.5

    9

    0.33

    5

    0 10100100 1 4 10100101 16.5 81.7

    2

    0.25

    9

    1 10100101

    Genetic Algorithm

  • 5/11/2015

    28

    Genetic Algorithm

    BOILER TDL

    Y(K)CONCENTRATION OF CO2

    U(k)

    Flow rate

    Box and Jenkins Furnace

    Input, u(t), is gas flow rate & output,y(t), is carbon dioxide concentration.

    Objective is to maintain concentration of carbon dioxide

    y(k)=f{y(k-1), y(k-2), y(k-3), y(k-4), u(k) u(k-1 ), u(k- 2),u(k-3), u(k-5), u(k-4) }

    THE SYSTEM UNDER STUDY

  • 5/11/2015

    29

    Genetic

    Algorithm

    fp(k)

    fpn(k)

    Desired non-linear

    function

    Neural network

    u(k)

    -

    +

    BLOCK DIAGRAM FOR SYSTEM

    IDENTIFICATION

    E(k)

    SIMULATION RESULTS FOR

    IDENTIFICATION

    1 2 3 4 5 6 7 8 9 104.034

    4.0345

    4.035

    4.0355

    4.036

    4.0365

    4.037

    4.0375

    4.038plot of performance index for identification

    No. of generations

    am

    plit

    ude

    Plot of Performance Index for Identification using BP

    & gradient descent

    Plot of Performance Index for Identification using GA

  • 5/11/2015

    30

    COMPARATIVE STUDY OF GA, BP & GRADIENT

    DESCENT AS LEARNING ALGORITHM FOR

    IDENTIFICATION

    Learning algorithm used Minimum value of

    performance index

    Genetic Algorithm 4.0345 at 10 th generation

    BP & Gradient descent 36 at 100th iteration

    BLOCK DIAGRAM (CONTROLLER)

    NN/GA

    ControllerPLANT

    SET POINT ACTUAL O/P

  • 5/11/2015

    31

    SIMULATION RESULTS FOR

    CONTROL

    1 2 3 4 5 6 7 8 9 103.68

    3.685

    3.69

    3.695

    3.7

    3.705

    3.71x 10

    -6 plot of fittness function for direct control

    no. of generations

    square

    of

    err

    or

    Plot for Square of error for off-line control using BP &

    gradient descent

    Plot for Square of error for off-line control using GA

    COMPARATIVE STUDY OF GA, BP & GRADIENT

    DESCENT AS LEARNING ALGORITHM FOR OFF

    LINE CONTROL

    Learning algorithm used Minimum value of

    square of error

    Genetic Algorithm 3.697*10-6 at 7th iteration

    BP & Gradient descent 50 at 7th generation

  • 5/11/2015

    32

    PARTICLE SWARM

    OPTIMIZATION

    PARTICLE SWARM

    OPTIMIZATION

    Evolutionary computational technique based on the movement

    and intelligence of swarms looking for the most fertile feeding

    location

    It was developed in 1995 by James Kennedy and Russell

    Eberhart

    Simple algorithm, easy to implement and few parameters to

    adjust mainly the velocity

    A swarm is an apparently disorganized collection

    (population) of moving individuals that tend to cluster together

    while each individual seems to be moving in a random direction

  • 5/11/2015

    33

    CONTINUED It uses a number of agents (particles) that constitute a

    swarm moving around in the search space looking for the best solution.

    Each particle is treated as a point in a D-dimensional space which adjusts its flying according to its own flying experience as well as the flying experience of other particles

    Each particle keeps track of its coordinates in the problem space which are associated with the best solution (fitness) that has achieved so far. This value is called pbest.

    CONTINUED Another best value that is tracked by the PSO is the

    best value obtained so far by any particle in the neighbors of the particle. This value is called gbest.

    The PSO concept consists of changing the velocity(or accelerating) of each particle toward its pbest and the gbest position at each time step.

  • 5/11/2015

    34

    PSO ALGORITHMFor each particle

    Initialize particle with feasible random numberENDDo

    For each particle Calculate the fitness valueIf the fitness value is better than the best fitness value (pbest) in history

    Set current value as the new pbestEnd

    Choose the particle with the best fitness value of all the particles as the gbestFor each particle

    Calculate particle velocity according to velocity update equation Update particle position according to position update equation

    End While maximum iterations or minimum error criteria is not attained

    gbest & lbest global version:

    vx[ ][ ] = vx[ ][ ] + 2*rand( )*(pbest[ ][ ] presentx[ ][ ]) +2*rand( )*(pbestx[ ][gbest] presentx[ ][ ])

    local version:

    vx[ ][ ] = vx[ ][ ] + 2*rand( )*(pbest[ ][ ] presebtx[ ][ ]) + 2*rand( )*(pbestx[ ][lbest] presentx[ ][ ])

  • 5/11/2015

    35

    PSO VS GA In PSO unlike GA each iteration is not a process of replacing the

    previous population with a new one, but rather a process of adaptation.

    PSO does not have genetic operators like crossover and mutation. Particles update themselves with the internal velocity and have memory.

    In GAs, chromosomes share information with each other. So the whole population moves like one group towards an optimal area. In PSO, only gBest gives out the information to others. It is a one way information sharing mechanism. The evolution only looks for the best solution. Compared with GA, all the particles tend to converge to the best solution quickly [18].

    .

    ADVANTAGES OF PSO & GD

    One of the well known disadvantage of GD is that itmay get stuck at local minima and the programmermay end in a solution far away from global minima.PSO does not use any gradient on objective function.If only PSO algorithm is used then it is seen thatsquare of error fluctuates randomly and it may takemany iterations to converge.

    Thus in a way PSO takes care of the disadvantages ofGD

  • 5/11/2015

    36

    POWER QUALITY ISSUSES

    Voltage

    Sag / Swell

    Voltage

    Transients

    Voltage

    unbalanceHarmonics

    Load Frequency

    Deviation

    Voltage

    Flicker

    PROBLEMS DISCUSSED

    A comparative study of different algorithms to train the weights of neural network i.e. Particle Swarm Optimization (PSO), Genetic Algorithm (GA), Gradient Descent (GD) and a hybrid of PSO& GD is made for the above problems.

    Three problems of power quality are discussed in this study.1. voltage flicker estimation, 2. load frequency estimation,

    In the first problem the proposed algorithm is tested on given equations, then in second and third problem the algorithm is applied on real data.

  • 5/11/2015

    37

    VOLTAGE FLICKER ESTIMATION

    VOLTAGE FLICKER

    Changes in the envelope of 60Hz supply voltage is called

    instantaneous flicker level.

    When there are large fluctuating loads such as arc furnace, arc

    welder, spot welder, shredder motors flicker becomes a problem of

    concern, as it can propagate to neighboring customer connection

    points in power system.

    The periodic fluctuation can be modeled as an amplitude modulated

    signal; where the fundamental power frequency represents the carrier

    signal and the voltage flicker represents the modulating signal .

  • 5/11/2015

    38

    CONTINUED

    )sin()()( fffo twtAAtv

    oAfA

    fw

    f

    1

    1

    11sin)(

    cos)(]cossin[)(

    tA

    tAtwtwtv

    2

    11

    1 tanw

    w

    The shape can be a sinusoidal function with a frequency lower than the supply

    frequency as in the ac arc furnaces as follows:

    is the magnitude of the fundamental voltage ,is the magnitude of the voltage flicker,

    is the angular frequency of the voltage flicker, and

    is the phase angle.To allow the proposed estimation technique to track the envelope of the measured voltage waveform, it is written as:

    and is the phase angle.

    )()( tWtX

    BLOCK DIAGRAM FOR ESTIMATION OF VOLTAGE

    FLICKER ENVELOPE AND PHASE ANGLE

    2

    2

    2

    1)( wwtAVen

    2

    11

    1 tanw

    w

    Finally, the envelope is given by:

    and the phase angle can be

    calculated from:

    sum

    Weight Adaptation algorithm

    Rectangular to polar

    w1

    v(k)

    +

    Error

    v^(k) -

    X1

    X2

    w2

    Ven

  • 5/11/2015

    39

    PLOT OF ACTUAL AND ESTIMATED VOLTAGE FLICKER, VOLTAGE FLICKER

    ENVELOPE, FUNDAMENTAL PHASE ANGLE WHEN NN IS TRAINED WITH

    PSO&GD.

    0 0.05 0.1 0.15 0.2 0.25 0.3

    -5

    0

    5

    time in seconds

    volta

    ge a

    mpl

    itude

    0 0.05 0.1 0.15 0.2 0.25 0.3

    0

    2

    4

    6

    volta

    ge e

    nvel

    ope

    time in seconds

    0 0.05 0.1 0.15 0.2 0.25 0.3-2

    0

    2

    4

    time in seconds

    phas

    e an

    gle

    actual voltage envelope

    tracked voltage envelope

    actual phase angle

    tracked phase angle

    actual voltage

    tracked voltage

    COMPARISON OF SQUARE OF

    ERROR IN FLICKER PROBLEM

    LMS GD PSO GA PSO & GD

    0.02 in 12 iterations 0.01 in 450 iterations 0.008 in 450 iterations 0.1 in 480 iterations 0.0057 in 2 iterations

    1 1.2 1.4 1.6 1.8 2 2.2 2.4 2.6 2.8 35.5

    6

    6.5

    7

    7.5

    8

    8.5

    9

    9.5x 10

    -3 Error Plot with PSO& GD

    Number of iterations

    Am

    plitu

    de

    Plot of square of error with PSO & GD

  • 5/11/2015

    40

    POWER SYSTEM LOAD FREQUENCY ESTIMATION ON REAL DATA

    IMPORTANCE OF

    FREQUENCY ESTIMATON

    With increasing levels of distortions, there is large variations in

    frequency.

    Control and Protection require accurate estimate of frequency.

    Frequency estimation is a highly non linear problem.

  • 5/11/2015

    41

    PROBLEM FORMULATION

    A constant frequency is estimated. Effect like sudden change in frequency is also

    considered.

    Energy in MWH drawn in Northern grid of NTPC for different states is recorded after

    every 15 minutes.

    Frequency codes from "00" to "99" are for frequency range of 49.00 to 51.00 Hz ("00" for frequency = 51.00 Hz).

    Data for the state of Punjab recorded on 17-11-2003 is used for off-line training of the

    neural network. For the next 24 hours load frequency is estimated.

    Estimated frequency is then compared with actual recorded frequency on 18-11-2003.

    Practical conditions like sudden change in load and random noise are also considered.

    Genetic

    Algorithm

    fp(k)

    fpn(k)

    Desired non-linear

    function

    Neural network

    u(k)

    -

    +

    BLOCK DIAGRAM OF FREQUENCY

    ESTIMATOR

    E(k)

  • 5/11/2015

    42

    ESTIMATION OF FREQUENCY FROM THE

    REAL DATA

    0 10 20 30 40 50 60 70 80 90 1000

    50

    100

    150

    200

    250

    300plot for target frequency& estimated frequency

    No. of samples

    am

    plit

    ude

    target frequency

    estimated frequency

    energy input

    COMPARISON OF SQUARE OF ERROR IN LOAD FREQUENCY PROBLEM

    0 20 40 60 80 100 120 140 160 180 2000

    5

    10

    15

    20

    25

    30

    35

    40

    45Square of Error with PSO & GD

    Number of iterations

    Am

    plit

    ude

    GD GA PSO PSO&GD

    2 in 480 iterations 4 in 160 iterations 3 in 180 iterations 2.8 in 180 iterations

  • 5/11/2015

    43

    NN & PSO BASED FREQUENCY ESTIMATION

    NN & PSO BASED VOLTAGE FLICKER

    Thank You