Code covered by the BSD License  

Highlights from
Speeding Up Optimization Problems with Parallel Computing

image thumbnail

Speeding Up Optimization Problems with Parallel Computing

by

 

Files from the webinar: Speeding up optimization problems with parallel computing

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

optimSuspensionScript.m
%% User-Defined Parallel Optimization Problem
% The goal of this problem is to
% design a suspension system that minimizes the discomfort the driver would
% experience when traveling over a bump in the road. At the same time, we
% must account for uncertainty in the mass of the driver, passengers, and
% trunk loadings. We can modify the four parameters that define the front
% and rear suspension system stiffness and damping rate: kf, kr, cf, cr.
% The masses of the driver, passengers, and trunk loadings are uncertain
% and have a normal distribution assigned to them.

% Copyright 2010 The MathWorks, Inc.
mldemo_suspnfast
%%
% A Monte-Carlo simulation is performed to capture the different vehicle
% loadings. The model outputs are angular acceleration about the center of
% gravity (thetadotdot) and vertical acceleration (zdotdot).
%
% The objective function, |myCostFcnRR|, contains a Monte-Carlo simulation
% used to evaluate the mean and standard deviation of acceleration that the
% passengers would experience. The goal is to minimize the mean
% and standard deviations.
%
% <<figure8.png>>
%
% In a Monte-Carlo simulation, each run is independent and therefore can
% benefit from parallel computation. To convert the problem from serial to
% parallel, we simply replace the for loop construct with the parfor
% (parallel for loop) construct. The objective statements inside
% the parfor loop can then run in parallel, speeding up the objective
% function evaluation time.
type myCostFcnRR
%% Run in Serial
%
close_system
nRuns = 20; % number of Monte-Carlo points (small number to show how)
tic
x = rrDesignParallel(nRuns); %#ok<NASGU>
toc
%%
clc
disp('Elapsed time is 68.696113 seconds.')

%% Run Objective in Parallel
%
files = dir;
files = {files(3:end).name};
matlabpool('open','speedy-4core',4,'FileDependencies',files)
tic
x = rrDesignParallel(nRuns);
toc
matlabpool close

Contact us