GlobalSearch
Find global minimum
Description
AGlobalSearch
object contains properties (options) that affect howrun
repeatedly runs a local solver to generate aGlobalOptimSolution
object. When run, the solver attempts to locate a solution that has the lowest objective function value.
Creation
Syntax
Description
gs = GlobalSearch
createsgs
, aGlobalSearch
solver with its properties set to the defaults.
gs = GlobalSearch(Name,Value)
sets properties using name-value pairs.
gs = GlobalSearch(oldGS,Name,Value)
creates a copy of theoldGS
GlobalSearch
solver, and sets properties using name-value pairs.
gs = GlobalSearch(ms)
createsgs
, aGlobalSearch
solver, with common property values from thems
MultiStart
solver.
Properties
BasinRadiusFactor
—Basin radius decrease factor
0.2
(default) |scalar from0
through1
Basin radius decrease factor, specified as a scalar from0
through1
. A basin radius decreases afterMaxWaitCycle
consecutive start points are within the basin. The basin radius decreases by a factor of 1 –BasinRadiusFactor
.
SetBasinRadiusFactor
to0
to disable updates of the basin radius.
Example:0.5
Data Types:double
Display
—Level of display to the Command Window
'final'
(default) |'iter'
|'off'
Level of display to the Command Window, specified as one of the following character vectors or strings:
'final'
– Report summary results afterrun
finishes.'iter'
– Report results after the initialfmincon
run, after Stage 1, after every 200 start points, and after every run offmincon
, in addition to the final summary.'off'
– No display.
Example:'iter'
Data Types:char
|string
DistanceThresholdFactor
—Multiplier for determining trial point is in existing basin
0.75
(default) |nonnegative scalar
Multiplier for determining whether a trial point is in an existing basin of attraction, specified as a nonnegative scalar. For details, seeExamine Stage 2 Trial Point to See if fmincon Runs.
Example:0.5
Data Types:double
FunctionTolerance
—Tolerance on function values for considering solutions equal
1e-6
(default) |nonnegative scalar
Tolerance on function values for considering solutions equal, specified as a nonnegative scalar. Solvers consider two solutions identical if they are withinXTolerance
relative distance of each other and have objective function values withinFunctionTolerance
relative difference of each other. If both conditions are not met, solvers report the solutions as distinct. SetFunctionTolerance
to0
to obtain the results of every local solver run. SetFunctionTolerance
to a larger value to have fewer results. ForGlobalSearch
details, seeUpdate Solution SetinWhen fmincon Runs. ForMultiStart
details, seeCreate GlobalOptimSolution Object.
Example:1e-4
Data Types:double
MaxTime
—Maximum time in seconds that GlobalSearch runs
Inf
(default) |positive scalar
Maximum time in seconds that GlobalSearch runs, specified as a positive scalar. GlobalSearch and its local solvers halt whenMaxTime
seconds have passed since the beginning of the run, as measured bytic
andtoc
.
MaxTime
does not interrupt local solvers during a run, so the total time can exceedMaxTime
.
Example:180
stops the solver the first time a local solver call finishes after 180 seconds.
Data Types:double
MaxWaitCycle
—Algorithm control parameter
20
(default) |positive integer
Algorithm control parameter, specified as a positive integer.
If the observed penalty function of
MaxWaitCycle
consecutive trial points is at least the penalty threshold, then raise the penalty threshold (seePenaltyThresholdFactor).If
MaxWaitCycle
consecutive trial points are in a basin, then update that basin's radius (seeBasinRadiusFactor).
Example:40
Data Types:double
NumStageOnePoints
—Number of Stage 1 points
200
(default) |positive integer
Number of Stage 1 points, specified as a positive integer. For details, seeObtain Stage 1 Start Point, Run.
Example:1000
Data Types:double
NumTrialPoints
—Number of potential start points
1000
(default) |positive integer
Number of potential start points, specified as a positive integer.
Example:3e4
Data Types:double
OutputFcn
—Report on solver progress or halt solver
[]
(default) |function handle|cell array of function handles
Report on solver progress or halt solver, specified as a function handle or cell array of function handles. Output functions run after each local solver call. They also run when the global solver starts and ends. Write output functions using the syntax described inOutputFcn. SeeGlobalSearch Output Function.
Data Types:cell
|function_handle
PenaltyThresholdFactor
—Increase in penalty threshold
0.2
(default) |positive scalar
Increase in the penalty threshold, specified as a positive scalar. For details, seeReact to Large Counter Values.
Example:0.4
Data Types:double
PlotFcn
—Plot solver progress
[]
(default) |function handle|cell array of function handles
Plot solver progress, specified as a function handle or cell array of function handles. Plot functions run after each local solver call. They also run when the global solver starts and ends. Write plot functions using the syntax described inOutputFcn.
There are two built-in plot functions:
@gsplotbestf
plots the best objective function value.@gsplotfunccount
plots the number of function evaluations.
Example:@gsplotbestf
Data Types:cell
|function_handle
StartPointsToRun
—Start points to run
'all'
(default) |'bounds'
|'bounds-ineqs'
Start points to run, specified as:
'all'
— Run all start points.'bounds'
— Run only start points that satisfy bounds.'bounds-ineqs'
— Run only start points that satisfy bounds and inequality constraints.
GlobalSearch
checks theStartPointsToRun
property only during Stage 2 of theGlobalSearch
algorithm (the main loop). For more information, seeGlobalSearch Algorithm.
Example:'bounds'
runs only points that satisfy all bounds.
Data Types:char
|string
XTolerance
—Tolerance on distance for considering solutions equal
1e-6
(default) |nonnegative scalar
Tolerance on distance for considering solutions equal, specified as a nonnegative scalar. Solvers consider two solutions identical if they are withinXTolerance
relative distance of each other and have objective function values withinFunctionTolerance
relative difference of each other. If both conditions are not met, solvers report the solutions as distinct. SetXTolerance
to0
to obtain the results of every local solver run. SetXTolerance
to a larger value to have fewer results. ForGlobalSearch
details, seeUpdate Solution SetinWhen fmincon Runs. ForMultiStart
details, seeCreate GlobalOptimSolution Object.
Example:2e-4
Data Types:double
Object Functions
run |
Run multiple-start solver |
Examples
RunGlobalSearch
on Multidimensional Problem
Create an optimization problem that has several local minima, and try to find the global minimum usingGlobalSearch
. The objective is the six-hump camel back problem (seeRun the Solver).
rngdefault% For reproducibilitygs = GlobalSearch; sixmin = @(x)(4*x(1)^2 - 2.1*x(1)^4 + x(1)^6/3...+ x(1)*x(2) - 4*x(2)^2 + 4*x(2)^4); problem = createOptimProblem('fmincon','x0',[-1,2],...'objective',sixmin,'lb',[-3,-3],'ub',[3,3]); x = run(gs,problem)
GlobalSearch stopped because it analyzed all the trial points. All 8 local solver runs converged with a positive local solver exit flag.
x =1×2-0.0898 0.7127
You can request the objective function value atx
when you callrun
by using the following syntax:
[x,fval] = run(gs,problem)
However, if you neglected to requestfval
, you can still compute the objective function value atx
.
fval = sixmin(x)
fval = -1.0316
RunGlobalSearch
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, runGlobalSearch
using thefmincon
'sqp'
algorithm.
rngdefault% For reproducibilityopts = optimoptions(@fmincon,'Algorithm','sqp'); problem = createOptimProblem('fmincon','objective',...fun,'x0',3,'lb',-5,'ub',5,'options',opts); gs = GlobalSearch; [x,f] = run(gs,problem)
GlobalSearch stopped because it analyzed all the trial points. All 23 local solver runs converged with a positive local solver exit flag.
x = -0.3080
f = -3.9032
GlobalSearch
Using Common Properties fromMultiStart
Create a nondefaultMultiStart
object.
ms = MultiStart('FunctionTolerance',2e-4,'UseParallel',true)
ms = MultiStart with properties: UseParallel: 1 Display: 'final' FunctionTolerance: 2.0000e-04 MaxTime: Inf OutputFcn: [] PlotFcn: [] StartPointsToRun: 'all' XTolerance: 1.0000e-06
Create aGlobalSearch
object that uses the available properties fromms
.
gs = GlobalSearch(ms)
gs = GlobalSearch属性:NumTrialPoints:1000 BasinRadiusFactor: 0.2000 DistanceThresholdFactor: 0.7500 MaxWaitCycle: 20 NumStageOnePoints: 200 PenaltyThresholdFactor: 0.2000 Display: 'final' FunctionTolerance: 2.0000e-04 MaxTime: Inf OutputFcn: [] PlotFcn: [] StartPointsToRun: 'all' XTolerance: 1.0000e-06
gs
has the same nondefault value ofFunctionTolerance
asms
. Butgs
does not use theUseParallel
property.
UpdateGlobalSearch
Properties
Create aGlobalSearch
object with aFunctionTolerance
of1e-4
.
gs = GlobalSearch('FunctionTolerance',1e-4)
gs = GlobalSearch属性:NumTrialPoints:1000 BasinRadiusFactor: 0.2000 DistanceThresholdFactor: 0.7500 MaxWaitCycle: 20 NumStageOnePoints: 200 PenaltyThresholdFactor: 0.2000 Display: 'final' FunctionTolerance: 1.0000e-04 MaxTime: Inf OutputFcn: [] PlotFcn: [] StartPointsToRun: 'all' XTolerance: 1.0000e-06
Update theXTolerance
property to1e-3
and theStartPointsToRun
property to'bounds'
.
gs = GlobalSearch(gs,'XTolerance',1e-3,'StartPointsToRun','bounds')
gs = GlobalSearch属性:NumTrialPoints:1000 BasinRadiusFactor: 0.2000 DistanceThresholdFactor: 0.7500 MaxWaitCycle: 20 NumStageOnePoints: 200 PenaltyThresholdFactor: 0.2000 Display: 'final' FunctionTolerance: 1.0000e-04 MaxTime: Inf OutputFcn: [] PlotFcn: [] StartPointsToRun: 'bounds' XTolerance: 1.0000e-03
You can also update properties one at a time by using dot notation.
gs.MaxTime = 1800
gs = GlobalSearch属性:NumTrialPoints:1000 BasinRadiusFactor: 0.2000 DistanceThresholdFactor: 0.7500 MaxWaitCycle: 20 NumStageOnePoints: 200 PenaltyThresholdFactor: 0.2000 Display: 'final' FunctionTolerance: 1.0000e-04 MaxTime: 1800 OutputFcn: [] PlotFcn: [] StartPointsToRun: 'bounds' XTolerance: 1.0000e-03
Algorithms
For a detailed description of the algorithm, seeGlobalSearch Algorithm. Ugray et al.[1]describe both the algorithm and the scatter-search method of generating trial points.
References
[1] Ugray, Zsolt, Leon Lasdon, John Plummer, Fred Glover, James Kelly, and Rafael Martí.Scatter Search and Local NLP Solvers: A Multistart Framework for Global Optimization. INFORMS Journal on Computing, Vol. 19, No. 3, 2007, pp. 328–340.
Version History
Introduced in R2010a
Ouvrir l'exemple
Vous possédez une version modifiée de cet exemple. Souhaitez-vous ouvrir cet exemple avec vos modifications ?
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes MATLAB.
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)