resume
Resume a Bayesian optimization
Description
resumes the optimization that produced newresults
= resume(results
,Name,Value
)results
with additional
options specified by one or more name-value arguments.
Examples
Resume Bayesian Optimization
This example shows how to resume a Bayesian optimization. The optimization is for a deterministic function known as Rosenbrock's function, which is a well-known test case for nonlinear optimization. The function has a global minimum value of 0
at the point [1,1]
.
Create two real variables bounded by -5
and 5
.
x1 = optimizableVariable("x1",[-5,5]); x2 = optimizableVariable("x2",[-5,5]); vars = [x1,x2];
Define an objective function named rosenbrocks
that corresponds to Rosenbrock's function.
type rosenbrocks.m % Display contents of rosenbrocks.m file
function f = rosenbrocks(x) f = 100*(x.x2 - x.x1^2)^2 + (1 - x.x1)^2;
Note: If you click the button located in the upper-right section of this page and open this example in MATLAB®, then MATLAB opens the example folder. This folder includes the objective function file.
Create a function handle for the objective function.
fun = @rosenbrocks;
For reproducibility, set the random seed, and set the acquisition function to "expected-improvement-plus"
in the optimization.
rng("default") results = bayesopt(fun,vars,"Verbose",0, ... "AcquisitionFunctionName","expected-improvement-plus");
View the best point found and the best modeled objective.
results.XAtMinObjective
ans=1×2 table
x1 x2
______ ______
1.7902 3.2287
results.MinEstimatedObjective
ans = -9.1194
The best point is not very close to the optimum, and the function model is inaccurate. Resume the optimization for 30 more points (a total of 60 points), this time telling the optimizer that the objective function is deterministic.
newresults = resume(results,"IsObjectiveDeterministic",true, ... "MaxObjectiveEvaluations",30);
newresults.XAtMinObjective
ans=1×2 table
x1 x2
_______ _______
0.95093 0.90364
newresults.MinEstimatedObjective
ans = -0.0106
This time, the best point is closer to the true optimum, and the objective function model is closer to the true function.
Input Arguments
results
— Bayesian optimization results
BayesianOptimization
object
Bayesian optimization results, specified as a BayesianOptimization
object.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: resume(results,'MaxObjectiveEvaluations',60)
You can use any name-value argument accepted by bayesopt
except for those beginning with Initial
.
See the bayesopt
Input Arguments.
Note
The MaxObjectiveEvaluations
and MaxTime
name-value arguments mean additional time or evaluations,
above the numbers stored in results
. So, for example, the
default number of evaluations is 30
in addition to the
original specification.
Additionally, you can use the following name-value argument.
VariableDescriptions
— Modify variable
OptimizableVariable
object
Modify variable, specified as an
OptimizableVariable
object.
You can change only the following properties of a variable in an optimization.
Range
of real or integer variables. For example,xvar = optimizableVariable('x',[-10,10]); % Modify the range: xvar.Range = [1,5];
Type
between'integer'
and'real'
. For example,xvar.Type = 'integer';
Transform
of real or integer variables between'log'
and'none'
. For example,xvar.Transform = 'log';
Output Arguments
newresults
— Optimization results
BayesianOptimization
object
Optimization results, returned as a BayesianOptimization
object.
Version History
Introduced in R2016b
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)