Chpt13 Optimisation and Search

download Chpt13 Optimisation and Search

of 43

Transcript of Chpt13 Optimisation and Search

  • 8/12/2019 Chpt13 Optimisation and Search

    1/43

    Optimisation and Search:

    Gradient Descent and

    the Nelder-Mead Simplex Algorithm

  • 8/12/2019 Chpt13 Optimisation and Search

    2/43

    Why minimise a function numerically?

    f(a,b)

    a

    by

    Unknown!

  • 8/12/2019 Chpt13 Optimisation and Search

    3/43

    Why minimise a function numerically?Background: linear regression

  • 8/12/2019 Chpt13 Optimisation and Search

    4/43

    Straight Line: f(x) = 1x + 2

    Why minimise a function numerically?Background: linear regression

  • 8/12/2019 Chpt13 Optimisation and Search

    5/43

    Straight Line: f(x) = 1x + 2

    i

    Why minimise a function numerically?Background: linear regression

  • 8/12/2019 Chpt13 Optimisation and Search

    6/43

    Straight Line: f(x) = 1x + 2

    Error between f(xi) given bythe model andyi from thedata:

    ii

    iii

    yx

    yxf

    +=

    =

    21

    21 )(),(

    i

    Why minimise a function numerically?Background: linear regression

  • 8/12/2019 Chpt13 Optimisation and Search

    7/43

    Straight Line: f(x) = 1x + 2

    Error between f(xi) given bythe model andyi from thedata:

    ii

    iii

    yx

    yxf

    +=

    =

    21

    21 )(),(

    iTask: Find the parameters 1

    and 2 that minimise the sumof squared errors!

    =

    =

    +=

    =

    N

    i

    ii

    N

    i

    i

    yx

    E

    1

    2

    21

    1

    2

    2121

    )(

    ),(),(

    Why minimise a function numerically?Background: linear regression

  • 8/12/2019 Chpt13 Optimisation and Search

    8/43

    Linear Regression:

    Fitting function is linear with respect to theparameters can be solved analytically (see Wikipedia)

    Non-linear Regression:

    Fitting function is non-linear with respect to theparameters (e.g. f(x,1,2) = sin(1x)+cos(2 x)) Often no analytical solution Numerical optimisation or direct search

    Why minimise a function numerically? non-linear regression

  • 8/12/2019 Chpt13 Optimisation and Search

    9/43

    Gradient Descent: Example

    1 2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    10/43

    Gradient Descent

    1. Choose initial parameters 1 and 22. Calculate the gradient

    3. Step in the direction of the gradient with a stepsize proportional to the amplitude of thegradient

    you get new parameters 1 and 24. Check if the parameters have changed at a rate

    above a certain threshold

    5. If yes, go to 2, else terminate

  • 8/12/2019 Chpt13 Optimisation and Search

    11/43

    Gradient Descent: Example

    1 2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    12/43

    Gradient Descent: Example

    1 2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    13/43

    Gradient Descent: Example

    1 2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    14/43

    Gradient Descent: Example

    1 2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    15/43

    Gradient Descent: Example

    1 2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    16/43

    Gradient Descent: Example

    1 2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    17/43

    Gradient Descent: Example

    1 2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    18/43

    Gradient Descent: Example

    1 2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    19/43

    Gradient Descent: Example

    1 2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    20/43

    Gradient Descent: Example

    1 2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    21/43

    Gradient Descent: Example

    1 2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    22/43

    Gradient Descent: Example

    1 2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    23/43

    Gradient Descent: Example

    1 2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    24/43

    Nelder-Mead Simplex Algorithm(for functions of 2 variables)1. Pick 3 parameter combinations Triangle

    2. Evaluate the function for those combinations f

    h,f

    s,f

    l: highest, second highest and lowest point

    3. Update the triangleusing the best of thetransformations inthe figure

    4. Check for endcondition

    5. Go to 2 orterminate

  • 8/12/2019 Chpt13 Optimisation and Search

    25/43

    Nelder-Mead Algorithm: Update Rulesr

    srl

    f

    fff

    accept

  • 8/12/2019 Chpt13 Optimisation and Search

    26/43

    Nelder-Mead Algorithm: Example

    1

    2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    27/43

    Nelder-Mead Algorithm: Example

    1

    2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    28/43

    Nelder-Mead Algorithm: Example

    1

    2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    29/43

    Nelder-Mead Algorithm: Example

    1

    2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    30/43

    Nelder-Mead Algorithm: Example

    1

    2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    31/43

    Nelder-Mead Algorithm: Example

    1

    2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    32/43

    Nelder-Mead Algorithm: Example

    1

    2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    33/43

    Nelder-Mead Algorithm: Example

    1

    2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    34/43

    Nelder-Mead Algorithm: Example

    1

    2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    35/43

    Nelder-Mead Algorithm: Example

    1

    2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    36/43

    Nelder-Mead Algorithm: Example

    1

    2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    37/43

    Nelder-Mead Algorithm: Example

    1

    2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    38/43

    Nelder-Mead Algorithm: Example

    1

    2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    39/43

    Nelder-Mead Algorithm: Example

    1

    2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    40/43

    Nelder-Mead Algorithm: Example

    1

    2

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    41/43

    Nelder-Mead Algorithm: Example

    12

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    42/43

    Nelder-Mead Algorithm: Example

    12

    E(1,2)

  • 8/12/2019 Chpt13 Optimisation and Search

    43/43

    Nelder-Mead Algorithm: Example

    12

    E(1,2)