%% Run |GlobalSearch| on 1-D Problem
% Consider a function with several local minima.

fun = @(x) x.^2 + 4*sin(5*x);
fplot(fun,[-5,5])
%% 
% To search for the global minimum, run |GlobalSearch| using the |fmincon| 
% |'sqp'| algorithm.

rng default % For reproducibility
opts = optimoptions(@fmincon,'Algorithm','sqp');
problem = createOptimProblem('fmincon','objective',...
    fun,'x0',3,'lb',-5,'ub',5,'options',opts);
gs = GlobalSearch;
[x,f] = run(gs,problem)
%% 
% _Copyright 2012 The MathWorks, Inc._
