MATLAB Global Optimization Toolbox User s Guide The Mathworks All Chapters Instant Download
MATLAB Global Optimization Toolbox User s Guide The Mathworks All Chapters Instant Download
com
https://textbookfull.com/product/matlab-global-optimization-
toolbox-user-s-guide-the-mathworks/
OR CLICK BUTTON
DOWNLOAD NOW
https://textbookfull.com/product/matlab-optimization-toolbox-user-s-
guide-the-mathworks/
textboxfull.com
https://textbookfull.com/product/matlab-econometrics-toolbox-user-s-
guide-the-mathworks/
textboxfull.com
https://textbookfull.com/product/matlab-bioinformatics-toolbox-user-s-
guide-the-mathworks/
textboxfull.com
https://textbookfull.com/product/matlab-mapping-toolbox-user-s-guide-
the-mathworks/
textboxfull.com
MATLAB Trading Toolbox User s Guide The Mathworks
https://textbookfull.com/product/matlab-trading-toolbox-user-s-guide-
the-mathworks/
textboxfull.com
https://textbookfull.com/product/matlab-computer-vision-toolbox-user-
s-guide-the-mathworks/
textboxfull.com
https://textbookfull.com/product/matlab-curve-fitting-toolbox-user-s-
guide-the-mathworks/
textboxfull.com
https://textbookfull.com/product/matlab-fuzzy-logic-toolbox-user-s-
guide-the-mathworks/
textboxfull.com
https://textbookfull.com/product/matlab-image-processing-toolbox-user-
s-guide-the-mathworks/
textboxfull.com
Global Optimization Toolbox
User's Guide
R2020a
How to Contact MathWorks
Phone: 508-647-7000
Getting Started
v
Write Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
Consult Optimization Toolbox Documentation . . . . . . . . . . . . . . . . . . 2-6
Set Bounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
Ensure ga Options Maintain Feasibility . . . . . . . . . . . . . . . . . . . . . . . 2-6
Gradients and Hessians . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7
Vectorized Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7
vi Contents
Visualize the Basins of Attraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27
vii
Speedup with Parallel Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-86
viii Contents
Search and Poll . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-38
Using a Search Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-38
Search Using a Different Solver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-40
ix
Displaying Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6
Resume ga . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-59
Resuming ga From the Final Population . . . . . . . . . . . . . . . . . . . . . . . . . 5-59
Resuming ga From a Previous Run . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-62
x Contents
Additional Output Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-65
xi
Particle Swarm Optimization Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-9
Algorithm Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-9
Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-9
Iteration Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-10
Stopping Criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-11
Surrogate Optimization
7
What Is Surrogate Optimization? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2
xii Contents
Solve Nonlinear Problem with Integer and Nonlinear Constraints . . . . . 7-82
Multiobjective Optimization
9
What Is Multiobjective Optimization? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-2
xiii
Initialize Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-13
Create Archive and Incumbents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-13
Poll to Find Better Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-13
Update archive and iterates Structures . . . . . . . . . . . . . . . . . . . . . . . . . . 9-14
Stopping Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-14
Returned Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-15
Modifications for Parallel Computation and Vectorized Function Evaluation
..................................................... 9-15
Run paretosearch Quickly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-15
Parallel Processing
10
How Solvers Compute in Parallel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2
Parallel Processing Types in Global Optimization Toolbox . . . . . . . . . . . . 10-2
How Toolbox Functions Distribute Processes . . . . . . . . . . . . . . . . . . . . . 10-3
xiv Contents
Options Reference
11
GlobalSearch and MultiStart Properties (Options) . . . . . . . . . . . . . . . . . 11-2
How to Set Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2
Properties of Both Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2
GlobalSearch Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-5
MultiStart Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-6
xv
Command-Line Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-53
Output Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-54
Plot Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-56
Parallel Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-56
Checkpoint File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-57
Functions
12
xvi Contents
Getting Started
17
1
Global Optimization Toolbox provides functions that search for global solutions to problems that
contain multiple maxima or minima. Toolbox solvers include surrogate, pattern search, genetic
algorithm, particle swarm, simulated annealing, multistart, and global search. You can use these
solvers for optimization problems where the objective or constraint function is continuous,
discontinuous, stochastic, does not possess derivatives, or includes simulations or black-box
functions. For problems with multiple objectives, you can identify a Pareto front using genetic
algorithm or pattern search solvers.
You can improve solver effectiveness by adjusting options and, for applicable solvers, customizing
creation, update, and search functions. You can use custom data types with the genetic algorithm and
simulated annealing solvers to represent problems not easily expressed with standard data types. The
hybrid function option lets you improve a solution by applying a second solver after the first.
Key Features
• Surrogate solver for problems with lengthy objective function execution times and bound
constraints
• Pattern search solvers for single and multiple objective problems with linear, nonlinear, and bound
constraints
• Genetic algorithm for problems with linear, nonlinear, bound, and integer constraints
• Multiobjective genetic algorithm for problems with linear, nonlinear, and bound constraints
• Particle swarm solver for bound constraints
• Simulated annealing solver for bound constraints
• Multistart and global search solvers for smooth problems with linear, nonlinear, and bound
constraints
1-2
Comparison of Six Solvers
Function to Optimize
This example shows how to minimize Rastrigin’s function with six solvers. Each solver has its own
characteristics. The characteristics lead to different solutions and run times. The results, examined in
“Compare Syntax and Solutions” on page 1-9, can help you choose an appropriate solver for your
own problems.
Rastrigin’s function has many local minima, with a global minimum at (0,0):
Usually you don't know the location of the global minimum of your objective function. To show how
the solvers look for a global solution, this example starts all the solvers around the point [20,30],
which is far from the global minimum.
The rastriginsfcn.m file implements Rastrigin’s function. This file comes with Global Optimization
Toolbox software. This example employs a scaled version of Rastrigin’s function with larger basins of
attraction. For information, see “Basins of Attraction” on page 1-19.
rf2 = @(x)rastriginsfcn(x/10);
1-3
1 Introducing Global Optimization Toolbox Functions
This example minimizes rf2 using the default settings of fminunc (an Optimization Toolbox™
solver), patternsearch, and GlobalSearch. The example also uses ga and particleswarm with
nondefault options to start with an initial population around the point [20,30]. Because
surrogateopt requires finite bounds, the example uses surrogateopt with lower bounds of -70
and upper bounds of 130 in each variable.
fminunc
To solve the optimization problem using the fminunc Optimization Toolbox solver, enter:
rf2 = @(x)rastriginsfcn(x/10); % objective
x0 = [20,30]; % start point away from the minimum
[xf,ff,flf,of] = fminunc(rf2,x0)
fminunc returns
1-4
Comparison of Six Solvers
xf =
19.8991 29.8486
ff =
12.9344
flf =
1
of =
iterations: 3
funcCount: 15
stepsize: 1.7776e-06
lssteplength: 1
firstorderopt: 5.9907e-09
algorithm: 'quasi-newton'
message: 'Local minimum found.…'
patternsearch
To solve the optimization problem using the patternsearch Global Optimization Toolbox solver,
enter:
rf2 = @(x)rastriginsfcn(x/10); % objective
x0 = [20,30]; % start point away from the minimum
[xp,fp,flp,op] = patternsearch(rf2,x0)
patternsearch returns
Optimization terminated: mesh size less than options.MeshTolerance.
xp =
19.8991 -9.9496
fp =
4.9748
flp =
1
op =
function: @(x)rastriginsfcn(x/10)
problemtype: 'unconstrained'
pollmethod: 'gpspositivebasis2n'
maxconstraint: []
searchmethod: []
iterations: 48
funccount: 174
1-5
1 Introducing Global Optimization Toolbox Functions
meshsize: 9.5367e-07
rngstate: [1x1 struct]
message: 'Optimization terminated: mesh size less than options.MeshTolerance.'
ga
To solve the optimization problem using the ga Global Optimization Toolbox solver, enter:
initpop is a 20-by-2 matrix. Each row of initpop has mean [20,30], and each element is normally
distributed with standard deviation 10. The rows of initpop form an initial population matrix for the
ga solver.
ga uses random numbers, and produces a random result. In this case ga returns:
xga =
-0.0042 -0.0024
fga =
4.7054e-05
flga =
oga =
problemtype: 'unconstrained'
rngstate: [1×1 struct]
generations: 200
funccount: 9453
1-6
Comparison of Six Solvers
particleswarm
xpso =
9.9496 0.0000
fpso =
0.9950
flgpso =
opso =
1-7
1 Introducing Global Optimization Toolbox Functions
surrogateopt
surrogateopt does not require a start point, but does require finite bounds. Set bounds of –70 to
130 in each component. To have the same sort of output as the other solvers, disable the default plot
function.
rng default % for reproducibility
lb = [-70,-70];
ub = [130,130];
rf2 = @(x)rastriginsfcn(x/10); % objective
opts = optimoptions('surrogateopt','PlotFcn',[]);
[xsur,fsur,flgsur,osur] = surrogateopt(rf2,lb,ub,opts)
xsur =
-0.0033 0.0005
fsur =
2.2456e-05
flgsur =
osur =
elapsedtime: 2.3877
funccount: 200
rngstate: [1×1 struct]
message: 'Surrogateopt stopped because it exceeded the function evaluation limit set by ↵
GlobalSearch
1-8
Comparison of Six Solvers
problem is an optimization problem structure. problem specifies the fmincon solver, the rf2
objective function, and x0=[20,30]. For more information on using createOptimProblem, see
“Create Problem Structure” on page 3-4.
Note You must specify fmincon as the solver for GlobalSearch, even for unconstrained problems.
gs is a default GlobalSearch object. The object contains options for solving the problem. Calling
run(gs,problem) runs problem from multiple start points. The start points are random, so the
following result is also random.
All 10 local solver runs converged with a positive local solver exit flag.
xg =
1.0e-07 *
-0.1405 -0.1405
fg =
flg =
og =
funcCount: 2350
localSolverTotal: 10
localSolverSuccess: 10
localSolverIncomplete: 0
localSolverNoSolution: 0
message: 'GlobalSearch stopped because it analyzed all the trial points.↵↵All 10 local solver runs converged with a po
1-9
1 Introducing Global Optimization Toolbox Functions
• fminunc quickly reaches the local solution within its starting basin, but does not explore outside
this basin at all. fminunc has a simple calling syntax.
• patternsearch takes more function evaluations than fminunc, and searches through several
basins, arriving at a better solution than fminunc. The patternsearch calling syntax is the
same as that of fminunc.
• ga takes many more function evaluations than patternsearch. By chance it arrived at a better
solution. In this case, ga found a point near the global optimum. ga is stochastic, so its results
change with every run. ga has a simple calling syntax, but there are extra steps to have an initial
population near [20,30].
• particleswarm takes fewer function evaluations than ga, but more than patternsearch. In
this case, particleswarm found a point with lower objective function value than
patternsearch, but higher than ga. Because particleswarm is stochastic, its results change
with every run. particleswarm has a simple calling syntax, but there are extra steps to have an
initial population near [20,30].
• surrogateopt stops when it reaches a function evaluation limit, which by default is 200 for a
two-variable problem. surrogateopt has a simple calling syntax, but requires finite bounds.
surrogateopt attempts to find a global solution, and in this case succeeded. Each function
evaluation in surrogateopt takes a longer time than in most other solvers, because
surrogateopt performs many auxiliary computations as part of its algorithm.
• GlobalSearch run takes the same order of magnitude of function evaluations as ga and
particleswarm, searches many basins, and arrives at a good solution. In this case,
GlobalSearch found the global optimum. Setting up GlobalSearch is more involved than
setting up the other solvers. As the example shows, before calling GlobalSearch, you must
create both a GlobalSearch object (gs in the example), and a problem structure (problem).
Then, you call the run method with gs and problem. For more details on how to run
GlobalSearch, see “Workflow for GlobalSearch and MultiStart” on page 3-3.
See Also
More About
• “Optimization Problem Setup”
• “Solver Behavior with a Nonsmooth Problem” on page 1-11
1-10
Solver Behavior with a Nonsmooth Problem
In general, the solver decision tables provide guidance on which solver is likely to work best for your
problem. For smooth problems, see “Optimization Decision Table” (Optimization Toolbox). For
nonsmooth problems, see “Table for Choosing a Solver” on page 1-23 first, and for more information
consult “Global Optimization Toolbox Solver Characteristics” on page 1-24.
1/2
The function f (x) = x is nonsmooth at the point 0, which is the minimizing point. Here is a 2-D
x(1) x(2)
plot using the matrix norm for the 4-D point .
0 0
figure
x = linspace(-5,5,51);
[xx,yy] = meshgrid(x);
zz = zeros(size(xx));
for ii = 1:length(x)
for jj = 1:length(x)
zz(ii,jj) = sqrt(norm([xx(ii,jj),yy(ii,jj);0,0]));
end
end
surf(xx,yy,zz)
xlabel('x(1)')
ylabel('x(2)')
title('Norm([x(1),x(2);0,0])^{1/2}')
1-11
Discovering Diverse Content Through
Random Scribd Documents
copies of the works possessed in a physical medium and
discontinue all use of and all access to other copies of Project
Gutenberg™ works.
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
1.F.4. Except for the limited right of replacement or refund set forth in
paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com