Unformatted text preview:

38 MONTE CARLO AND GRID-BASED TECHNIQUES FOR STOCHASTIC SIMULATION145 38 Monte Carlo and Grid-Based Techniques for Stochas-tic Simulation In this problem you will compare the performance of random vs. regular sampling on a specific stochastic dynamics problem. Thesystemweare considering is a simple rotary mass, controlled by a motor: Jφ ¨= τ = kti, where J is the mass moment of inertia, φ is its angular position, τ is the control torque, kt is the torque constant of the motor, and i is the electrical current applied. While this is a simple control design problem for given values of J and kt, the situation we study here is when these are each only known within a range of values. In particular, J is described as a uniform random variable in the range [5, 15]kg · m2,and kt is a uniform random variable in the range [4, 6]Nm/A. The basic question we ask is: if the control system is designed for a nominal condition, say J =10kg · m2 and kt =5Nm/A, how will the closed-loop system vary in its response, for all the possible J and kt? This is a question of stochastic simulation, that is, finding the statistics of a function output, given the statistics of its input. The code fragment provided below applies Monte Carlo and grid-based approaches to find the mean and variance of the function cos(y), when y is uniformly distributed in the range [2, 5]. Try running this a few times and notice the effects of changing N. The grid-based approach is clearly giving a good result with far less work than MC - for this example with only one random dimension. In general, the grid-based methods suffer greatly as the d dimension increases; for trapezoidal integration, the error goes as 1/N2/d, whereas for Monte Carlo it is simply 1/N1/2 for any d! 1. For the nominal system model (as above) design a proportional-derivative controller so that the closed-loop step response reaches the commanded angle for the first time in about one second and the maximum overshoot is twenty percent. The closed-loop system equation is Jφ ¨= kt(− kp(φ − φdesired) − kdφ˙) −→ Jφ ¨+ ktkdφ˙+ ktkpφ = ktkpφdesired. Remember that if you write the left-hand side of the equation as φ¨+2ζωn +ωn2 ,you can tune this up quite easily because the overshoot scales directly with damping ratio ζ, and you can then adjust ωn to get the right rise time. Show a plot of the step response and list your two gains kp and kd. The step response for the nominal system is shown, along with the ”four corners” of the parameter space, that is, at the max and min combinations of J and kt. The gains I used are derived from ζ =0.455 and ωn =2.3rad/s;they are kp =10.58 and kd =4.19. 2. Keeping your controller for the nominal system, use the Monte Carlo technique to calculate the mean and the variance of the overshoot z, over the random domain that38 MONTE CARLO AND GRID-BASED TECHNIQUES FOR STOCHASTIC SIMULATION146 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all; N = 1000; % how many trials to run %%%%%%%%%%%%%% % Monte Carlo %%%%%%%%%%%%%% for i = 1:N, q = 2 + 3*rand ; % random sample from the random domain z(i) = cos(q); % evaluate the function end; meanzMC = sum(z)/N ; % calculate mean varzMC = sum((z-meanzMC).^2)/N ; % calculate variance %%%%%%% % Grid %%%%%%% for i = 1:N, q = 2 + 3/N/2 + (i-1)*3/N ; % regular sample from the random domain z(i) = cos(q) ; end; meanzGrid = sum(z)/N ; varzGrid = sum((z-meanzGrid).^2)/N ; disp(sprintf(’Means MC: %7.4g Grid: %7.4g EXACT: %7.4g’, ... meanzMC, meanzGrid, (sin(5)-sin(2))/3 )); disp(sprintf(’Variances MC: %7.4g Grid: %7.4g’, varzMC, varzGrid)); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% covers all the possible J and kt values. Show a plot of mean z¯ vs. N, and a plot of variance σz 2 vs. N, for N =[1, 2, 5, 10, 20, 50, 100, 200, ...]. About how high does N have to be to give two significant digits? The MC version is pretty noisy, and you’d need at least some hundreds of trials to say with confidence that z¯ is between 0.19 and 0.20; ditto for the variance. Clearly a thousand or more trials is preferable. 3. Keeping your controller for the nominal system, use the trapezoidal rule to calculate the mean and variance of z.Let n1 and n2 be the number of points in the J and the kt dimensions, and set n1 = n2,so that N = n1n2. Show plots of ¯z and σz 2 vs. N,to achieve at least two significant digits. We see the grid-based calculation is much cleaner, evidently reaching very stable values38 MONTE CARLO AND GRID-BASED TECHNIQUES FOR STOCHASTIC SIMULATION147 of z¯ and var(z) in only a hundred or so trials! 4. Comparing the curves you obtained, which is the superior technique for this problem, andhow canyou tell? The grid! 5. Taking your highest-fidelity result for ¯z (probably the grid-based calculation with high N)as truth, you can calculate the apparent errors in ¯z for each method, as a function of N. Making a log-log plot of the absolute values of these errors, can you argue that the error scaling laws 1/N1/2 (MC) and 1/N2/d =1/N (grid) hold? See the last plot. The thin lines indicate trends for N−1/4,N−1/2,N−3/4,N−1,N−5/4 . The MC points are scattered but generally fit the N−1/2 line. The grid data fit the N−1 line, and since the dimension is two, it all works out. Nominal and Four−Corners Step Responses 0 0.5 1 1.5 2 2.5 3 3.5 time, seconds 0 0.2 0.4 0.6 0.8 1 1.2 1.4 φ, radians 438 MONTE CARLO AND GRID-BASED TECHNIQUES FOR STOCHASTIC SIMULATION148 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 mean(z) Monte Carlo Uniform Grid 0 1 2 310 10 10 10 N38 MONTE CARLO AND GRID-BASED TECHNIQUES FOR STOCHASTIC SIMULATION149 0 1 2 3 4 5 6 x 10−3 var(z) Monte Carlo Uniform Grid 0 1 2 310 10 10 10 N38 MONTE CARLO AND GRID-BASED TECHNIQUES FOR STOCHASTIC SIMULATION150 Error, Relative to Highest−Fidelity Grid Result−110−210−310−410−510100 101 102 103 104 N Monte Carlo Uniform Grid38 MONTE CARLO AND GRID-BASED TECHNIQUES FOR STOCHASTIC SIMULATION151 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Study MC vs. grid-based sensitivity % FSH MIT 2.017 November 2009


View Full Document

MIT 2 017J - Study Guide

Documents in this Course
Load more
Download Study Guide
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Study Guide and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Study Guide 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?