surrogateopt - Surrogate optimization for global minimization of time-consuming objective

        functions - MATLAB ([original](https://in.mathworks.com/help/gads/surrogateopt.html)) ([raw](?raw))

Surrogate optimization for global minimization of time-consuming objective functions

Syntax

Description

surrogateopt is a global solver for time-consuming objective functions.

surrogateopt attempts to solve problems of the form

The solver searches for the global minimum of a real-valued objective function in multiple dimensions, subject to bounds, optional linear constraints, optional integer constraints, and optional nonlinear inequality constraints.surrogateopt is best suited to objective functions that take a long time to evaluate. The objective function can be nonsmooth. The solver requires finite bounds on all variables. The solver can optionally maintain a checkpoint file to enable recovery from crashes or partial execution, or optimization continuation after meeting a stopping condition. The objective function_f_(x) can be empty ([]), in which case surrogateopt attempts to find a point satisfying all the constraints.

[x](#mw%5Feedaab90-3a2f-4dad-bc9a-f1945f16e2ab) = surrogateopt([objconstr](#mw%5F61b86098-d547-4563-afb7-af5c91912fd6),[lb](#mw%5Fdbf50a47-efee-476b-86c5-0d2c0d0e27b3),[ub](#mw%5F5048c1ef-7a27-436e-a0e4-18608813187f)) searches for a global minimum of objconstr(x) in the regionlb <= x <= ub. If objconstr(x) returns a structure, then surrogateopt searches for a minimum of objconstr(x).Fval, subject toobjconstr(x).Ineq <= 0.

example

[x](#mw%5Feedaab90-3a2f-4dad-bc9a-f1945f16e2ab) = surrogateopt([objconstr](#mw%5F61b86098-d547-4563-afb7-af5c91912fd6),[lb](#mw%5Fdbf50a47-efee-476b-86c5-0d2c0d0e27b3),[ub](#mw%5F5048c1ef-7a27-436e-a0e4-18608813187f),[intcon](#mw%5F27e51e6e-15cf-408c-aecc-06d507185d40)) requires that the variables listed in intcon take integer values.

example

[x](#mw%5Feedaab90-3a2f-4dad-bc9a-f1945f16e2ab) = surrogateopt([objconstr](#mw%5F61b86098-d547-4563-afb7-af5c91912fd6),[lb](#mw%5Fdbf50a47-efee-476b-86c5-0d2c0d0e27b3),[ub](#mw%5F5048c1ef-7a27-436e-a0e4-18608813187f),[intcon](#mw%5F27e51e6e-15cf-408c-aecc-06d507185d40),[A](#d126e72756),[b](#mw%5F9bfd5d1d-859b-4c72-b98a-43c8cdffa088%5Fsep%5Fbuxdit7-b),[Aeq](#d126e72915),[beq](#mw%5F9bfd5d1d-859b-4c72-b98a-43c8cdffa088%5Fsep%5Fbuxdit7-beq)) requires that the solution x satisfy the inequalitiesA*x <= b and the equalities Aeq*x = beq. If no inequalities exist, set A = [] andb = []. Similarly, if no equalities exist, setAeq = [] and beq = [].

example

[x](#mw%5Feedaab90-3a2f-4dad-bc9a-f1945f16e2ab) = surrogateopt(___,[options](#mw%5Ffa3519af-f062-41df-af65-c65ea7a54eb6)) modifies the search procedure using the options in options. Specify options following any input argument combination in the previous syntaxes.

example

[x](#mw%5Feedaab90-3a2f-4dad-bc9a-f1945f16e2ab) = surrogateopt([problem](#mw%5F02738a3c-d151-4c26-a11c-f28fc45334a0)) searches for a minimum for problem, a structure described inproblem.

example

[x](#mw%5Feedaab90-3a2f-4dad-bc9a-f1945f16e2ab) = surrogateopt([checkpointFile](#mw%5F18ead528-cf4a-40a3-bc8a-8c026f2c93b8),[opts](#mw%5F5a1bdfbf-632e-485a-a9a7-2f58f8d2febb)) continues running the optimization from the state in a saved checkpoint file, and replaces options in checkpointFile with those inopts. See Checkpoint File.

example

[[x](#mw%5Feedaab90-3a2f-4dad-bc9a-f1945f16e2ab),[fval](#mw%5F9bdf44db-8ff0-4cdb-a58a-0a298cb479be)] = surrogateopt(___) also returns the best (smallest) value of the objective function found by the solver, using any of the input argument combinations in the previous syntaxes.

example

[[x](#mw%5Feedaab90-3a2f-4dad-bc9a-f1945f16e2ab),[fval](#mw%5F9bdf44db-8ff0-4cdb-a58a-0a298cb479be),[exitflag](#mw%5Fbda07112-0768-4281-806e-5aef112e870c),[output](#mw%5Ffaa18963-4146-488f-b88b-cacc98b213cd)] = surrogateopt(___) also returns exitflag, an integer describing the reason the solver stopped, and output, a structure describing the optimization procedure.

example

[[x](#mw%5Feedaab90-3a2f-4dad-bc9a-f1945f16e2ab),[fval](#mw%5F9bdf44db-8ff0-4cdb-a58a-0a298cb479be),[exitflag](#mw%5Fbda07112-0768-4281-806e-5aef112e870c),[output](#mw%5Ffaa18963-4146-488f-b88b-cacc98b213cd),[trials](#mw%5Fa0e6c0e6-9ae3-48c8-9dd2-47063b473dc7)] = surrogateopt(___) also returns a structure containing all of the evaluated points and the objective function values at those points.

example

Examples

collapse all

Search for a minimum of the six-hump camel back function in the region -2.1 <= x(i) <= 2.1. This function has two global minima with the objective function value -1.0316284... and four local minima with higher objective function values.

rng default % For reproducibility objconstr = @(x)(4x(:,1).^2 - 2.1x(:,1).^4 + x(:,1).^6/3 ... + x(:,1).x(:,2) - 4x(:,2).^2 + 4*x(:,2).^4); lb = [-2.1,-2.1]; ub = -lb; x = surrogateopt(objconstr,lb,ub)

Figure Optimization Plot Function contains an axes object. The axes object with title Best Function Value: -1.03163, xlabel Iteration, ylabel Function value contains an object of type scatter. This object represents Best function value.

surrogateopt stopped because it exceeded the function evaluation limit set by 'options.MaxFunctionEvaluations'.

Find the minimum of Rosenbrock's function

100(x(2)-x(1)2)2+(1-x(1))2

subject to the nonlinear constraint that the solution lies in a disk of radius 1/3 around the point [1/3,1/3]:

(x(1)-1/3)2+(x(2)-1/3)2≤(1/3)2.

To do so, write a function objconstr(x) that returns the value of Rosenbrock's function in a structure field Fval, and returns the nonlinear constraint value in the form c(x)≤0 in the structure field Ineq.

function f = objconstr(x) f.Fval = 100*(x(2) - x(1)^2)^2 + (1 - x(1))^2; f.Ineq = (x(1)-1/3)^2 + (x(2)-1/3)^2 - (1/3)^2;

Call surrogateopt using lower bounds of 0 and upper bounds of 2/3 on each component.

lb = [0,0]; ub = [2/3,2/3]; [x,fval,exitflag] = surrogateopt(@objconstr,lb,ub)

Figure Optimization Plot Function contains an axes object. The axes object with title Best Function Value: 0.119376, xlabel Iteration, ylabel Function value contains 2 objects of type scatter. These objects represent Best function value, Best function value (infeasible).

surrogateopt stopped because it exceeded the function evaluation limit set by 'options.MaxFunctionEvaluations'.

Check the value of the nonlinear constraint at the solution.

The constraint function value is near zero, indicating that the constraint is active at the solution.

Find the minimum of the ps_example function for a two-dimensional variable x whose first component is restricted to integer values, and all components are between –5 and 5.

intcon = 1; rng default % For reproducibility objconstr = @ps_example; lb = [-5,-5]; ub = [5,5]; x = surrogateopt(objconstr,lb,ub,intcon)

Figure Optimization Plot Function contains an axes object. The axes object with title Best Function Value: -1.91746, xlabel Iteration, ylabel Function value contains an object of type scatter. This object represents Best function value.

surrogateopt stopped because it exceeded the function evaluation limit set by 'options.MaxFunctionEvaluations'.

Minimize the six-hump camel back function in the region -2.1 <= x(i) <= 2.1. This function has two global minima with the objective function value -1.0316284... and four local minima with higher objective function values.

To search the region systematically, use a regular grid of starting points. Set 120 as the maximum number of function evaluations. Use the 'surrogateoptplot' plot function. To understand the 'surrogateoptplot' plot, see Interpret surrogateoptplot.

rng default % For reproducibility objconstr = @(x)(4x(:,1).^2 - 2.1x(:,1).^4 + x(:,1).^6/3 ... + x(:,1).x(:,2) - 4x(:,2).^2 + 4*x(:,2).^4); lb = [-2.1,-2.1]; ub = -lb; [Xpts,Ypts] = meshgrid(-3:3); startpts = [Xpts(:),Ypts(:)]; options = optimoptions('surrogateopt','PlotFcn','surrogateoptplot',... 'InitialPoints',startpts,'MaxFunctionEvaluations',120); x = surrogateopt(objconstr,lb,ub,options)

Figure Optimization Plot Function contains an axes object. The axes object with title Best: -1.03163 Incumbent: -0.124304 Current: 2.62156, xlabel Number of Function Evaluations, ylabel Objective Function contains 6 objects of type line. One or more of the lines displays its values using only markers These objects represent Best, Incumbent, Initial Samples, Adaptive Samples, Random Samples, Surrogate Reset.

surrogateopt stopped because it exceeded the function evaluation limit set by 'options.MaxFunctionEvaluations'.

Minimize a nonlinear objective function subject to linear inequality constraints. Minimize for 200 function evaluations.

objconstr = @multirosenbrock; nvar = 6; lb = -2*ones(nvar,1); ub = -lb; intcon = []; A = ones(1,nvar); b = 3; Aeq = []; beq = []; options = optimoptions('surrogateopt','MaxFunctionEvaluations',200); [sol,fval,exitflag,output] = ... surrogateopt(objconstr,lb,ub,intcon,A,b,Aeq,beq,options)

Figure Optimization Plot Function contains an axes object. The axes object with title Best Function Value: 2.1853, xlabel Iteration, ylabel Function value contains an object of type scatter. This object represents Best function value.

surrogateopt stopped because it exceeded the function evaluation limit set by 'options.MaxFunctionEvaluations'.

sol = 1×6

0.2072    0.0437    0.1360    0.0066    0.1196   -0.0002

output = struct with fields: elapsedtime: 30.3115 funccount: 200 constrviolation: 0 ineq: [1×0 double] rngstate: [1×1 struct] message: 'surrogateopt stopped because it exceeded the function evaluation limit set by ↵'options.MaxFunctionEvaluations'.'

Create a problem structure representing the six-hump camel back function in the region -2.1 <= x(i) <= 2.1. Set 120 as the maximum number of function evaluations.

rng default % For reproducibility objconstr = @(x)(4x(:,1).^2 - 2.1x(:,1).^4 + x(:,1).^6/3 ... + x(:,1).x(:,2) - 4x(:,2).^2 + 4*x(:,2).^4); options = optimoptions('surrogateopt','MaxFunctionEvaluations',120); problem = struct('objective',objconstr,... 'lb',[-2.1,-2.1],... 'ub',[2.1,2.1],... 'options',options,... 'solver','surrogateopt'); x = surrogateopt(problem)

Figure Optimization Plot Function contains an axes object. The axes object with title Best Function Value: -1.03163, xlabel Iteration, ylabel Function value contains an object of type scatter. This object represents Best function value.

surrogateopt stopped because it exceeded the function evaluation limit set by 'options.MaxFunctionEvaluations'.

Minimize the six-hump camel back function and return both the minimizing point and the objective function value. Set options to suppress all other display.

rng default % For reproducibility objconstr = @(x)(4x(:,1).^2 - 2.1x(:,1).^4 + x(:,1).^6/3 ... + x(:,1).x(:,2) - 4x(:,2).^2 + 4*x(:,2).^4); lb = [-2.1,-2.1]; ub = -lb; options = optimoptions('surrogateopt','Display','off','PlotFcn',[]); [x,fval] = surrogateopt(objconstr,lb,ub,options)

Monitor the surrogate optimization process by requesting that surrogateopt return more outputs. Use the 'surrogateoptplot' plot function. To understand the 'surrogateoptplot' plot, see Interpret surrogateoptplot.

rng default % For reproducibility objconstr = @(x)(4x(:,1).^2 - 2.1x(:,1).^4 + x(:,1).^6/3 ... + x(:,1).x(:,2) - 4x(:,2).^2 + 4*x(:,2).^4); lb = [-2.1,-2.1]; ub = -lb; options = optimoptions('surrogateopt','PlotFcn','surrogateoptplot'); [x,fval,exitflag,output] = surrogateopt(objconstr,lb,ub,options)

Figure Optimization Plot Function contains an axes object. The axes object with title Best: -1.03163 Incumbent: -1.03162 Current: -1.03161, xlabel Number of Function Evaluations, ylabel Objective Function contains 6 objects of type line. One or more of the lines displays its values using only markers These objects represent Best, Incumbent, Random Samples, Adaptive Samples, Surrogate Reset.

surrogateopt stopped because it exceeded the function evaluation limit set by 'options.MaxFunctionEvaluations'.

output = struct with fields: elapsedtime: 13.2674 funccount: 200 constrviolation: 0 ineq: [1×0 double] rngstate: [1×1 struct] message: 'surrogateopt stopped because it exceeded the function evaluation limit set by ↵'options.MaxFunctionEvaluations'.'

Conclude a surrogate optimization quickly by setting a small maximum number of function evaluations. To prepare for the possibility of restarting the optimization, request all solver outputs.

rng default % For reproducibility objconstr = @(x)(4x(:,1).^2 - 2.1x(:,1).^4 + x(:,1).^6/3 ... + x(:,1).x(:,2) - 4x(:,2).^2 + 4*x(:,2).^4); lb = [-2.1,-2.1]; ub = -lb; options = optimoptions('surrogateopt','MaxFunctionEvaluations',20); [x,fval,exitflag,output,trials] = surrogateopt(objconstr,lb,ub,options);

Figure Optimization Plot Function contains an axes object. The axes object with title Best Function Value: -0.124304, xlabel Iteration, ylabel Function value contains an object of type scatter. This object represents Best function value.

surrogateopt stopped because it exceeded the function evaluation limit set by 'options.MaxFunctionEvaluations'.

Optimize for another 20 function evaluations, starting from the previously evaluated points.

options.InitialPoints = trials; [x,fval,exitflag,output,trials] = surrogateopt(objconstr,lb,ub,options);

Figure Optimization Plot Function contains an axes object. The axes object with title Best Function Value: -1.0316, xlabel Iteration, ylabel Function value contains an object of type scatter. This object represents Best function value.

surrogateopt stopped because it exceeded the function evaluation limit set by 'options.MaxFunctionEvaluations'.

By comparing the plots of these 40 function evaluations to those in Search for Global Minimum, you see that restarting surrogate optimization is not the same as having the solver run continuously.

To enable restarting surrogate optimization due to a crash or any other reason, set a checkpoint file name.

opts = optimoptions('surrogateopt','CheckpointFile','checkfile.mat');

Create an optimization problem and set a small number of function evaluations.

rng default % For reproducibility objconstr = @(x)(4x(:,1).^2 - 2.1x(:,1).^4 + x(:,1).^6/3 ... + x(:,1).x(:,2) - 4x(:,2).^2 + 4*x(:,2).^4); lb = [-2.1,-2.1]; ub = -lb; opts.MaxFunctionEvaluations = 30; [x,fval,exitflag,output] = surrogateopt(objconstr,lb,ub,opts)

Surrogateopt stopped because it exceeded the function evaluation limit set by 'options.MaxFunctionEvaluations'.

output = struct with fields: elapsedtime: 28.7221 funccount: 30 constrviolation: 0 ineq: [1×0 double] rngstate: [1×1 struct] message: 'Surrogateopt stopped because it exceeded the function evaluation limit set by ↵'options.MaxFunctionEvaluations'.'

Set options to use 100 function evaluations (which means 70 more than already done) and restart the optimization.

opts.MaxFunctionEvaluations = 100; [x2,fval2,exitflag2,output2] = surrogateopt('checkfile.mat',opts)

Surrogateopt stopped because it exceeded the function evaluation limit set by 'options.MaxFunctionEvaluations'.

output2 = struct with fields: elapsedtime: 159.2411 funccount: 100 constrviolation: 0 ineq: [1×0 double] rngstate: [1×1 struct] message: 'Surrogateopt stopped because it exceeded the function evaluation limit set by ↵'options.MaxFunctionEvaluations'.'

Input Arguments

collapse all

Objective function and nonlinear constraint, specified as a function handle or function name. objconstr accepts a single argument x, where x is typically a row vector. However, when the Vectorized option istrue, x is a matrix containingoptions.BatchUpdateInterval rows; each row represents one point to evaluate. objconstr returns one of the following:

When the Vectorized option is true and the BatchUpdateInterval is greater than one,objconstr operates on each row ofx and returns one of the following:

The objective function objconstr.Fval can be empty ([]), in which case surrogateopt attempts to find a point satisfying all the constraints. See Solve Feasibility Problem.

For examples using a nonlinear constraint, see Solve Problem with Nonlinear Constraints, Surrogate Optimization with Nonlinear Constraint, and Solve Feasibility Problem. For information on converting between the surrogateopt structure syntax and other solvers, see packfcn and Convert Nonlinear Constraints Between surrogateopt Form and Other Solver Forms For an example using vectorized batch evaluations, see Optimize Simulink Model in Parallel.

Data Types: function_handle | char | string

Lower bounds, specified as a finite real vector. lb represents the lower bounds element-wise inlb x ub. The lengths of lb and ub must be equal to the number of variables that objconstr accepts.

Caution

Although lb is optional for most solvers,lb is a required input forsurrogateopt.

Note

surrogateopt allows equal entries in lb andub. For each i in intcon, you must have ceil(lb(i)) <= floor(ub(i)). See Construct Surrogate Details.

Example: lb = [0;-20;4] means x(1) ≥ 0, x(2) ≥ -20, x(3) ≥ 4.

Data Types: double

Upper bounds, specified as a finite real vector. ub represents the upper bounds element-wise inlb x ub. The lengths of lb and ub must be equal to the number of variables that objconstr accepts.

Caution

Although ub is optional for most solvers,ub is a required input forsurrogateopt.

Note

surrogateopt allows equal entries in lb andub. For each i in intcon, you must have ceil(lb(i)) <= floor(ub(i)). See Construct Surrogate Details.

Example: ub = [10;-20;4] means x(1) ≤ 10, x(2) ≤ -20, x(3) ≤ 4.

Data Types: double

Integer variables, specified as a vector of positive integers with values from 1 to the number of problem variables. Each value inintcon represents an x component that is integer-valued.

Example: To specify that the even entries in x are integer-valued, set intcon to2:2:nvars.

Data Types: double

Linear inequality constraints, specified as a real matrix. A is an M-by-nvars matrix, where M is the number of inequalities.

A encodes the M linear inequalities

A*x <= b,

where x is the column vector of nvars variables x(:), and b is a column vector with M elements.

For example, to specify

_x_1 + 2_x_2 ≤ 10
3_x_1 + 4_x_2 ≤ 20
5_x_1 + 6_x_2 ≤ 30,

give these constraints:

A = [1,2;3,4;5,6]; b = [10;20;30];

Example: To specify that the control variables sum to 1 or less, give the constraintsA = ones(1,N) and b = 1.

Data Types: double

Linear inequality constraints, specified as a real vector. b is an M-element vector related to the A matrix. If you pass b as a row vector, solvers internally convert b to the column vector b(:).

b encodes the M linear inequalities

A*x <= b,

where x is the column vector of N variables x(:), and A is a matrix of size M-by-N.

For example, to specify

_x_1 + 2_x_2 ≤ 10
3_x_1 + 4_x_2 ≤ 20
5_x_1 + 6_x_2 ≤ 30,

give these constraints:

A = [1,2;3,4;5,6]; b = [10;20;30];

Example: To specify that the control variables sum to 1 or less, give the constraintsA = ones(1,N) and b = 1.

Data Types: double

Linear equality constraints, specified as a real matrix. Aeq is an Me-by-nvars matrix, where Me is the number of equalities.

Aeq encodes the Me linear equalities

Aeq*x = beq,

where x is the column vector of N variables x(:), and beq is a column vector with Me elements.

For example, to specify

_x_1 + 2_x_2 + 3_x_3 = 10
2_x_1 + 4_x_2 +_x_3 = 20,

give these constraints:

Aeq = [1,2,3;2,4,1]; beq = [10;20];

Example: To specify that the control variables sum to 1, give the constraints Aeq = ones(1,N) and beq = 1.

Data Types: double

Linear equality constraints, specified as a real vector. beq is an Me-element vector related to the Aeq matrix. If you pass beq as a row vector, solvers internally convert beq to the column vector beq(:).

beq encodes the Me linear equalities

Aeq*x = beq,

where x is the column vector of N variables x(:), and Aeq is a matrix of size Meq-by-N.

For example, to specify

_x_1 + 2_x_2 + 3_x_3 = 10
2_x_1 + 4_x_2 +_x_3 = 20,

give these constraints:

Aeq = [1,2,3;2,4,1]; beq = [10;20];

Example: To specify that the control variables sum to 1, give the constraints Aeq = ones(1,N) and beq = 1.

Data Types: double

Options, specified as the output ofoptimoptions.

For more information, see Surrogate Optimization Options.

Option Description Values
BatchUpdateInterval Number of function evaluations before the surrogate is updated.Number of points to pass in a vectorized evaluation. When UseVectorized is true,surrogateopt passes a matrix of sizeBatchUpdateInterval-by-nvar, where nvar is the number of problem variables. Each row of the matrix represents one evaluation point. Output functions and plot functions are updated after each batch is evaluated completely. Positive integer. Default is1.
CheckpointFile File name for checkpointing and restarting optimization. The file has the .mat data type. See Work with Checkpoint Files.Checkpointing takes time. This overhead is especially noticeable for functions that otherwise take little time to evaluate. File name or file path, given as a string or character array. If you specify a file name without a path, surrogateopt saves the checkpoint file in the current folder.
ConstraintTolerance Tolerance on nonlinear constraints, measured as the maximum of all nonlinear constraint function values, where positive values indicate a violation. This tolerance is an absolute (not relative) tolerance; see Tolerances and Stopping Criteria. Nonnegative scalar. Default is1e-3.
Display Level of display returned at the command line. 'final' (default) — Exit message at the end of the iterations.'off' or the equivalent'none' — No display.'iter' — Iterative display; see Command-Line Display.
InitialPoints Initial points for solver. Matrix of initial points, where each row is one point. Or, a structure with field X, whose value is a matrix of initial points, and these optional fields:Fval, a vector containing the values of the objective function at the initial pointsIneq, a matrix containing nonlinear inequality constraint valuesSee Algorithm Control. Default is [].
MaxFunctionEvaluations Maximum number of objective function evaluations, a stopping criterion. Nonnegative integer. Default ismax(200,50*nvar), wherenvar is the number of problem variables.
MaxTime Maximum running time in seconds. The actual running time can exceed MaxTime because of the time required to evaluate an objective function or because of parallel processing delays. Nonnegative scalar. Default isInf.
MinSampleDistance Minimum distance between trial points generated by the adaptive sampler. See Surrogate Optimization Algorithm. Nonnegative scalar. Default is1e-6.
MinSurrogatePoints Minimum number of random sample points to create at the start of a surrogate creation phase. See Surrogate Optimization Algorithm.When BatchUpdateInterval > 1, the minimum number of random sample points used to create a surrogate is the larger ofMinSurrogatePoints and BatchUpdateInterval. Integer at least nvar + 1. Default ismax(20,2*nvar), wherenvar is the number of problem variables.
ObjectiveLimit Tolerance on the objective function value. If a calculated objective function value of a feasible point is less than ObjectiveLimit, the algorithm stops. Double scalar value. Default is-Inf.
OutputFcn Output function to report on solver progress or to stop the solver. See Output Function. Function name, function handle, or cell array of function names or handles. Default is [].
PlotFcn Plot function to display solver progress or to stop solver. See Plot Function. Function name, function handle, or cell array of function names or handles. Built-in plot functions are:'optimplotfvalconstr' (default) — Plot the best feasible objective function value found as a line plot. If there is no objective function, plot the maximum nonlinear constraint violation as a line plot.The plot shows infeasible points in one color and feasible points in another.If there is no objective function, the plot title shows the number of feasible solutions.'optimplotfval' — Plot the best objective function value found as a line plot.'optimplotx' — Plot the best solution found as a bar chart.'surrogateoptplot' — Plot the objective function value at each iteration, showing which phase of the algorithm produces the value and the best value found both in this phase and overall. See Interpret surrogateoptplot.
UseParallel Boolean value indicating whether to compute objective function values in parallel.You cannot specify both UseParallel = true and UseVectorized = true. If you set both to true, the solver ignores UseVectorized and attempts to compute in parallel using a parallel pool, if possible. Boolean. Default is false. For algorithmic details, see Parallel surrogateopt Algorithm.
UseVectorized Boolean value indicating whether to compute objective function values in batches of sizeBatchUpdateInterval.You cannot specify both UseParallel = true and UseVectorized = true. If you set both to true, the solver ignores UseVectorized and attempts to compute in parallel using a parallel pool, if possible. Boolean. Default is false. For an example, see Optimize Simulink Model in Parallel.

Example: options = optimoptions('surrogateopt','Display','iter','UseParallel',true)

Problem structure, specified as a structure with these fields:

Note

These problem fields are required:objective, lb,ub, solver, andoptions.

Data Types: struct

Path to a checkpoint file, specified as a string or character vector. A checkpoint file has the .mat extension. If you specify a file name without a path, surrogateopt uses a checkpoint file in the current folder.

A checkpoint file stores the state of an optimization for resuming the optimization. surrogateopt updates the checkpoint file at each function evaluation, so you can resume the optimization even whensurrogateopt halts prematurely. For an example, seeRestart Surrogate Optimization from Checkpoint File.

surrogateopt creates a checkpoint file when it has a valid CheckpointFile option.

You can change some options when resuming from a checkpoint file. Seeopts.

The data in a checkpoint file is in .mat format. To avoid errors or other unexpected results, do not modify the data before calling surrogateopt.

Warning

Do not resume surrogateopt from a checkpoint file created with a different MATLAB® version. surrogateopt can throw an error or give inconsistent results.

Example: 'checkfile.mat'

Example: "C:\Program Files\MATLAB\docs\checkpointNov2019.mat"

Data Types: char | string

Options for resuming optimization from the checkpoint file, specified asoptimoptions options (from a restricted set) that you can change from the original options. The options you can change are:

Example: opts = optimoptions(options,'MaxFunctionEvaluations',400);

Output Arguments

collapse all

Solution, returned as a real vector. x has the same length as lb and ub.

Objective function value at the solution, returned as a real number.

Reason surrogateopt stopped, returned as one of the integer values described in this table.

Exit Flag Description
10 Problem has a unique feasible solution due to one of the following:All upper bounds ub are equal to the lower boundslb.The linear equality constraints Aeq*x = beq and the bounds have a unique solution point.surrogateopt returns the feasible point and function value without performing any optimization.
3 Feasible point found. Solver stopped because too few new feasible points were found to continue.
1 The objective function value is less thanoptions.ObjectiveLimit. This exit flag takes precedence over exit flag10 when both apply.
0 The number of function evaluations exceedsoptions.MaxFunctionEvaluations or the elapsed time exceedsoptions.MaxTime. If the problem has nonlinear inequalities, the solution is feasible.
-1 The optimization is terminated by an output function or plot function.
-2 No feasible point is found due to one of the following:A lower bound lb(i) exceeds a corresponding upper boundub(i). Or one or moreceil(lb(i)) exceeds a corresponding floor(ub(i)) for i in intcon. In this case,surrogateopt returnsx = [] and fval = [].lb = ub and the pointlb is infeasible. In this case,x = lb, and fval = objconstr(x).Fval.The linear and, if present, integer constraints are infeasible together with the bounds. In this case,surrogateopt returnsx = [] and fval = [].The bounds, integer, and linear constraints are feasible, but no feasible solution is found with nonlinear constraints. In this case,x is the point of least maximum infeasibility of nonlinear constraints, andfval = objconstr(x).Fval.

Information about the optimization process, returned as a structure with these fields:

Points evaluated, returned as a structure with these fields:

The trials structure has the same form as theoptions.InitialPoints structure. So, you can continue an optimization by passing the trials structure as theInitialPoints option.

Algorithms

surrogateopt repeatedly performs these steps:

  1. Create a set of trial points by sampling MinSurrogatePoints random points within the bounds, and evaluate the objective function at the trial points.
  2. Create a surrogate model of the objective function by interpolating a radial basis function through all of the random trial points.
  3. Create a merit function that gives some weight to the surrogate and some weight to the distance from the trial points. Locate a small value of the merit function by randomly sampling the merit function in a region around the incumbent point (best point found since the last surrogate reset). Use this point, called the adaptive point, as a new trial point.
  4. Evaluate the objective at the adaptive point, and update the surrogate based on this point and its value. Count a "success" if the objective function value is sufficiently lower than the previous best (lowest) value observed, and count a "failure" otherwise.
  5. Update the dispersion of the sample distribution upwards if three successes occur before max(nvar,5) failures, wherenvar is the number of dimensions. Update the dispersion downwards if max(nvar,5) failures occur before three successes.
  6. Continue from step 3 until all trial points are withinMinSampleDistance of the evaluated points. At that time, reset the surrogate by discarding all adaptive points from the surrogate, reset the scale, and go back to step 1 to create MinSurrogatePoints new random trial points for evaluation.

For details, see Surrogate Optimization Algorithm.

Alternative Functionality

App

The Optimize Live Editor task provides a visual interface for surrogateopt.

Extended Capabilities

Version History

Introduced in R2018b

expand all

surrogateopt has updated internal routines that increase its efficiency, especially for integer-constrained problems. Also, for problems with fast objective and nonlinear constraint functions, checkpointing is more efficient than before: surrogateopt writes checkpoint files no more than once in 10 seconds. For details, see Surrogate Optimization Algorithm and Checkpoint File.