peaks Minimization with MultiStart

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 MultiStart to Find the Global Minimum

Define the multistart solver

close all
ms = MultiStart
ms = 

  MultiStart

  Properties:
         UseParallel: 'never'
             Display: 'final'
              TolFun: 1.0000e-006
                TolX: 1.0000e-006
             MaxTime: Inf
    StartPointsToRun: 'all'


Run Multistart

Well use 5 starting points

[x,f,exitflag,output,solutions] = run(ms, problem, 5)
MultiStart completed the runs from all start points.

All 5 local solver runs converged with a positive local solver exit flag.

x =

    0.2283   -1.6255


f =

   -6.5511


exitflag =

     1


output = 

                funcCount: 273
         localSolverTotal: 5
       localSolverSuccess: 5
    localSolverIncomplete: 0
    localSolverNoSolution: 0
                  message: [1x127 char]


solutions = 

  1x5 GlobalOptimSolution

  Properties:
    X
    Fval
    Exitflag
    Output
    X0