Global Optimization Toolbox
User's Guide
R2019a
How to Contact MathWorks
Latest news:
www.mathworks.com
Sales and services:
www.mathworks.com/sales_and_services
User community:
Technical support:
Phone:
www.mathworks.com/matlabcentral
www.mathworks.com/support/contact_us
508-647-7000
The MathWorks, Inc.
1 Apple Hill Drive
Natick, MA 01760-2098
Global Optimization Toolbox User's Guide
© COPYRIGHT 2004–2019 by The MathWorks, Inc.
The software described in this document is furnished under a license agreement. The software may be used
or copied only under the terms of the license agreement. No part of this manual may be photocopied or
reproduced in any form without prior written consent from The MathWorks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation by,
for, or through the federal government of the United States. By accepting delivery of the Program or
Documentation, the government hereby agrees that this software or documentation qualifies as commercial
computer software or commercial computer software documentation as such terms are used or defined in
FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and conditions of this
Agreement and only those rights specified in this Agreement, shall pertain to and govern the use,
modification, reproduction, release, performance, display, and disclosure of the Program and
Documentation by the federal government (or other entity acquiring for or through the federal government)
and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the
government's needs or is inconsistent in any respect with federal procurement law, the government agrees
to return the Program and Documentation, unused, to The MathWorks, Inc.
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand
names may be trademarks or registered trademarks of their respective holders.
Patents
MathWorks products are protected by one or more U.S. patents. Please see
www.mathworks.com/patents for more information.
Online only
First printing
Online only
Online only
Revision History
January 2004
June 2004
October 2004
March 2005
September 2005 Second printing
March 2006
Online only
September 2006 Online only
March 2007
Online only
September 2007 Third printing
March 2008
Online only
October 2008
Online only
March 2009
Online only
September 2009 Online only
March 2010
Online only
September 2010 Online only
April 2011
Online only
September 2011 Online only
March 2012
Online only
September 2012 Online only
March 2013
Online only
September 2013 Online only
Online only
March 2014
Online only
October 2014
March 2015
Online only
September 2015 Online only
March 2016
Online only
September 2016 Online only
March 2017
Online only
September 2017 Online only
March 2018
Online only
September 2018 Online only
Online only
March 2019
New for Version 1.0 (Release 13SP1+)
Revised for Version 1.0.1 (Release 14)
Revised for Version 1.0.2 (Release 14SP1)
Revised for Version 1.0.3 (Release 14SP2)
Revised for Version 2.0 (Release 14SP3)
Revised for Version 2.0.1 (Release 2006a)
Revised for Version 2.0.2 (Release 2006b)
Revised for Version 2.1 (Release 2007a)
Revised for Version 2.2 (Release 2007b)
Revised for Version 2.3 (Release 2008a)
Revised for Version 2.4 (Release 2008b)
Revised for Version 2.4.1 (Release 2009a)
Revised for Version 2.4.2 (Release 2009b)
Revised for Version 3.0 (Release 2010a)
Revised for Version 3.1 (Release 2010b)
Revised for Version 3.1.1 (Release 2011a)
Revised for Version 3.2 (Release 2011b)
Revised for Version 3.2.1 (Release 2012a)
Revised for Version 3.2.2 (Release 2012b)
Revised for Version 3.2.3 (Release 2013a)
Revised for Version 3.2.4 (Release 2013b)
Revised for Version 3.2.5 (Release 2014a)
Revised for Version 3.3 (Release 2014b)
Revised for Version 3.3.1 (Release 2015a)
Revised for Version 3.3.2 (Release 2015b)
Revised for Version 3.4 (Release 2016a)
Revised for Version 3.4.1 (Release 2016b)
Revised for Version 3.4.2 (Release 2017a)
Revised for Version 3.4.3 (Release 2017b)
Revised for Version 3.4.4 (Release 2018a)
Revised for Version 4.0 (Release 2018b)
Revised for Version 4.1 (Release 2019a)
Contents
Getting Started
1
Introducing Global Optimization Toolbox
Functions
Global Optimization Toolbox Product Description . . . . . .
Key Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Comparison of Six Solvers . . . . . . . . . . . . . . . . . . . . . . . . .
Function to Optimize . . . . . . . . . . . . . . . . . . . . . . . . . . .
Six Solution Methods . . . . . . . . . . . . . . . . . . . . . . . . . . .
Compare Syntax and Solutions . . . . . . . . . . . . . . . . . . .
Solver Behavior with a Nonsmooth Problem . . . . . . . . . .
What Is Global Optimization? . . . . . . . . . . . . . . . . . . . . . .
Local vs. Global Optima . . . . . . . . . . . . . . . . . . . . . . . .
Basins of Attraction . . . . . . . . . . . . . . . . . . . . . . . . . . .
Optimization Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . .
Table for Choosing a Solver . . . . . . . . . . . . . . . . . . . . . . .
Global Optimization Toolbox Solver Characteristics . . .
Solver Choices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Explanation of “Desired Solution” . . . . . . . . . . . . . . . . .
Choosing Between Solvers for Smooth Problems . . . . . .
Choosing Between Solvers for Nonsmooth Problems . . .
Solver Characteristics . . . . . . . . . . . . . . . . . . . . . . . . .
Why Are Some Solvers Objects? . . . . . . . . . . . . . . . . . .
1-2
1-2
1-3
1-3
1-4
1-11
1-13
1-22
1-22
1-23
1-28
1-29
1-31
1-31
1-32
1-34
1-35
1-36
1-39
v
2
Write Files for Optimization Functions
Compute Objective Functions . . . . . . . . . . . . . . . . . . . . . . .
Objective (Fitness) Functions . . . . . . . . . . . . . . . . . . . . .
Write a Function File . . . . . . . . . . . . . . . . . . . . . . . . . . .
Write a Vectorized Function . . . . . . . . . . . . . . . . . . . . . .
Gradients and Hessians . . . . . . . . . . . . . . . . . . . . . . . . .
Maximizing vs. Minimizing . . . . . . . . . . . . . . . . . . . . . . . . .
Write Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Consult Optimization Toolbox Documentation . . . . . . . . .
Set Bounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Ensure ga Options Maintain Feasibility . . . . . . . . . . . . . .
Gradients and Hessians . . . . . . . . . . . . . . . . . . . . . . . . .
Vectorized Constraints . . . . . . . . . . . . . . . . . . . . . . . . . .
Set and Change Options . . . . . . . . . . . . . . . . . . . . . . . . . .
View Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2-2
2-2
2-2
2-3
2-4
2-6
2-8
2-8
2-8
2-9
2-9
2-9
2-12
2-14
3
Using GlobalSearch and MultiStart
Problems That GlobalSearch and MultiStart Can Solve . . . . . .
Workflow for GlobalSearch and MultiStart . . . . . . . . . . . . . . . .
Create Problem Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
About Problem Structures . . . . . . . . . . . . . . . . . . . . . . . . . . .
Using the createOptimProblem Function . . . . . . . . . . . . . . . .
Exporting from the Optimization app . . . . . . . . . . . . . . . . . . .
Create Solver Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
What Is a Solver Object? . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Properties (Global Options) of Solver Objects . . . . . . . . . . . .
Creating a Nondefault GlobalSearch Object . . . . . . . . . . . . .
Creating a Nondefault MultiStart Object . . . . . . . . . . . . . . . .
3-2
3-3
3-5
3-5
3-5
3-8
3-13
3-13
3-13
3-15
3-15
vi
Contents
Set Start Points for MultiStart . . . . . . . . . . . . . . . . . . . . . . . . .
Four Ways to Set Start Points . . . . . . . . . . . . . . . . . . . . . . . .
Positive Integer for Start Points . . . . . . . . . . . . . . . . . . . . . .
RandomStartPointSet Object for Start Points . . . . . . . . . . . .
CustomStartPointSet Object for Start Points . . . . . . . . . . . . .
Cell Array of Objects for Start Points . . . . . . . . . . . . . . . . . .
Run the Solver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Optimize by Calling run . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Example of Run with GlobalSearch . . . . . . . . . . . . . . . . . . . .
Example of Run with MultiStart . . . . . . . . . . . . . . . . . . . . . .
Single Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Multiple Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
About Multiple Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . .
Change the Definition of Distinct Solutions . . . . . . . . . . . . . .
Iterative Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Types of Iterative Display . . . . . . . . . . . . . . . . . . . . . . . . . . .
Examine Types of Iterative Display . . . . . . . . . . . . . . . . . . . .
Global Output Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Visualize the Basins of Attraction . . . . . . . . . . . . . . . . . . . . . .
Output Functions for GlobalSearch and MultiStart . . . . . . . .
What Are Output Functions? . . . . . . . . . . . . . . . . . . . . . . . . .
GlobalSearch Output Function . . . . . . . . . . . . . . . . . . . . . . .
No Parallel Output Functions . . . . . . . . . . . . . . . . . . . . . . . .
Plot Functions for GlobalSearch and MultiStart . . . . . . . . . .
What Are Plot Functions? . . . . . . . . . . . . . . . . . . . . . . . . . . .
MultiStart Plot Function . . . . . . . . . . . . . . . . . . . . . . . . . . . .
No Parallel Plot Functions . . . . . . . . . . . . . . . . . . . . . . . . . .
How GlobalSearch and MultiStart Work . . . . . . . . . . . . . . . . .
Multiple Runs of a Local Solver . . . . . . . . . . . . . . . . . . . . . .
Differences Between the Solver Objects . . . . . . . . . . . . . . . .
GlobalSearch Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . .
MultiStart Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3-17
3-17
3-17
3-18
3-18
3-19
3-21
3-21
3-22
3-23
3-25
3-27
3-27
3-30
3-33
3-33
3-33
3-36
3-37
3-40
3-40
3-40
3-42
3-44
3-44
3-45
3-47
3-49
3-49
3-49
3-51
3-55
3-57
vii
Can You Certify That a Solution Is Global? . . . . . . . . . . . . . . .
No Guarantees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Check if a Solution Is a Local Solution with patternsearch . .
Identify a Bounded Region That Contains a Global Solution .
Use MultiStart with More Start Points . . . . . . . . . . . . . . . . .
Refine Start Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
About Refining Start Points . . . . . . . . . . . . . . . . . . . . . . . . . .
Methods of Generating Start Points . . . . . . . . . . . . . . . . . . .
Example: Searching for a Better Solution . . . . . . . . . . . . . . .
Change Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
How to Determine Which Options to Change . . . . . . . . . . . .
Changing Local Solver Options . . . . . . . . . . . . . . . . . . . . . . .
Changing Global Options . . . . . . . . . . . . . . . . . . . . . . . . . . .
Reproduce Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Identical Answers with Pseudorandom Numbers . . . . . . . . . .
Steps to Take in Reproducing Results . . . . . . . . . . . . . . . . . .
Example: Reproducing a GlobalSearch or MultiStart Result .
Parallel Processing and Random Number Streams . . . . . . . .
Find Global or Multiple Local Minima . . . . . . . . . . . . . . . . . . .
Function to Optimize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Single Global Minimum Via GlobalSearch . . . . . . . . . . . . . . .
Multiple Local Minima Via MultiStart . . . . . . . . . . . . . . . . . .
Maximizing Monochromatic Polarized Light Interference
Patterns Using GlobalSearch and MultiStart . . . . . . . . . . .
Optimize Using Only Feasible Start Points . . . . . . . . . . . . . .
MultiStart Using lsqcurvefit or lsqnonlin . . . . . . . . . . . . . . .
Parallel MultiStart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Steps for Parallel MultiStart . . . . . . . . . . . . . . . . . . . . . . . .
Speedup with Parallel Computing . . . . . . . . . . . . . . . . . . . .
Isolated Global Minimum . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Difficult-To-Locate Global Minimum . . . . . . . . . . . . . . . . . .
Default Settings Cannot Find the Global Minimum — Add
Bounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
GlobalSearch with Bounds and More Start Points . . . . . . . .
3-59
3-59
3-59
3-60
3-61
3-62
3-62
3-63
3-65
3-71
3-71
3-72
3-73
3-75
3-75
3-75
3-75
3-77
3-78
3-78
3-80
3-82
3-86
3-103
3-108
3-114
3-114
3-116
3-117
3-117
3-119
3-119
viii
Contents