TMB Documentation
v1.9.11
|
Sequential reduction algorithm. More...
#include <graph_transform.hpp>
Public Member Functions | |
void | merge (Index i) |
Merge all cliques that contain a given independent variable. More... | |
void | reorder_random () |
Re-order random effects. More... | |
sequential_reduction (global &glob, std::vector< Index > random, std::vector< sr_grid > grid=std::vector< sr_grid >(1, sr_grid(-20, 20, 200)), std::vector< Index > random2grid=std::vector< Index >(0), bool perm=true) | |
CTOR of sequential reduction object. More... | |
std::vector< ad_aug > | tabulate (std::vector< Index > inv_index, Index dep_index) |
tabulate each combination of variables of a subgraph More... | |
void | update (Index i) |
Integrate independent variable number i, (inv_index[i] ). More... | |
Sequential reduction algorithm.
Example: Consider the circular graph
Each edge is a logspace term. Assume we integrate in some random order:
Definition at line 581 of file graph_transform.hpp.
TMBad::sequential_reduction::sequential_reduction | ( | global & | glob, |
std::vector< Index > | random, | ||
std::vector< sr_grid > | grid = std::vector<sr_grid>(1, sr_grid(-20, 20, 200)) , |
||
std::vector< Index > | random2grid = std::vector<Index>(0) , |
||
bool | perm = true |
||
) |
CTOR of sequential reduction object.
The optimal order is not found by this routine. In general a good choice is the fill-reducing permutation of the sparse Cholesky factorization. For hierarchical models the optimal ordering is the opposite of the 'natural simulation order'.
glob | Output from accumulation_tree_split() . |
random | Which independent variables to integrate out and in what order (if perm=false ). To be specific, the order of integration is inv_index[random[0]] , inv_index[random[1]] , ... |
grid | Vector of grids to be used by individual random effects - see random2grid . |
random2grid | Factor determining the grid to be used for each random effect. To be specific, the i'th random effect random[i] uses the grid grid[random2grid[i]] . |
perm | Apply a permutation of random based on a simple heuristic (see reorder_random() ). |
void TMBad::sequential_reduction::merge | ( | Index | i | ) |
Merge all cliques that contain a given independent variable.
i | Index to remove |
Example:
void TMBad::sequential_reduction::reorder_random | ( | ) |
Re-order random effects.
Two random effects are connected if they both affect the same term. This function finds a fill-reducing permutation of the corresponding un-directed graph.
Definition at line 3885 of file TMBad.cpp.
Referenced by sequential_reduction().
std::vector< ad_aug > TMBad::sequential_reduction::tabulate | ( | std::vector< Index > | inv_index, |
Index | dep_index | ||
) |
tabulate each combination of variables of a subgraph
It is assumed that a subgraph has been made. The subgraph has a certain number of inputs and outputs. This function tabulates a given output dep_index
for all combinations of inputs inv_index
. To avoid tabulating identical functions many times, we a use caching based on term hash codes.
void TMBad::sequential_reduction::update | ( | Index | i | ) |
Integrate independent variable number i, (inv_index[i]
).
The algorithm works as follows: