peaks Minimization with GlobalSearch

Copyright (c) 2010, The MathWorks, Inc.
All rights reserved.

Contents

Objective Function

We wish find the minimum of the peaks function

clear all, close all, clc
peaks
 
z =  3*(1-x).^2.*exp(-(x.^2) - (y+1).^2) ... 
   - 10*(x/5 - x.^3 - y.^5).*exp(-x.^2-y.^2) ... 
   - 1/3*exp(-(x+1).^2 - y.^2) 
 

Nonlinear Constraint Function

Subject to a nonlinear constraint defined by a circular region of radius three around the origin

type circularConstraint
function [c,ceq] = circularConstraint(x)
% Nonlinear constraint definition

%  Copyright (c) 2010, The MathWorks, Inc.
%  All rights reserved.

% Define nonlinear equality constraint (none)
ceq = [];

% Define nonlinear inequality constraint
% circular region with radius 3: x1^2 + x^2 -3^2 <= 0 
c = x(:,1).^2 + x(:,2).^2 - 9;

Define Optimization Problem

problem = createOptimProblem('fmincon',...
                             'objective',@(x) peaks(x(1),x(2)), ...
                             'nonlcon',@circularConstraint,...
                             'x0',[-1 -1],...
                             'lb',[-3 -3],...
                             'ub',[3 3],...
                             'options',optimset('OutputFcn',...
                                                @peaksPlotIterates))
problem = 

    objective: @(x)peaks(x(1),x(2))
           x0: [-1 -1]
        Aineq: []
        bineq: []
          Aeq: []
          beq: []
           lb: [-3 -3]
           ub: [3 3]
      nonlcon: @circularConstraint
       solver: 'fmincon'
      options: [1x1 struct]

Run the solver fmincon from the initial point

We can see the solution is not the global minimum

[x,f] = fmincon(problem)
x =

   -1.3473    0.2045


f =

   -3.0498

Use GlobalSearch to Find the Global Minimum

Define the globalsearch solver

close all
gs = GlobalSearch
gs = 

  GlobalSearch

  Properties:
             NumTrialPoints: 1000
          BasinRadiusFactor: 0.2000
    DistanceThresholdFactor: 0.7500
               MaxWaitCycle: 20
          NumStageOnePoints: 200
     PenaltyThresholdFactor: 0.2000
                    Display: 'final'
                     TolFun: 1.0000e-006
                       TolX: 1.0000e-006
                    MaxTime: Inf
           StartPointsToRun: 'all'


Run GlobalSearch

[x,f,exitflag,output,solutions] = run(gs, problem)
GlobalSearch stopped because it analyzed all the trial points.

6 out of 10 local solver runs converged with a positive local solver exit flag.

x =

    0.2283   -1.6255


f =

   -6.5511


exitflag =

     2


output = 

                funcCount: 2203
         localSolverTotal: 10
       localSolverSuccess: 6
    localSolverIncomplete: 0
    localSolverNoSolution: 4
                  message: [1x143 char]


solutions = 

  1x6 GlobalOptimSolution

  Properties:
    X
    Fval
    Exitflag
    Output
    X0