Docsity

Improving Optimization Performance with Parallel Computing, Provas de Mecatrônica

Toggle sidebar
bg1
1 MATLAB Digest www.mathworks.com
Parallel computing techniques can help re-
duce the time it takes to reach a solution. To
derive the full benefits of parallelization, it is
important to choose an approach that is ap-
propriate for the optimization problem.
This article describes two ways to use the
inherent paralleli sm in optimization prob-
lems to reduce the time to solution. The
first example solves a mathematical prob-
lem using the parallel computing option in
Optimization Toolbox™, and requires no
code modification. The se cond, a practical
engineering optimization problem, requires
a single-line change in code. Both examples
use Parallel Computing Toolbox™ and
MATLAB Distributed Computing Server™
to automate and m anage the parallel com-
puting task s.
Parallel Optimization with
Optimization Toolbox
In a typical optimization, an iterat ive
search procedure is used to find a mi ni-
mum value of a given f unction —for ex-
ample, using a gradient-based a lgorithm to
find a mi nimum va lue of the peaks func-
tion in MATLAB® (Figure 1).
Gradient esti mation is often the mos t
time-consuming computation during opti-
mization . In a single iteration, the optimi-
zation solver estimates the local gradient of
Engineers, scientists, and financial analysts frequently use optimization
methods to solve computationally expensive problems such as smoothing
the large computational meshes used in fluid dynamic simulations, performing
image registration, or analyzing high-dimensional financial portfolios. How-
ever, computing a solution can take anywhere from hours to days.
Improving Optimization Performance with
Parallel Computing
the function and uses t hat information to
determine the direction of the search and
the magnitude of t he step to the next point
in the search. This pro cess is repeated until
Products Used
■ M A T L A B ®
■ S i m u l i n k ®
■ Optimization Toolbox™
■ Statistics Toolbox™
■ Parallel Computing Toolbox™
■ MATLAB Distributed Computing Ser ver™
Figure 1. Using a gradient-based optimization solver to search for a minimum value.
pf3
pf4
pf5

Pré-visualização parcial do texto

Baixe Improving Optimization Performance with Parallel Computing e outras Provas em PDF para Mecatrônica, somente na Docsity!

Parallel computing techniques can help re- duce the time it takes to reach a solution. To derive the full benefits of parallelization, it is important to choose an approach that is ap- propriate for the optimization problem. This article describes two ways to use the inherent parallelism in optimization prob- lems to reduce the time to solution. The first example solves a mathematical prob- lem using the parallel computing option in Optimization Toolbox™, and requires no code modification. The second, a practical engineering optimization problem, requires a single-line change in code. Both examples use Parallel Computing Toolbox™ and MATLAB Distributed Computing Server™ to automate and manage the parallel com- puting tasks.

Parallel Optimization with

Optimization Toolbox

In a typical optimization, an iterative search procedure is used to find a mini- mum value of a given function—for ex- ample, using a gradient-based algorithm to find a minimum value of the peaks func- tion in MATLAB® (Figure 1). Gradient estimation is often the most time-consuming computation during opti- mization. In a single iteration, the optimi- zation solver estimates the local gradient of

Engineers, scientists, and financial analysts frequently use optimization

methods to solve computationally expensive problems such as smoothing

the large computational meshes used in fluid dynamic simulations, performing

image registration, or analyzing high-dimensional financial portfolios. How-

ever, computing a solution can take anywhere from hours to days.

Improving Optimization Performance with

Parallel Computing

the function and uses that information to determine the direction of the search and the magnitude of the step to the next point in the search. This process is repeated until

Products Used

■ MATLAB®

■ Simulink® ■ Optimization Toolbox™ ■ Statistics Toolbox™ ■ Parallel Computing Toolbox™ ■ MATLAB Distributed Computing Server™ Figure 1. Using a gradient-based optimization solver to search for a minimum value.

the solver finds a minimum value or reaches a predefined time or iteration limit. The gradient estimation step, which is often performed using an approximation method, such as finite differences, requires several function evaluations near the cur- rent point. Typically, N function evalua- tions are required, where N is the number of variables, or the dimensionality of the problem. As N increases, so do the number of function evaluations for each iteration and the time to solution. Figure 2 shows how you can perform computations in parallel to accelerate gra- dient estimation. The N function evalua- tion used to estimate the gradient when performed on a single MATLAB worker would be executed serially. Whereas in the serial approach the N function evaluations occur one after the other, in the parallel approach the com- putations are distributed across MATLAB workers, and several function evaluations can occur simultaneously. We can speed up gradient estimation as long as the cost of distributing the function evaluation across multiple workers is less than the execution time of N objective (and constraint) func- tion evaluations. The actual solution time depends on the objective/constraint func- tion execution speed, the computer pro- cessing speed, available memory, current load, and network speed.

An ElectroStatics Examplei

This example illustrates how to formu- late and solve an optimization problem in MATLAB. Consider N electrons in a con- ducting body (Figure 3). The electrons ar- range themselves to minimize their potential energy subject to the constraint of lying in- side the conducting body. At the minimum

Serial Approach

Start Stop For k = 1 : N Evaluate model

Parallel Approach

...MATLAB... ...workers... Evaluate model Evaluate model Evaluate model Evaluate model Stop Start Figure 2. Serial and parallel approaches to gradient estimation. Figure 3. Conducting body and electrons. i (^) Inspired by Dolan, Moré, and Munson, “Benchmarking Optimization Software with COPS 3.0”, Argonne National Laboratory Technical Report. ANL/MCS-TM-273, February 2004.

distributing computations to run in parallel is slower than running the problem serially. This example shows that for optimiza- tion problems to benefit from running the computations in parallel, the cost associated with the function evaluations with gradient estimation must be greater than the overhead costs associated with data and code transfer. To further understand the trade-offs as- sociated with the objective function execu- tion time, number of MATLAB workers, and number of variables (electrons), we ran this problem with a pause time (t) ranging from 0 to 0.4 seconds, different workers from 1 to 32, and number of electrons ranging from 8 to

  1. Figures 6a and 6b show the results plotted for t = 0 and 0.1 seconds, respectively. Figure 6a shows how the number of elec- trons changes the speed-up. For 8 and 10 electrons, the overhead cost of more work- ers reduced the speed-up. For 16 electrons, the overhead cost fell below the function evaluation cost, and we saw a positive effect on the speed-up for most workers. The aver- age time to evaluate one objective function was on the order of 1 millisecond on a single worker. The maximum speed-up occurred at around 8 workers. Increasing the num- ber of workers increased the communica- tion overhead and eventually eliminated the benefit of using parallel computing. Figure 6b shows how the results change when the objective function evaluation time significantly exceeds the overhead costs. A rapid increase in speed-up is again observed around 8 workers. Notice that the maximum reductions in the curve for the 8-electron case and the 16-electron case are 8 workers and 16 workers, respectively. This increase is a result of balancing the number of parallel compu- tations that can be performed with the same number of workers. For the 8-electron case, 8 workers resulted in the greatest increase. A similar trend is seen for the 16-electron case.

User-Defined Parallel

Optimization Problem

As we have seen, the time required to evaluate the objective strongly influences the solution time. Therefore, one of the ap- proaches we can take is to look for parallel- ism within the objective function and the constraint function—that is, to parallelize the objective or the constraint function. We will take this approach by distribut- ing computations within the objective func- tion for the problem shown in Figure 7. The Figure 6a. Results for pause time t = 0 seconds. Figure 6b. Results for pause time t = 0.01 seconds. Figure 7. Vehicle suspension model and simulation results for an empty vehicle.

goal of this problem is to design a suspen- sion 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 load- ings. 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. 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, z··). The objective function, myCostFcnRR, contains a Monte-Carlo simulation used to evaluate the mean and standard deviation of acceleration that the passengers would experience (Figure 8). The goal is to mini- mize the mean and standard deviations. 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 sim- ply replace the for loop construct with the parfor (parallel for loop) construct (Figure 9). The objective statements inside the parfor loop can then run in parallel, speeding up the objective function evalu- ation time. The optimization problem was run for three different values of nRuns, the num- ber of points to evaluate in the Monte- Carlo simulation. The results show that parallelizing the objective function yielded substantial performance gains (Figure 10). Figure 8. Objective function used to run a Monte-Carlo simulation within the optimi- zation process. Figure 9. Objective function modified to execute in parallel. Figure 10. Results for the suspension system design problem. Optimizer Stop Objective Function Monte-Carlo Simulation For k = 1 :N Evaluate Model