coco::der_eval Class Reference
[Evaluators]

Backward gradient evaluation with prepared derivative data. More...

#include <der_evaluator.h>

Inheritance diagram for coco::der_eval:

Inheritance graph
[legend]
Collaboration diagram for coco::der_eval:

Collaboration graph
[legend]

List of all members.

Public Types

typedef _Base::node_data_type node_data_type
typedef _Base::return_value return_value
typedef _Base::const_walker const_walker
typedef der_eval_type data_type

Public Member Functions

 der_eval (std::vector< std::vector< double > > &__der_data, variable_indicator &__v, const model &__m, std::vector< std::vector< double > > *__d, std::vector< double > &__grad)
 der_eval (const der_eval &__d)
 ~der_eval ()
void new_point (std::vector< std::vector< double > > &__der_data, const variable_indicator &__v)
void new_result (std::vector< double > &__grad)
void set_mult (double scal)
expression_const_walker short_cut_to (const expression_node &__data)
 der_eval (std::vector< func_cache > &__func_data, variable_indicator &__v, const model &__m, std::vector< std::vector< double > > *__d, std::vector< double > &__grad)
 der_eval (const der_eval &__d)
 ~der_eval ()
void new_point (std::vector< func_cache > &__func_data, const variable_indicator &__v)
void new_result (std::vector< double > &__grad)
void set_mult (double scal)
expression_const_walker short_cut_to (const expression_node &__data)
int preorder (const node_data_type &__data)
void postorder (const node_data_type &__data)
int collect (const node_data_type &__data, const return_value &__rval)
int vcollect (const return_value &__rval)
return_value value ()
return_value vvalue ()
void vinit ()
void initialize ()
int calculate (const expression_node &__data)
void cleanup (const expression_node &__data)
void retrieve_from_cache (const expression_node &__data)
int update (const bool &__rval)
int update (const expression_node &__data, const bool &__rval)
bool calculate_value (bool eval_all)
void initialize ()
int calculate (const expression_node &__data)
void cleanup (const expression_node &__data)
void retrieve_from_cache (const expression_node &__data)
int update (const bool &__rval)
int update (const expression_node &__data, const bool &__rval)
bool calculate_value (bool eval_all)

Protected Member Functions

bool is_cached (const node_data_type &__data)
bool is_cached (const node_data_type &__data)

Protected Attributes

const variable_indicatorv_ind
der_eval_type eval_data


Detailed Description

Backward gradient evaluation including preparation of derivative data.

This class is a cached backward evaluator performing a gradient evaluation with available partial derivative information.

Definition at line 1002 of file der_evaluator.h.


Member Typedef Documentation

This is the type of the walker, which is used for the short-cuts.

Reimplemented from coco::cached_evaluator_base< der_eval_type, expression_node, bool,expression_const_walker >.

Definition at line 853 of file evaluator.h.

The data_type specifies the type of the internal data of the evaluator.

Definition at line 305 of file evaluator.h.

The node_data_type is the datatype of the nodes of the graph.

Reimplemented from coco::cached_evaluator_base< der_eval_type, expression_node, bool,expression_const_walker >.

Definition at line 849 of file evaluator.h.

This type is the result type of the evaluator.

Reimplemented from coco::cached_evaluator_base< der_eval_type, expression_node, bool,expression_const_walker >.

Definition at line 851 of file evaluator.h.


Constructor & Destructor Documentation

coco::der_eval::der_eval ( std::vector< std::vector< double > > &  __der_data,
variable_indicator __v,
const model __m,
std::vector< std::vector< double > > *  __d,
std::vector< double > &  __grad 
) [inline]

Constructor: __der_data contains the partial derivative information, __v is a variable indicator specifying the variables that have changed value since the last evaluation, __m specifies the DAG, and __d the cache (may be NULL). Eventually, __grad is a reference to the result vector. This vector must have the correct length and has to be initialized with zero, since all components are actually computed by adding to the components of __grad.

Definition at line 1035 of file der_evaluator.h.

coco::der_eval::der_eval ( const der_eval __d  )  [inline]

Standard Copy Constructor

Definition at line 1049 of file der_evaluator.h.

coco::der_eval::~der_eval (  )  [inline]

Standard Destructor

Definition at line 1052 of file der_evaluator.h.

coco::der_eval::der_eval ( std::vector< func_cache > &  __func_data,
variable_indicator __v,
const model __m,
std::vector< std::vector< double > > *  __d,
std::vector< double > &  __grad 
) [inline]

Constructor: __der_data contains the partial derivative information, __v is a variable indicator specifying the variables that have changed value since the last evaluation, __m specifies the DAG, and __d the cache (may be NULL). Eventually, __grad is a reference to the result vector. This vector must have the correct length and has to be initialized with zero, since all components are actually computed by adding to the components of __grad.

Definition at line 1036 of file der_evaluator_n.h.

coco::der_eval::der_eval ( const der_eval __d  )  [inline]

Standard Copy Constructor

Definition at line 1050 of file der_evaluator_n.h.

coco::der_eval::~der_eval (  )  [inline]

Standard Destructor

Definition at line 1053 of file der_evaluator_n.h.


Member Function Documentation

int coco::der_eval::calculate ( const expression_node __data  )  [inline, virtual]

This is an evaluator method, as defined for the various evaluators.

Reimplemented from coco::cached_backward_evaluator_base< der_eval_type, expression_node, bool, expression_const_walker >.

Definition at line 1095 of file der_evaluator_n.h.

int coco::der_eval::calculate ( const expression_node __data  )  [inline, virtual]

This is an evaluator method, as defined for the various evaluators.

Reimplemented from coco::cached_backward_evaluator_base< der_eval_type, expression_node, bool, expression_const_walker >.

Definition at line 1090 of file der_evaluator.h.

bool coco::der_eval::calculate_value ( bool  eval_all  )  [inline, virtual]

This is an evaluator method, as defined for the various evaluators.

Reimplemented from coco::cached_backward_evaluator_base< der_eval_type, expression_node, bool, expression_const_walker >.

Definition at line 1775 of file der_evaluator_n.h.

bool coco::der_eval::calculate_value ( bool  eval_all  )  [inline, virtual]

This is an evaluator method, as defined for the various evaluators.

Reimplemented from coco::cached_backward_evaluator_base< der_eval_type, expression_node, bool, expression_const_walker >.

Definition at line 1182 of file der_evaluator.h.

void coco::der_eval::cleanup ( const expression_node __data  )  [inline, virtual]

This is an evaluator method, as defined for the various evaluators.

Reimplemented from coco::cached_backward_evaluator_base< der_eval_type, expression_node, bool, expression_const_walker >.

Definition at line 1731 of file der_evaluator_n.h.

void coco::der_eval::cleanup ( const expression_node __data  )  [inline, virtual]

This is an evaluator method, as defined for the various evaluators.

Reimplemented from coco::cached_backward_evaluator_base< der_eval_type, expression_node, bool, expression_const_walker >.

Definition at line 1138 of file der_evaluator.h.

int coco::cached_backward_evaluator_base< der_eval_type , expression_node , bool , expression_const_walker >::collect ( const node_data_type __data,
const return_value &  __rval 
) [inline, virtual, inherited]

This method is needed by a visitor (see VGTL documentation) and is called for each normal node everytime a child node has been visited passing the return value of the child. It is translated to a call to update.

Reimplemented from coco::_evaluator_base< der_eval_type, expression_node, bool,expression_const_walker >.

Definition at line 879 of file evaluator.h.

void coco::der_eval::initialize (  )  [inline, virtual]

This is an evaluator method, as defined for the various evaluators.

Reimplemented from coco::cached_backward_evaluator_base< der_eval_type, expression_node, bool, expression_const_walker >.

Definition at line 1089 of file der_evaluator_n.h.

void coco::der_eval::initialize (  )  [inline, virtual]

This is an evaluator method, as defined for the various evaluators.

Reimplemented from coco::cached_backward_evaluator_base< der_eval_type, expression_node, bool, expression_const_walker >.

Definition at line 1084 of file der_evaluator.h.

bool coco::der_eval::is_cached ( const node_data_type __data  )  [inline, protected, virtual]

This function determines, whether the gradient for this node is already available.

Reimplemented from coco::cached_backward_evaluator_base< der_eval_type, expression_node, bool, expression_const_walker >.

Definition at line 1022 of file der_evaluator_n.h.

bool coco::der_eval::is_cached ( const node_data_type __data  )  [inline, protected, virtual]

This function determines, whether the gradient for this node is already available.

Reimplemented from coco::cached_backward_evaluator_base< der_eval_type, expression_node, bool, expression_const_walker >.

Definition at line 1014 of file der_evaluator.h.

void coco::der_eval::new_point ( std::vector< func_cache > &  __func_data,
const variable_indicator __v 
) [inline]

This method changes the evaluation point to new derivative data __der. The parameter __v specifies which variables have changed value since the last evaluation.

Definition at line 1058 of file der_evaluator_n.h.

void coco::der_eval::new_point ( std::vector< std::vector< double > > &  __der_data,
const variable_indicator __v 
) [inline]

This method changes the evaluation point to new derivative data __der. The parameter __v specifies which variables have changed value since the last evaluation.

Definition at line 1057 of file der_evaluator.h.

void coco::der_eval::new_result ( std::vector< double > &  __grad  )  [inline]

This method changes the result vector to __grad.

Definition at line 1069 of file der_evaluator_n.h.

void coco::der_eval::new_result ( std::vector< double > &  __grad  )  [inline]

This method changes the result vector to __grad.

Definition at line 1065 of file der_evaluator.h.

void coco::cached_backward_evaluator_base< der_eval_type , expression_node , bool , expression_const_walker >::postorder ( const node_data_type __data  )  [inline, virtual, inherited]

This method is needed by a visitor (see VGTL documentation) and is called right after all children of a node have been visited. It is translated into a call to cleanup.

Reimplemented from coco::_evaluator_base< der_eval_type, expression_node, bool,expression_const_walker >.

Definition at line 874 of file evaluator.h.

int coco::cached_backward_evaluator_base< der_eval_type , expression_node , bool , expression_const_walker >::preorder ( const node_data_type __data  )  [inline, virtual, inherited]

This method is needed by a visitor (see VGTL documentation) and is called right before any children of a node are visited. It checks whether the result of this node is cached and calls either retrieve_from_cache and stops the downwards walk or calls calculate.

Reimplemented from coco::cached_evaluator_base< der_eval_type, expression_node, bool,expression_const_walker >.

Definition at line 862 of file evaluator.h.

void coco::der_eval::retrieve_from_cache ( const expression_node __data  )  [inline, virtual]

This is an evaluator method, as defined for the various evaluators.

Reimplemented from coco::cached_backward_evaluator_base< der_eval_type, expression_node, bool, expression_const_walker >.

Definition at line 1742 of file der_evaluator_n.h.

void coco::der_eval::retrieve_from_cache ( const expression_node __data  )  [inline, virtual]

This is an evaluator method, as defined for the various evaluators.

Reimplemented from coco::cached_backward_evaluator_base< der_eval_type, expression_node, bool, expression_const_walker >.

Definition at line 1149 of file der_evaluator.h.

void coco::der_eval::set_mult ( double  scal  )  [inline]

This method causes the gradient to be multiplied by scal.

Definition at line 1075 of file der_evaluator_n.h.

void coco::der_eval::set_mult ( double  scal  )  [inline]

This method causes the gradient to be multiplied by scal.

Definition at line 1071 of file der_evaluator.h.

expression_const_walker coco::der_eval::short_cut_to ( const expression_node __data  )  [inline, virtual]

NOP version, not needed

Reimplemented from coco::cached_evaluator_base< der_eval_type, expression_node, bool,expression_const_walker >.

Definition at line 1083 of file der_evaluator_n.h.

expression_const_walker coco::der_eval::short_cut_to ( const expression_node __data  )  [inline, virtual]

NOP version, not needed

Reimplemented from coco::cached_evaluator_base< der_eval_type, expression_node, bool,expression_const_walker >.

Definition at line 1078 of file der_evaluator.h.

int coco::der_eval::update ( const expression_node __data,
const bool &  __rval 
) [inline, virtual]

This is an evaluator method, as defined for the various evaluators.

Reimplemented from coco::cached_backward_evaluator_base< der_eval_type, expression_node, bool, expression_const_walker >.

Definition at line 1756 of file der_evaluator_n.h.

int coco::der_eval::update ( const bool &  __rval  )  [inline, virtual]

This is an evaluator method, as defined for the various evaluators.

Reimplemented from coco::cached_backward_evaluator_base< der_eval_type, expression_node, bool, expression_const_walker >.

Definition at line 1749 of file der_evaluator_n.h.

int coco::der_eval::update ( const expression_node __data,
const bool &  __rval 
) [inline, virtual]

This is an evaluator method, as defined for the various evaluators.

Reimplemented from coco::cached_backward_evaluator_base< der_eval_type, expression_node, bool, expression_const_walker >.

Definition at line 1163 of file der_evaluator.h.

int coco::der_eval::update ( const bool &  __rval  )  [inline, virtual]

This is an evaluator method, as defined for the various evaluators.

Reimplemented from coco::cached_backward_evaluator_base< der_eval_type, expression_node, bool, expression_const_walker >.

Definition at line 1156 of file der_evaluator.h.

This method is needed by a visitor (see VGTL documentation) and is called right before the end of the visit of a normal node to retrieve the return value. It is translated to a call to calculate_value with parameter false.

Reimplemented from coco::_evaluator_base< der_eval_type, expression_node, bool,expression_const_walker >.

Definition at line 891 of file evaluator.h.

int coco::cached_backward_evaluator_base< der_eval_type , expression_node , bool , expression_const_walker >::vcollect ( const return_value &  __rval  )  [inline, virtual, inherited]

This method is needed by a visitor (see VGTL documentation) and is called for each virtual node everytime a child node has been visited passing the return value of the child. It is translated to a call to update.

Reimplemented from coco::_evaluator_base< der_eval_type, expression_node, bool,expression_const_walker >.

Definition at line 885 of file evaluator.h.

void coco::cached_backward_evaluator_base< der_eval_type , expression_node , bool , expression_const_walker >::vinit (  )  [inline, inherited]

This method is needed by a visitor using recursive_short_cut_walk for traversing the graph. It is called before performing any graph walk when at a virtual node. It is translated to initialize.

Definition at line 900 of file evaluator.h.

This method is needed by a visitor (see VGTL documentation) and is called right before the end of the visit of a virtual node to retrieve the return value. It is translated to a call to calculate_value with parameter true.

Reimplemented from coco::_evaluator_base< der_eval_type, expression_node, bool,expression_const_walker >.

Definition at line 896 of file evaluator.h.


Member Data Documentation

The internal data of the evaluator

Definition at line 316 of file evaluator.h.

For caching a variable indicator is needed to check which nodes need not be re-evaluated.

Definition at line 427 of file evaluator.h.


The documentation for this class was generated from the following files:

Generated on Tue Feb 9 14:48:12 2010 for COCONUT API by  doxygen 1.5.8