next up previous contents
Next: Using OSInstance Methods: High Up: Using OSInstance Methods: Low Previous: First Derivative Reverse Sweep   Contents

Second Derivative Reverse Sweep Calculations

In order to calculate second derivatives using reverseAD forward sweeps of order 0 and 1 must have been completed. The call to reverseAD(2, vlambda) will return a vector of dimension $ 2n$ where $ n$ is the number of variables. If the zero-order forward sweep is forward(0,x0) and the first-order forward sweep is forwardAD(1, x1) where x1 $ = e^{(i)},$ then the return vector z = reverseAD(2, vlambda) is

$\displaystyle z[2j - 2] = \frac{\partial L (x^{(0)}, \lambda^{(0)})}{\partial x_{j}} , \quad j = 1, \ldots, n$     (28)


$\displaystyle z[2j - 1] = \frac{\partial^2 L(x^{(0)}, \lambda^{(0)})}{\partial x_{i} \partial x_{j}} , \quad j = 1, \ldots, n$     (29)

where
$\displaystyle L (x, \lambda) = \sum_{k = 1}^{m} \lambda_{k} f_{k}(x)$     (30)

For example, the following calls will calculate the third row (column) of the Hessian of the Lagrangian.

x0[0] = 1;
x0[1] = 5; 	
x0[2] = 5;
osinstance->forwardAD(0, x0);	
x1[0] = 0;
x1[1] = 0;
x1[2] = 1;
osinstance->forwardAD(1, x1);
vlambda[0] = 1;
vlambda[1] = 2;
vlambda[2] = 1;
osinstance->reverseAD(2, vlambda);
This returns
$\displaystyle \frac{\partial L (x^{(0)}, \lambda^{(0)})}{\partial x_{0}} = 3, \...
... = 2.74, \quad \frac{\partial L (x^{(0)}, \lambda^{(0)})}{\partial x_{3}} = 4.2$      


$\displaystyle \frac{\partial^2 L(x^{(0)}, \lambda^{(0)})}{\partial x_{3} \parti...
...rac{\partial^2 L(x^{(0)}, \lambda^{(0)})}{\partial x_{3} \partial x_{3}} = -.04$      

The reason that

$\displaystyle \frac{\partial L (x^{(0)}, \lambda^{(0)})}{\partial x_{1}} = 2 \times 1.37 = 2.74
$

and not

$\displaystyle \frac{\partial L (x^{(0)}, \lambda^{(0)})}{\partial x_{1}} = 1 \times 9 + 2 \times 6.37 = 9 + 12.74 = 21.74
$

is that the terms $ 9x_1$ in the objective and $ 5x_1$ in the first constraint are captured in the linear section of the OSiL input and therefore do not appear as a nonlinear term in <nonlinearExpressions>. Again, forwardAD and reverseAD only operate on variables and terms in either the <quadraticCoefficients> or <nonlinearExpressions> sections.


next up previous contents
Next: Using OSInstance Methods: High Up: Using OSInstance Methods: Low Previous: First Derivative Reverse Sweep   Contents
Kipp Martin 2008-01-16