Top Banner
© 2008 The MathWorks, Inc. Tips & Tricks: Getting started with optimization in MATLAB® Stuart Kozola
14

Tips & Tricks: Getting started with optimization in MATLAB® · Tips & Tricks: Getting started with optimization in MATLAB® Stuart Kozola. 2 Agenda Optimization: What is it, Why

Mar 24, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Tips & Tricks: Getting started with optimization in MATLAB® · Tips & Tricks: Getting started with optimization in MATLAB® Stuart Kozola. 2 Agenda Optimization: What is it, Why

©20

08 T

he M

athW

orks

, Inc

.

Tips & Tricks: Getting started with optimization in MATLAB®

Stuart Kozola

Page 2: Tips & Tricks: Getting started with optimization in MATLAB® · Tips & Tricks: Getting started with optimization in MATLAB® Stuart Kozola. 2 Agenda Optimization: What is it, Why

2

Agenda

� Optimization: What is it, Why use it?

� Overview of MATLAB® Based Optimization Tools

� Demos: Tips, Tricks, and Best Practices

� Additional Resources

� Q&A

Page 3: Tips & Tricks: Getting started with optimization in MATLAB® · Tips & Tricks: Getting started with optimization in MATLAB® Stuart Kozola. 2 Agenda Optimization: What is it, Why

3

Optimization – Finding answers to problems automatically

Objectives Achieved?

NO

OptimalDesign

YESModel or Prototype

Modify DesignParameters

InitialDesign

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 Algorithmshttp://ic.arc.nasa.gov/projects/esg/research/antenna.htm

Manually

(trial-and-error or iteratively)

Automatically

(using optimization techniques)

Page 4: Tips & Tricks: Getting started with optimization in MATLAB® · Tips & Tricks: Getting started with optimization in MATLAB® Stuart Kozola. 2 Agenda Optimization: What is it, Why

4

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 5: Tips & Tricks: Getting started with optimization in MATLAB® · Tips & Tricks: Getting started with optimization in MATLAB® Stuart Kozola. 2 Agenda Optimization: What is it, Why

5

Optimization toolboxes support different problem types

�Custom data types

�More “global”

Better on � non-smooth� noisy� stochastic� highly nonlinear� ill-defined problems

�Larger Problems

�Faster

Genetic Algorithm &Direct Search Toolbox

OptimizationToolbox

Start Point

Pattern Search solution

Page 6: Tips & Tricks: Getting started with optimization in MATLAB® · Tips & Tricks: Getting started with optimization in MATLAB® Stuart Kozola. 2 Agenda Optimization: What is it, Why

6

Optimization Toolbox

� 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

� Parallel computing support in selected solvers

� Customizable algorithm options� Standard and large-scale algorithms� Output diagnostics

Page 7: Tips & Tricks: Getting started with optimization in MATLAB® · Tips & Tricks: Getting started with optimization in MATLAB® Stuart Kozola. 2 Agenda Optimization: What is it, Why

7

Genetic Algorithm and Direct Search Toolbox� Graphical user interface and

command line functions for:– 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

Page 8: Tips & Tricks: Getting started with optimization in MATLAB® · Tips & Tricks: Getting started with optimization in MATLAB® Stuart Kozola. 2 Agenda Optimization: What is it, Why

8

Demo

Page 9: Tips & Tricks: Getting started with optimization in MATLAB® · Tips & Tricks: Getting started with optimization in MATLAB® Stuart Kozola. 2 Agenda Optimization: What is it, Why

9

Curve Fitting Example

� MATLAB– Formulated as a linear system of equations

[ ]yEEyc

Ecc

cey

eccty

t

t

1

21

/

2

11

)(

==

=

=

+=t = [0 .3 .8 1.1 1.6 2.3]';

y = [.82 .72 .63 .60 .55 .50]';

E = [ones(size(t)) exp(-t)];

c = E\y

MATLAB Problem (linear system form)Problem Formulation

How? Least Squares Minimization(an optimization problem)

( )

2

2

2

2

2

min

0

yEc

yEc

yEc

yEc

Ecy

c−

≤−

≤−

=−=

∑ε

ε

=

50.0

55.0

60.0

63.0

72.0

82.0

1

1

1

1

1

1

2

1

1

3.2

6.1

1.1

8.0

3.0

0

e

e

e

e

e

e

c

c

Solve this overdetermined system of equations:

Can’t solve this exactly on a computer

This can be solved with acceptable error

An optimization problem!

Page 10: Tips & Tricks: Getting started with optimization in MATLAB® · Tips & Tricks: Getting started with optimization in MATLAB® Stuart Kozola. 2 Agenda Optimization: What is it, Why

10

Anatomy of an Optimization Problem

General Form Accepted by MATLAB SolversObjective 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 11: Tips & Tricks: Getting started with optimization in MATLAB® · Tips & Tricks: Getting started with optimization in MATLAB® Stuart Kozola. 2 Agenda Optimization: What is it, Why

11

Page 12: Tips & Tricks: Getting started with optimization in MATLAB® · Tips & Tricks: Getting started with optimization in MATLAB® Stuart Kozola. 2 Agenda Optimization: What is it, Why

12

Additional Resources

Upcoming webinars– TBD

Recorded webinars– Introduction to Optimization Toolbox

– Reliability Analysis and Robust Design with MATLAB products

– Genetic Algorithms in Financial Applications

Page 13: Tips & Tricks: Getting started with optimization in MATLAB® · Tips & Tricks: Getting started with optimization in MATLAB® Stuart Kozola. 2 Agenda Optimization: What is it, Why

13

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 14: Tips & Tricks: Getting started with optimization in MATLAB® · Tips & Tricks: Getting started with optimization in MATLAB® Stuart Kozola. 2 Agenda Optimization: What is it, Why

©20

08 T

he M

athW

orks

, Inc

.

Questions?