Code covered by the BSD License  

Highlights from
Files for the 2012 Webinar "Tips and Tricks - Getting Started Using Optimization with MATLAB"

image thumbnail

Files for the 2012 Webinar "Tips and Tricks - Getting Started Using Optimization with MATLAB"

by

 

These are the files that were used for the demonstrations in the webinar.

GlobalOptimScript.m
%% Run Global Optimization Solvers on Peaks Problem

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

%% Peaks Problem
[X,Y,Z] = peaks;
surf(X,Y,Z);

%% Setup Optimization Problem
clear;

x0 = [0 1.5];
lb = [-3 -3];
ub = [ 3  3];

%% MultiStart
close all;

% Set options for FMINCON
options = optimset('Algorithm','interior-point','Disp','iter',...
                   'OutputFcn',@peaksPlotIterates);

% Create problem for MultiStart
problem = createOptimProblem('fmincon','objective',@peaksObj,'x0',x0,...
            'lb',lb,'ub',ub,'nonlcon',@peaksCon,'options',options);

% Make a MultiStart object        
ms = MultiStart;

% Run the optimization
[xopt,fval,eflag,output,solutions] = run(ms, problem, 10);

%% GlobalSearch
close all;

% Set options for FMINCON
options = optimset('Algorithm','interior-point','Disp','iter',...
                   'OutputFcn',@peaksPlotIterates);

% Create problem for GlobalSearch
problem = createOptimProblem('fmincon','objective',@peaksObj,'x0',x0,...
            'lb',lb,'ub',ub,'nonlcon',@peaksCon,'options',options);

% Make a GlobalSearch object        
gs = GlobalSearch;

% Run the optimization
[xopt,fval,eflag,output,solutions] = run(gs, problem);

%% Pattern Search
close all;

% Set options for pattern search
options = psoptimset('Display','iter','OutputFcn',@peaksPlotIterates);

% Run the optimization
[xopt,fval] = patternsearch(@peaksObj,x0,[],[],[],[],lb,ub,@peaksCon,options);

%% Genetic Algorithm
close all;

% Set options for genetic algorithm
options = gaoptimset('Disp','iter','OutputFcn',@peaksPlotIterates);

% Run the optimization
[xopt,fval] = ga(@peaksObj,2,[],[],[],[],lb,ub,@peaksCon,options);

Contact us