next up previous contents
Next: 4.3 Coupling of SRSM Up: 4. COUPLING OF THE Previous: 4.1 Methods for Estimation

4.2 Automatic Differentiation using ADIFOR

ADIFOR (Automatic DIfferentiation of FORtran) [17] transforms the model source code based on the specification of the dependent and independent variables, and produces source code that calculates the derivatives of the dependent variables with respect to the independent variables. Figure 4.2 presents a schematic depiction of the automatic differentiation procedure using ADIFOR.

Figure 4.3 presents an example of the transformation of source code using ADIFOR. Figure 4.3 (a) shows a segment of a sample Fortran program for which derivatives are desired. The dependent variable is y and the independent variables are x(1) through x(10). Figure 4.3 (b) shows the derivative code produced through the application of ADIFOR. Using the resultant code, the partial derivatives of y with respect to independent variable x(i) can be obtained through the corresponding element dy(i) from the array dy.

This example illustrates some key advantages of using ADIFOR over other methods: ADIFOR steps through the conditional execution loops and iterative loops (e.g., the if and the do statements in Figure 4.3 (a)), and ADIFOR can calculate derivatives for assignment and iteration statements (e.g., the statement y =x(i) * y *y). Further, the iterative loops and conditional loops are common in computer codes, while they do not appear in algebraic or differential equations. It must be noted that the value of the variable y depends to a great extent the ``sign'' of the various x(i)'s, specifically of x(n); such situations are difficult to express in algebraic forms, whereas they can be readily expressed in computer code. Since ADIFOR methodically follows the model code, all the complex logic of the model code is followed exactly by the derivative code.

In principle, this method can be easily extended to compute derivatives for computer code of arbitrary length and complexity. Furthermore, in the application of ADIFOR, the user has to only (a) specify the information about the dependent and independent variables, and (b) add statements to the derivative code to output the derivatives.


  
Figure 4.3: FORTRAN derivative code generation using ADIFOR: (a) Sample code fragment and (b) ADIFOR generated derivative code
\begin{figure}
\large\tt
\begin{tabular}{\vert l\vert}
\hspace*{0.1in}~\\
\hl...
....1in}enddo\\
\hspace*{0.1in}~\\
\hline
(b)\\
\hline
\end{tabular}\end{figure}


next up previous contents
Next: 4.3 Coupling of SRSM Up: 4. COUPLING OF THE Previous: 4.1 Methods for Estimation
Sastry S. Isukapalli
1999-01-19