Documentation |
On this page… |
---|
Check if a Solution Is a Local Solution with patternsearch |
How can you tell if you have located the global minimum of your objective function? The short answer is that you cannot; you have no guarantee that the result of a Global Optimization Toolbox solver is a global optimum.
However, you can use the strategies in this section for investigating solutions.
Before you can determine if a purported solution is a global minimum, first check that it is a local minimum. To do so, run patternsearch on the problem.
To convert the problem to use patternsearch instead of fmincon or fminunc, enter
problem.solver = 'patternsearch';
Also, change the start point to the solution you just found, and clear the options:
problem.x0 = x; problem.options = [];
For example, Check Nearby Points (in the Optimization Toolbox™ documentation) shows the following:
options = optimoptions(@fmincon,'Algorithm','active-set'); ffun = @(x)(x(1)-(x(1)-x(2))^2); problem = createOptimProblem('fmincon', ... 'objective',ffun,'x0',[1/2 1/3], ... 'lb',[0 -1],'ub',[1 1],'options',options); [x fval exitflag] = fmincon(problem) x = 1.0e-007 * 0 0.1614 fval = -2.6059e-016 exitflag = 1
However, checking this purported solution with patternsearch shows that there is a better solution. Start patternsearch from the reported solution x:
% set the candidate solution x as the start point problem.x0 = x; problem.solver = 'patternsearch'; problem.options = []; [xp fvalp exitflagp] = patternsearch(problem) Optimization terminated: mesh size less than options.TolMesh. xp = 1.0000 -1.0000 fvalp = -3.0000 exitflagp = 1
Suppose you have a smooth objective function in a bounded region. Given enough time and start points, MultiStart eventually locates a global solution.
Therefore, if you can bound the region where a global solution can exist, you can obtain some degree of assurance that MultiStart locates the global solution.
For example, consider the function
$$f={x}^{6}+{y}^{6}+\mathrm{sin}(x+y)\left({x}^{2}+{y}^{2}\right)-\mathrm{cos}\left(\frac{{x}^{2}}{1+{y}^{2}}\right)\left(2+{x}^{4}+{x}^{2}{y}^{2}+{y}^{4}\right).$$
The initial summands x^{6} + y^{6} force the function to become large and positive for large values of |x| or |y|. The components of the global minimum of the function must be within the bounds
–10 ≤ x,y ≤ 10,
since 10^{6} is much larger than all the multiples of 10^{4} that occur in the other summands of the function.
You can identify smaller bounds for this problem; for example, the global minimum is between –2 and 2. It is more important to identify reasonable bounds than it is to identify the best bounds.
To check whether there is a better solution to your problem, run MultiStart with additional start points. Use MultiStart instead of GlobalSearch for this task because GlobalSearch does not run the local solver from all start points.
For example, see Example: Searching for a Better Solution.
If you use GlobalSearch on an unconstrained problem, change your problem structure before using MultiStart. You have two choices in updating a problem structure for an unconstrained problem using MultiStart:
Change the solver field to 'fminunc':
problem.solver = 'fminunc';
To avoid a warning if your objective function does not compute a gradient, change the local options to have Algorithm set to 'quasi-newton':
problem.options.Algorithm = 'quasi-newton';
Add an artificial constraint, retaining fmincon as the local solver:
problem.lb = -Inf(size(x0));
To search a larger region than the default, see Refine Start Points.