



Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Esta página não é visível na pré-visualização
Não perca as partes importantes!




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.
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
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
■ 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.
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
Start Stop For k = 1 : N Evaluate model
...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
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