Prev Next Index-> contents reference index search external Up-> CppAD ADFun sparsity_pattern for_hes_sparsity CppAD-> Install Introduction AD ADFun preprocessor multi_thread utility ipopt_solve Example speed Appendix ADFun-> record_adfun drivers Forward Reverse sparsity_pattern sparse_derivative optimize abs_normal FunCheck check_for_nan sparsity_pattern-> for_jac_sparsity ForSparseJac rev_jac_sparsity RevSparseJac rev_hes_sparsity RevSparseHes for_hes_sparsity ForSparseHes dependency.cpp rc_sparsity.cpp subgraph_sparsity for_hes_sparsity-> for_hes_sparsity.cpp Headings-> Syntax Purpose x BoolVector SizeVector f select_domain select_range internal_bool pattern_out Sparsity for Entire Hessian Algorithm Example

$\newcommand{\W}[1]{ \; #1 \; } \newcommand{\R}[1]{ {\rm #1} } \newcommand{\B}[1]{ {\bf #1} } \newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} } \newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} } \newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} } \newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }$
Forward Mode Hessian Sparsity Patterns

Syntax
f.for_hes_sparsity(      select_domain, select_range, internal_bool, pattern_out )

Purpose
We use $F : \B{R}^n \rightarrow \B{R}^m$ to denote the AD function corresponding to the operation sequence stored in f . Fix a diagonal matrix $D \in \B{R}^{n \times n}$, a vector $s \in \B{R}^m$ and define the function $$H(x) = D ( s^\R{T} F )^{(2)} ( x ) D$$ Given the sparsity for $D$ and $s$, for_hes_sparsity computes a sparsity pattern for $H(x)$.

x
Note that the sparsity pattern $H(x)$ corresponds to the operation sequence stored in f and does not depend on the argument x .

BoolVector
The type BoolVector is a SimpleVector class with elements of type bool.

SizeVector
The type SizeVector is a SimpleVector class with elements of type size_t.

f
The object f has prototype       ADFun<Base> f 
select_domain
The argument select_domain has prototype       const BoolVector& select_domain  It has size $n$ and specifies which components of the diagonal of $D$ are non-zero; i.e., select_domain[j] is true if and only if $D_{j,j}$ is possibly non-zero.

select_range
The argument select_range has prototype       const BoolVector& select_range  It has size $m$ and specifies which components of the vector $s$ are non-zero; i.e., select_range[i] is true if and only if $s_i$ is possibly non-zero.

internal_bool
If this is true, calculations are done with sets represented by a vector of boolean values. Otherwise, a vector of sets of integers is used.

pattern_out
This argument has prototype       sparse_rc<SizeVector>& pattern_out  This input value of pattern_out does not matter. Upon return pattern_out is a sparsity pattern for $H(x)$.

Sparsity for Entire Hessian
Suppose that $R$ is the $n \times n$ identity matrix. In this case, pattern_out is a sparsity pattern for $(s^\R{T} F) F^{(2)} ( x )$.

Algorithm
See Algorithm II in Computing sparse Hessians with automatic differentiation by Andrea Walther. Note that s provides the information so that 'dead ends' are not included in the sparsity pattern.

Example
The file for_hes_sparsity.cpp contains an example and test of this operation. It returns true if it succeeds and false otherwise.