To control the surrogate optimization algorithm, use the following options.
InitialPoints — Specify initial points in one of two
Matrix — Each row of the matrix represents an initial point. The
length of each row is the same as the number of elements in the
ub. The number of
rows is arbitrary.
surrogateopt uses all the rows
to construct the initial surrogate. If there are fewer than
MinSurrogatePoints rows, then
surrogateopt generates the remaining initial
surrogateopt evaluates the objective
function at each initial point.
Structure — The structure contains the field
and, optionally, the field
X field contains a matrix where each row
represents an initial point. The
contains a vector representing the objective function values at each
time for the solver.
MinSurrogatePoints — Number of initial points used for
constructing the surrogate. Larger values lead to a more accurate finished
surrogate, but take more time to finish the surrogate.
surrogateopt creates this number of random points
after each switch to the random generation phase. See Surrogate Optimization Algorithm.
MinSampleDistance — This option controls two aspects of
During the phase to estimate the minimum value of the
surrogate, the algorithm generates random points at which to
evaluate the surrogate. If any of these points are closer than
MinSampleDistance to any previous point
whose objective function value was evaluated, then
surrogateopt discards the newly
generated points and does not evaluate them.
surrogateopt discards all of the
random points, then it does not try to minimize the surrogate
and, instead, switches to the random generation phase. If the
surrogateoptplot plot function is
running, then it marks this switch with a blue vertical
For details, see Surrogate Optimization Algorithm.
Generally, the algorithm stops only when it reaches a limit that you set. There
are three limits that you can set using
Additionally, a plot function or output function can halt the solver.
|Stopping Option||Stopping Test||Exit Flag|
|The solver stops after it completes
|The solver stops after it reaches |
|The solver stops if it obtains an objective function value less
than or equal to |
|Bounds ||If an entry in |
Display option to control what
surrogateopt returns to the command line.
'final' — Return only the exit message. This is the
'iter' — Return iterative display.
'off' or the equivalent
'none' — No
With an iterative display, the solver returns the following information in table format.
F-count — Number of function evaluations
Time(s) — Time in seconds since the solver
Best Fval — Lowest objective function value
Current Fval — Latest objective function value
An output function can halt the solver or perform a computation at each iteration.
To include an output function, set the
OutputFcn option to
myoutputfcn is a
function with the syntax described in the next paragraph. This syntax is the same as
Toolbox™ output functions, but with different meanings of the
optimValues arguments. For
information about those output functions, see Output Function Syntax (Optimization Toolbox).
For an example of an output function, see Integer Optimization with Custom Output Function.
The syntax of an output function is:
stop = outfun(x,optimValues,state)
surrogateopt passes the values of
state to the output
outfun, in this case) at each iteration. The output
stop, a Boolean value (
false) indicating whether to stop
x — The input argument
x is the best
point found so far, meaning the point with the lowest objective function
optimValues — This input argument is a structure
containing the following fields. For more information about these fields,
see Surrogate Optimization Algorithm.
How the current point was created.
Objective function value at the current point
Time in seconds since the solver started
How the best point was created
Total number of objective function evaluations
Lowest objective function value encountered
How the incumbent point was created
Objective function value at the incumbent point
Incumbent point, meaning the best point found since the last phase shift to random sampling
Boolean value indicating that the current iteration resets the model and switches to random sampling
Total number of times that
state — This input argument is the state of the
algorithm, specified as one of these values.
'init' — The algorithm is in the initial
state before the first iteration. When the algorithm is in this
state, you can set up plot axes or other data structures or open
'init', the input arguments
optimValues.fval are empty
surrogateopt is designed for
time-consuming objective functions, and so does not evaluate
the objective function before calling the initialization
'iter' — The algorithm just evaluated the
objective function. You perform most calculations and view most
displays when the algorithm is in this state.
'done' — The algorithm performed its final
objective function evaluation. When the algorithm is in this
state, you can close files, finish plots, or prepare in other
surrogateopt to stop.
A plot function displays information at each iteration. You can pause or halt the
solver by clicking buttons on the plot. To include a plot function, set the
PlotFcn option to a function handle or cell array of function
handles to plot functions. The three built-in plot functions are:
@optimplotfval (default) — Shows the best function
value. If you do not choose a plot function,
@optimplotx — Shows the best point found as a bar
@surrogateoptplot — Shows the current objective
function value, best function value, and information about the algorithm
phase. See Interpret surrogateoptplot.
You can write a custom plot function using the syntax of an Output Function. For an example,
examine the code for
@surrogateoptplot by entering
surrogateoptplot at the MATLAB® command line.
If you set the
'UseParallel' option to
surrogateopt computes in parallel. Computing in parallel
requires a Parallel
Computing Toolbox™ license. For details, see Surrogate Optimization Algorithm.
When you set the name of a checkpoint file using the
writes data to the file after each iteration, which enables the function to resume
the optimization from the current state. When restarting,
surrogateopt does not evaluate the objective function value
at previously evaluated points.
A checkpoint file can be a file path such as
"C:\Documents\MATLAB\check1.mat" or a file name such as
'checkpoint1June2019.mat'. If you specify a file name without
surrogateopt saves the checkpoint file in the current
You can change only the following options when resuming the optimization:
To resume the optimization from a checkpoint file, call
surrogateopt with the file name as the first
[x,fval,exitflag,output] = surrogateopt('check1.mat')
To resume the optimization using new options, include the new options as the second argument.
opts = optimoptions(options,'MaxFunctionEvaluations',500); [x,fval,exitflag,output] = surrogateopt('check1.mat',opts)
During the restart,
surrogateopt runs any output functions
and plot functions, based on the original function evaluations. So, for example, you
can create a different plot based on an optimization that already ran. See Work with Checkpoint Files.
surrogateopt does not save all details of the state in
the checkpoint file. Therefore, subsequent iterations can differ from the
iterations that the solver takes without stopping at the checkpointed
Checkpointing takes time. This overhead is especially noticeable for functions that otherwise take little time to evaluate.
Do not resume
surrogateopt from a checkpoint file created with a
different MATLAB version.
surrogateopt can error or give inconsistent