peaks Minimization with Pattern Search

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 inital point

We can see the solution is not the global minimum

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

   -1.3473    0.2045


f =

   -3.0498

Use Pattern Search to Find the Global Minimum

Solve the problem using pattern search.

problem.solver  = 'patternsearch';
problem.options = psoptimset('OutputFcn',@peaksPlotIterates,...
                             'Display','iter',...
                             'SearchMethod',{@searchlhs})

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

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


                                  max
  Iter   f-count      f(x)      constraint   MeshSize      Method
    0     1      1.85589            0            1    
    1     7     0.246458            0     0.009772   Update multipliers
    2    63     -3.04527            0     0.000955   Update multipliers
    3   161     -6.55113            0   9.333e-005   Update multipliers
    4   263     -6.55113            0    9.12e-006   Update multipliers
    5   376     -6.55113            0   8.913e-007   Update multipliers
Optimization terminated: mesh size less than options.TolMesh
 and constraint violation is less than options.TolCon.

x =

    0.2283   -1.6255


f =

   -6.5511