67
1 © 2011 The MathWorks, Inc. Global Optimization with MATLAB® Products Account Manager 차장 Application Engineer

Global Optimization with MATLAB® Products Account Manager

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Global Optimization with MATLAB® Products Account Manager

1 © 2011 The MathWorks, Inc.

Global Optimization with MATLAB®

Products

Account Manager

이 장 원 차장

Application Engineer

엄 준 상

Page 2: Global Optimization with MATLAB® Products Account Manager

2

Agenda

Introduction to Global Optimization

Survey of Solvers with Examples

– MultiStart

– Global Search

– Pattern Search

– Simulated Annealing

– Genetic Algorithm / Multiobjective

Genetic Algorithm

Additional Resources

Question & Answer

-2

0

2

-3-2

-10

12

3

-6

-4

-2

0

2

4

6

8

x

Peaks

y

Local minima

Global minima

Page 3: Global Optimization with MATLAB® Products Account Manager

3

Optimization – Finding answers to problems automatically

Objectives

Achieved?

NO

Optimal

Design

YES Model or

Prototype

Modify Design

Parameters

Initial

Design

Parameters

OPTIMIZATION PROCESS

Finding better (optimal) designs

Faster design evaluations

Useful for trade-off analysis (N dimensions)

Non-intuitive designs may be found

Optimization benefits include: Design process can be performed:

Antenna Design Using Genetic Algorithm http://ic.arc.nasa.gov/projects/esg/research/antenna.htm

Manually

(trial-and-error or iteratively)

Automatically

(using optimization techniques)

Page 4: Global Optimization with MATLAB® Products Account Manager

4 0 20 40 60 80 100 1200

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

t

c

c=b1e-b

4t+b

2e-b

5t+b

3e-b

6t

Example Global Optimization Problems

Why does fmincon have a hard time finding the

function minimum?

Why didn’t nonlinear regression find a good fit?

Why didn’t fminunc find the maximum volumetric

efficiency?

0 5 10

-10

-5

0

5

10

x

Starting at 10

0 5 10

-10

-5

0

5

10

x

Starting at 8

0 5 10

-10

-5

0

5

10

x

Starting at 6

x s

in(x

) +

x c

os(2

x)

0 5 10

-10

-5

0

5

10

x

Starting at 3

0 5 10

-10

-5

0

5

10

x

Starting at 1

0 5 10

-10

-5

0

5

10

x

Starting at 0

x s

in(x

) +

x c

os(2

x)

Revolutions Per Minute, RPM

Manifold

Pre

ssure

Ratio

Peak VE Value = 0.96144

Start

End

1000 2000 3000 4000 5000 60000

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

Page 5: Global Optimization with MATLAB® Products Account Manager

5

Global Optimization

Goal:

Want to find the lowest/largest value of

the nonlinear function that has many local

minima/maxima

Problem:

Traditional solvers often return one of the

local minima (not the global)

Solution:

A solver that locates globally optimal

solutions Rastrigin’s Function

Page 6: Global Optimization with MATLAB® Products Account Manager

6

Global Optimization Toolbox – For problems that

contain multiple maxima/minima or are non-smooth

Optimization T

oolbox

Global Optimization

Toolbox

Faster/fewer function eval

uations Larger problems (higher d

imensions) Finds local minima/maxim

a

Finds global minima/maxi

ma (most of the time) Better on

non-smooth

stochastic

discontinuous

undefined gradients

Custom data types

(in GA and SA solvers)

Page 7: Global Optimization with MATLAB® Products Account Manager

7

MULTISTART

Page 8: Global Optimization with MATLAB® Products Account Manager

8

What is MultiStart?

Run a local solver from

each set of start points

Option to filter starting

points based feasibility

Supports parallel

computing

Page 9: Global Optimization with MATLAB® Products Account Manager

11

GLOBAL SEARCH

Page 10: Global Optimization with MATLAB® Products Account Manager

12

What is GlobalSearch?

Multistart heuristic algorithm

Calls fmincon from multiple

start points to try and find a

global minimum

Filters/removes non-promising

start points

Page 11: Global Optimization with MATLAB® Products Account Manager

13

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

GlobalSearch Overview Schematic Problem

Peaks function

Three minima

Green, z = -0.065

Red, z= -3.05

Blue, z = -6.55

x

y

Page 12: Global Optimization with MATLAB® Products Account Manager

14

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

GlobalSearch Overview – Stage 0 Run from specified x0

x

y

Page 13: Global Optimization with MATLAB® Products Account Manager

15

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

GlobalSearch Overview – Stage 1 Generate stage 1 start points via Scatter Search

3

6

0

0 0

4

0

-2

x

y

Page 14: Global Optimization with MATLAB® Products Account Manager

16

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

GlobalSearch Overview – Stage 1 Find stage 1 start point with lowest penalty value

3

6

0

0 0

4

0

-2

x

y

Page 15: Global Optimization with MATLAB® Products Account Manager

17

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

GlobalSearch Overview – Stage 1 Run from best stage 1 point

x

y

Page 16: Global Optimization with MATLAB® Products Account Manager

18

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

GlobalSearch Overview – Stage 2 Generate stage 2 start points using Scatter Search

x

y

Page 17: Global Optimization with MATLAB® Products Account Manager

19

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

GlobalSearch Overview – Stage 2 Analyse each stage 2 point in turn.

x

y

Page 18: Global Optimization with MATLAB® Products Account Manager

20

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

GlobalSearch Overview – Stage 2 Don’t run points that are in basins of existing

minimum

x

y

Page 19: Global Optimization with MATLAB® Products Account Manager

21

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

GlobalSearch Overview – Stage 2 Analyse each stage 2 point in turn.

x

y

Page 20: Global Optimization with MATLAB® Products Account Manager

22

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

GlobalSearch Overview – Stage 2 Don’t run points whose penalty value exceeds

threshold

6

Current penalty

threshold value : 4

x

y

Page 21: Global Optimization with MATLAB® Products Account Manager

23

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

GlobalSearch Overview – Stage 2 Analyse each stage 2 point in turn

x

y

Page 22: Global Optimization with MATLAB® Products Account Manager

24

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

GlobalSearch Overview – Stage 2 Run start point if it satisfies distance & merit criteria

Current penalty

threshold value : 4

-3

x

y

Page 23: Global Optimization with MATLAB® Products Account Manager

25

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

GlobalSearch Overview – Stage 2 Expand basin of attraction if minimum already found

Current penalty threshold value : 2

-0.1

x

y Basins can overlap

Page 24: Global Optimization with MATLAB® Products Account Manager

28

SIMULATED ANNEALING

Page 25: Global Optimization with MATLAB® Products Account Manager

29

What is Simulated Annealing?

A probabilistic metaheuristic approach based upon the

physical process of annealing in metallurgy.

Controlled cooling of a metal allows atoms to realign from a

random higher energy state to an ordered crystalline

(globally) lower energy state

By analogy, simulated annealing replaces a current solution

by randomly choosing a nearby solution

A “nearby” solution is determined by the solution

temperature

Page 26: Global Optimization with MATLAB® Products Account Manager

30

Simulated Annealing Overview – Iteration 1 Run from specified x0

x

y

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

0.9

Page 27: Global Optimization with MATLAB® Products Account Manager

31

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Simulated Annealing Overview – Iteration 1 Randomly generate a new point according to probability distribution and

current temperature

3

x

y 0.9

Possible New Points:

Standard Normal N(0,1) * Temperature

Temperature = 1

Page 28: Global Optimization with MATLAB® Products Account Manager

32

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Simulated Annealing Overview – Iteration 1 If lower, accept the point, if higher, accept based upon acceptance

probability

3

x

y 0.9

Temperature = 1

11.01

1/)9.03(

Taccepte

P

Page 29: Global Optimization with MATLAB® Products Account Manager

33

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Simulated Annealing Overview – Iteration 1 Randomly generate a new point according to probability distribution and

current temperature

3

x

y 0.9

Temperature = 1

0.3

Page 30: Global Optimization with MATLAB® Products Account Manager

34

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Simulated Annealing Overview – Iteration 1 Randomly generate a new point according to probability distribution and

current temperature, accept new point if lower value

3

x

y 0.9

Temperature = 1

0.3

Page 31: Global Optimization with MATLAB® Products Account Manager

35

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Simulated Annealing Overview – Iteration 2 Lower temperature according to temperature schedule

3

x

y 0.9

Temperature = 1

0.3

Page 32: Global Optimization with MATLAB® Products Account Manager

36

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Simulated Annealing Overview – Iteration 2 Lower temperature according to temperature schedule and generate new

point

3

x

y 0.9

Temperature = 0.75

0.3

-1.2

Page 33: Global Optimization with MATLAB® Products Account Manager

37

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Simulated Annealing Overview – Iteration N-1 After several iterations, the search radius becomes small and we narrow

in on a local solution

3

x

y 0.9

Temperature = 0.1

0.3

-1.2

-3

Page 34: Global Optimization with MATLAB® Products Account Manager

38

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Simulated Annealing Overview – Iteration N Reset temperature and start the process again (reanneling)

3

x

y 0.9

Temperature = 1

0.3

-1.2

-3

-2

Page 35: Global Optimization with MATLAB® Products Account Manager

39

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Simulated Annealing Overview – Iteration N Reset temperature and start the process again (reannealing)

3

x

y 0.9

Temperature = 1

0.3

-1.2

-3

-2

27.01

1/))3(2(

Taccepte

P

Page 36: Global Optimization with MATLAB® Products Account Manager

40

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Simulated Annealing Overview – Iteration N Reset temperature and start the process again (reannealing)

3

x

y 0.9

Temperature = 1

0.3

-1.2

-3

-2

Page 37: Global Optimization with MATLAB® Products Account Manager

41

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Simulated Annealing Overview – Iteration N+1 Reduce temperature and continue…

3

x

y 0.9

Temperature = 0.75

0.3

-1.2

-3

-2

-3

Page 38: Global Optimization with MATLAB® Products Account Manager

42

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Simulated Annealing Overview – Iteration N+1 Reduce temperature and continue…

3

x

y 0.9

Temperature = 0.75

0.3

-1.2

-3

-2

-3

Page 39: Global Optimization with MATLAB® Products Account Manager

43

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Simulated Annealing Overview – Iteration … Reduce temperature and continue…

3

x

y 0.9

Temperature = 0.75

0.3

-1.2

-3

-2

-3

-6.5

Page 40: Global Optimization with MATLAB® Products Account Manager

47

PATTERN SEARCH

(DIRECT SEARCH)

Page 41: Global Optimization with MATLAB® Products Account Manager

48

What is a Pattern Search?

An approach that uses a pattern of search directions around

the existing points, the mesh

Polls the mesh for a better solution and moves to that point

Expands/contracts the mesh around the current point when a

solution is not found

Does not rely on gradient information

Page 42: Global Optimization with MATLAB® Products Account Manager

49

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Pattern Search Overview – Iteration 1 Run from specified x0

x

y

3

Page 43: Global Optimization with MATLAB® Products Account Manager

50

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Pattern Search Overview – Iteration 1 Apply pattern vector, poll new points for improvement

x

y

3

Mesh size = 1

Pattern vectors = [1,0], [0,1], [-1,0], [-1,-1]

0_*_ xvectorpatternsizemeshPnew

0]0,1[*1 x1.6

0.4

4.6

2.8

First poll successful

Complete Poll (not default)

Page 44: Global Optimization with MATLAB® Products Account Manager

51

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Pattern Search Overview – Iteration 2 Increase mesh size and repeat…

x

y

3

Mesh size = 2

Pattern vectors = [1,0], [0,1], [-1,0], [-1,-1]

1.6

0.4

4.6

2.8

-4

0.3 -2.8

Complete Poll

Page 45: Global Optimization with MATLAB® Products Account Manager

52

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Pattern Search Overview – Iteration 3 Mesh expansion: increase mesh size and repeat…

x

y

3

Mesh size = 4

Pattern vectors = [1,0], [0,1], [-1,0], [-1,-1]

1.6

0.4

4.6

2.8

-4

0.3 -2.8

Page 46: Global Optimization with MATLAB® Products Account Manager

53

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Pattern Search Overview – Iteration 4 Refine mesh: decrease mesh size and repeat…

x

y

3

Mesh size = 4*0.5 = 2

Pattern vectors = [1,0], [0,1], [-1,0], [-1,-1]

1.6

0.4

4.6

2.8

-4

0.3 -2.8

Page 47: Global Optimization with MATLAB® Products Account Manager

54

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Pattern Search Overview – Iteration N Continue expansion/contraction until convergence…

x

y

3 1.6

0.4

4.6

2.8

-4

0.3 -2.8

-6.5

Page 48: Global Optimization with MATLAB® Products Account Manager

57

GENETIC ALGORITHM

Page 49: Global Optimization with MATLAB® Products Account Manager

58

What is a Genetic Algorithm?

Genetic Algorithms use concepts from evolutionary biology to

find exact or approximate solutions to optimization problems

Start with an initial generation of candidate solutions that are

tested against the objective function

Subsequent generations evolve from the 1st

through selection, crossover and mutation

The individual that best minimizes the given

objective is returned as the ideal solution

Page 50: Global Optimization with MATLAB® Products Account Manager

59

How Evolution Works – Binary Case

Selection

– Retain the best performing bit strings from one generation to the

next. Favor these for reproduction

– parent1 = [ 1 0 1 0 0 1 1 0 0 0 ]

– parent2 = [ 1 0 0 1 0 0 1 0 1 0 ]

Crossover

– parent1 = [ 1 0 1 0 0 1 1 0 0 0 ]

– parent2 = [ 1 0 0 1 0 0 1 0 1 0 ]

– child = [ 1 0 0 0 0 1 1 0 1 0 ]

Mutation

– parent = [ 1 0 1 0 0 1 1 0 0 0 ]

– child = [ 0 1 0 1 0 1 0 0 0 1 ]

Page 51: Global Optimization with MATLAB® Products Account Manager

60

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Genetic Algorithm – Iteration 1 Evaluate initial population

x

y

Page 52: Global Optimization with MATLAB® Products Account Manager

61

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Genetic Algorithm – Iteration 1 Select a few good solutions for reproduction

x

y

Page 53: Global Optimization with MATLAB® Products Account Manager

62

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Genetic Algorithm – Iteration 2 Generate new population and evaluate

x

y

Page 54: Global Optimization with MATLAB® Products Account Manager

63

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Genetic Algorithm – Iteration 2 Select a few good solutions for reproduction

x

y

Page 55: Global Optimization with MATLAB® Products Account Manager

64

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Genetic Algorithm – Iteration 3 Generate new population and evaluate

x

y

Page 56: Global Optimization with MATLAB® Products Account Manager

65

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Genetic Algorithm – Iteration 3 Select a few good solutions for reproduction

x

y

Page 57: Global Optimization with MATLAB® Products Account Manager

66

-3 -2 -1 0 1 2 3-3

-2

-1

0

1

2

3

Genetic Algorithm – Iteration N Continue process until stopping criteria are met

x

y

Solution found

Page 58: Global Optimization with MATLAB® Products Account Manager

69

Comparison of Solver (Default) Performance

x

y

rf([x,y])

-6 -4 -2 0 2 4 6-6

-4

-2

0

2

4

6

FuncValue

Min

StartPt

x

y

rf([x,y])

-60 -40 -20 0 20 40 60-60

-40

-20

0

20

40

60

FuncValue

Min

StartPt

x

y

rf([x,y])

-40 -20 0 20 40 60

-40

-20

0

20

40

60FuncValue

Min

StartPt

Page 59: Global Optimization with MATLAB® Products Account Manager

70

Page 60: Global Optimization with MATLAB® Products Account Manager

71

Additional Resources

Upcoming Webinars

Speeding Up Optimization with Parallel Computing

(August 2010)

On-demand Webinars

Genetic Algorithm in Financial Applications

Tips & Tricks: Getting Started with Optimization

Introduction to Optimization

Page 61: Global Optimization with MATLAB® Products Account Manager

72

Contact Information

North America

– Phone: 508-647-7000

– E-mail: [email protected]

Outside North America

– Contact your local MathWorks office or reseller:

www.mathworks.com/contact

Page 62: Global Optimization with MATLAB® Products Account Manager

73

Questions?

Page 63: Global Optimization with MATLAB® Products Account Manager

74

MATLAB Provides the Foundation for

Optimization

The leading environment for technical computing

– Customizable

– Numeric computation

– Data analysis and visualization

– The de facto industry-standard, high-level programming language for algorithm development

– Toolboxes for statistics, optimization, symbolic math, signal and image processing, and other areas

– Foundation of the MathWorks product family

Page 64: Global Optimization with MATLAB® Products Account Manager

75

Optimization Toolbox Solve standard and large-scale optimization problems

Graphical user interface and command line functions for: Linear and nonlinear programming

Quadratic programming

Nonlinear least squares and nonlinear equations

Multi-objective optimization

Binary integer programming

Additional Capabilities:

Parallel computing support in selected solvers

Customizable algorithm options

Choose between standard and large-scale algorithms

Output diagnostics

Page 65: Global Optimization with MATLAB® Products Account Manager

76

Global Optimization Toolbox Solve multiple maxima, multiple minima, and nonsmooth optimization problems

Graphical user interface and command line functions for: Global Search solver

Multistart solver

Genetic algorithm solver

– Single objective

– Multiobjective with Pareto front

Direct search solver

Simulated annealing solver

Useful for problems not easily addressed with Optimization Toolbox: Discontinuous

Highly nonlinear

Stochastic

Discrete or custom data types

Undefined derivatives

Multiple maxima/minima

Page 66: Global Optimization with MATLAB® Products Account Manager

77

Anatomy of an Optimization Problem

General Form Accepted by MATLAB Solvers

Objective Function

Subject to Constraints (i.e. such that)

uxl

xcbxA

xcbAx

eqeqeq

0)(,

0)(,

)(min xfx

Typically a linear or nonlinear function

Linear constraints

• inequalities

• equalities

• bounds

Nonlinear constraints

• inequalities

• equalities

Decision variables

Page 67: Global Optimization with MATLAB® Products Account Manager

78

MATLAB Optimization Products and Example

Applications

MATLAB Statistics Toolbox

Curve Fitting Toolbox

Optimization Toolbox Genetic Algorithm and

Direct Search Toolbox

Solving Equations

f(x) = 0

Root finding

Systems of equations

Real roots finding (1D):

Linear Systems:

F(x) = 0

Ax-b = 0 (i.e. Ax=b)

>> x = A \ b

Real roots finding (N-D):

Nonlinear Systems

F(X) = 0

Noisy, discontinuous root

finding (N-D)

Noisy, discontinuous systems:

F(X) = 0

Curve/Modeling

Fitting

curve fitting

parameter estimation

(model fitting)

Basic (linear) curve fitting Advanced (nonlinear) curve

fitting

Model Fitting (least squares)

Constrained curve fitting

Parameter Estimation

Noisy, Discontinuous

parameter estimation

Trade-Off Studies

Maximization

Minimization

Goal seeking

Multiobjective

Unconstrained nonlinear

minimization

Constrained nonlinear

minimization

Noisy, Discontinuous, ill-

defined mimization

-6 -4 -2 0 2 4 6-100

-50

0

50

100

x

x3-2 x-5

0 0.5 1 1.5 2 2.50.5

0.6

0.7

0.8

0.9