- Main Page
- Namespaces
- Classes
- Files

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Ipopt::CachedResults< T > Class Template Reference

Templated class for Chached Results. More...

`#include <IpCachedResults.hpp>`

List of all members.

## Public Member Functions
bool | InvalidateResult (const std::vector< const TaggedObject * > &dependents, const std::vector< Number > &scalar_dependents)
| Invalidates the result for given dependecies.
Constructors and Destructors.
| CachedResults (Int max_cache_size)
| Constructor, where max_cache_size is the maximal number of results that should be cached.
virtual | ~CachedResults ()
| Destructor.
Generic methods for adding and retrieving cached results.
void | AddCachedResult (const T &result, const std::vector< const TaggedObject * > &dependents, const std::vector< Number > &scalar_dependents)
| Generic method for adding a result to the cache, given a std::vector of TaggesObjects and a std::vector of Numbers.
bool | GetCachedResult (T &retResult, const std::vector< const TaggedObject * > &dependents, const std::vector< Number > &scalar_dependents) const
| Generic method for retrieving a cached results, given the dependencies as a std::vector of TaggesObjects and a std::vector of Numbers.
void | AddCachedResult (const T &result, const std::vector< const TaggedObject * > &dependents)
| Method for adding a result, providing only a std::vector of TaggedObjects.
bool | GetCachedResult (T &retResult, const std::vector< const TaggedObject * > &dependents) const
| Method for retrieving a cached result, providing only a std::vector of TaggedObjects.
Pointer-based methods for adding and retrieving cached
results, providing dependencies explicitly.
void | AddCachedResult1Dep (const T &result, const TaggedObject *dependent1)
| Method for adding a result to the cache, proving one dependency as a TaggedObject explicitly.
bool | GetCachedResult1Dep (T &retResult, const TaggedObject *dependent1)
| Method for retrieving a cached result, proving one dependency as a TaggedObject explicitly.
void | AddCachedResult2Dep (const T &result, const TaggedObject *dependent1, const TaggedObject *dependent2)
| Method for adding a result to the cache, proving two dependencies as a TaggedObject explicitly.
bool | GetCachedResult2Dep (T &retResult, const TaggedObject *dependent1, const TaggedObject *dependent2)
| Method for retrieving a cached result, proving two dependencies as a TaggedObject explicitly.
void | AddCachedResult3Dep (const T &result, const TaggedObject *dependent1, const TaggedObject *dependent2, const TaggedObject *dependent3)
| Method for adding a result to the cache, proving three dependencies as a TaggedObject explicitly.
bool | GetCachedResult3Dep (T &retResult, const TaggedObject *dependent1, const TaggedObject *dependent2, const TaggedObject *dependent3)
| Method for retrieving a cached result, proving three dependencies as a TaggedObject explicitly.
Pointer-free version of the Add and Get methods
bool | GetCachedResult1Dep (T &retResult, const TaggedObject &dependent1)
bool | GetCachedResult2Dep (T &retResult, const TaggedObject &dependent1, const TaggedObject &dependent2)
bool | GetCachedResult3Dep (T &retResult, const TaggedObject &dependent1, const TaggedObject &dependent2, const TaggedObject &dependent3)
void | AddCachedResult1Dep (const T &result, const TaggedObject &dependent1)
void | AddCachedResult2Dep (const T &result, const TaggedObject &dependent1, const TaggedObject &dependent2)
void | AddCachedResult3Dep (const T &result, const TaggedObject &dependent1, const TaggedObject &dependent2, const TaggedObject &dependent3)
## Private Member Functions
void | CleanupInvalidatedResults () const
| internal method for removing stale DependentResults from the list.
void | DebugPrintCachedResults () const
| Print list of currently cached results.
Default Compiler Generated Methods
(Hidden to avoid implicit creation/calling). These methods are not implemented and we do not want the compiler to implement them for us, so we declare them private and do not define them. This ensures that they will not be implicitly created/called.
| CachedResults ()
| Default Constructor.
| CachedResults (const CachedResults &)
| Copy Constructor.
void | operator= (const CachedResults &)
| Overloaded Equals Operator.
## Private Attributes
Int | max_cache_size_
| maximum number of cached results
std::list< DependentResult< T > * > * | cached_results_
| list of currently cached results.

## Detailed Description

### template<class T>
class Ipopt::CachedResults< T >

Templated class for Chached Results.

This class stores up to a given number of "results", entities that are stored here together with identifies, that can be used to later retrieve the information again.

Typically, T is a SmartPtr for some calculated quantity that should be stored (such as a Vector). The identifiers (or dependencies) are a (possibly varying) number of Tags from TaggedObjects, and a number of Numbers. Results are added to the cache using the AddCachedResults methods, and the can be retrieved with the GetCachedResults methods. The second set of methods checks whether a result has been cached for the given identifiers. If a corresponding results is found, a copy of it is returned and the method evaluates to true, otherwise it evaluates to false.

Note that cached results can become "stale", namely when a TaggedObject that is used to identify this CachedResult is changed. When this happens, the cached result can never be asked for again, so that there is no point in storing it any longer. For this purpose, a cached result, which is stored as a DependentResult, inherits off an Observer. This Observer retrieves notification whenever a TaggedObject dependency has changed. Stale results are later removed from the cache.

Definition at line 64 of file IpCachedResults.hpp.

## Constructor & Destructor Documentation

template<class T>

Ipopt::CachedResults< T >::CachedResults | ( | Int | max_cache_size | ) |

Constructor, where max_cache_size is the maximal number of results that should be cached.

If max_cache_size is negative, we allow an infinite abount of cache.

Definition at line 467 of file IpCachedResults.hpp.

References DBG_START_METH.

template<class T>

Ipopt::CachedResults< T >::~CachedResults | ( |  | ) | `[virtual]`

Destructor.

Definition at line 479 of file IpCachedResults.hpp.

References Ipopt::CachedResults< T >::cached_results_, and DBG_START_METH.

template<class T>

Ipopt::CachedResults< T >::CachedResults | ( |  | ) | `[private]`

Default Constructor.

template<class T>

Ipopt::CachedResults< T >::CachedResults | ( | const CachedResults< T > & |  | ) | `[private]`

Copy Constructor.

## Member Function Documentation

template<class T>

void Ipopt::CachedResults< T >::AddCachedResult | ( | const T & | result,
|  | const std::vector< const TaggedObject * > & | dependents,
|  | const std::vector< Number > & | scalar_dependents |
| ) |  |  |

Generic method for adding a result to the cache, given a std::vector of TaggesObjects and a std::vector of Numbers.

Definition at line 504 of file IpCachedResults.hpp.

References Ipopt::CachedResults< T >::cached_results_, Ipopt::CachedResults< T >::CleanupInvalidatedResults(), DBG_ASSERT, DBG_EXEC, DBG_START_METH, Ipopt::CachedResults< T >::DebugPrintCachedResults(), and Ipopt::CachedResults< T >::max_cache_size_.

Referenced by Ipopt::CachedResults< T >::AddCachedResult(), Ipopt::CachedResults< T >::AddCachedResult1Dep(), Ipopt::CachedResults< T >::AddCachedResult2Dep(), and Ipopt::CachedResults< T >::AddCachedResult3Dep().

template<class T>

bool Ipopt::CachedResults< T >::GetCachedResult | ( | T & | retResult,
|  | const std::vector< const TaggedObject * > & | dependents,
|  | const std::vector< Number > & | scalar_dependents |
| ) |  |  | const

Generic method for retrieving a cached results, given the dependencies as a std::vector of TaggesObjects and a std::vector of Numbers.

Definition at line 546 of file IpCachedResults.hpp.

References Ipopt::CachedResults< T >::cached_results_, Ipopt::CachedResults< T >::CleanupInvalidatedResults(), DBG_EXEC, DBG_START_METH, and Ipopt::CachedResults< T >::DebugPrintCachedResults().

Referenced by Ipopt::CachedResults< T >::GetCachedResult(), Ipopt::CachedResults< T >::GetCachedResult1Dep(), Ipopt::CachedResults< T >::GetCachedResult2Dep(), and Ipopt::CachedResults< T >::GetCachedResult3Dep().

template<class T>

void Ipopt::CachedResults< T >::AddCachedResult | ( | const T & | result,
|  | const std::vector< const TaggedObject * > & | dependents |
| ) |  |  |

Method for adding a result, providing only a std::vector of TaggedObjects.

Definition at line 538 of file IpCachedResults.hpp.

References Ipopt::CachedResults< T >::AddCachedResult().

template<class T>

bool Ipopt::CachedResults< T >::GetCachedResult | ( | T & | retResult,
|  | const std::vector< const TaggedObject * > & | dependents |
| ) |  |  | const

Method for retrieving a cached result, providing only a std::vector of TaggedObjects.

Definition at line 576 of file IpCachedResults.hpp.

References Ipopt::CachedResults< T >::GetCachedResult().

template<class T>

void Ipopt::CachedResults< T >::AddCachedResult1Dep | ( | const T & | result,
|  | const TaggedObject * | dependent1 |
| ) |  |  |

Method for adding a result to the cache, proving one dependency as a TaggedObject explicitly.

Definition at line 584 of file IpCachedResults.hpp.

References Ipopt::CachedResults< T >::AddCachedResult(), and DBG_START_METH.

Referenced by Ipopt::CachedResults< Ipopt::SmartPtr< Ipopt::SymMatrix > >::AddCachedResult1Dep().

template<class T>

bool Ipopt::CachedResults< T >::GetCachedResult1Dep | ( | T & | retResult,
|  | const TaggedObject * | dependent1 |
| ) |  |  |

Method for retrieving a cached result, proving one dependency as a TaggedObject explicitly.

Definition at line 598 of file IpCachedResults.hpp.

References DBG_START_METH, and Ipopt::CachedResults< T >::GetCachedResult().

Referenced by Ipopt::CachedResults< Ipopt::SmartPtr< Ipopt::SymMatrix > >::GetCachedResult1Dep().

template<class T>

void Ipopt::CachedResults< T >::AddCachedResult2Dep | ( | const T & | result,
|  | const TaggedObject * | dependent1,
|  | const TaggedObject * | dependent2 |
| ) |  |  |

Method for adding a result to the cache, proving two dependencies as a TaggedObject explicitly.

Definition at line 611 of file IpCachedResults.hpp.

References Ipopt::CachedResults< T >::AddCachedResult(), and DBG_START_METH.

Referenced by Ipopt::CachedResults< Ipopt::SmartPtr< Ipopt::SymMatrix > >::AddCachedResult2Dep().

template<class T>

bool Ipopt::CachedResults< T >::GetCachedResult2Dep | ( | T & | retResult,
|  | const TaggedObject * | dependent1,
|  | const TaggedObject * | dependent2 |
| ) |  |  |

Method for retrieving a cached result, proving two dependencies as a TaggedObject explicitly.

Definition at line 627 of file IpCachedResults.hpp.

References DBG_START_METH, and Ipopt::CachedResults< T >::GetCachedResult().

Referenced by Ipopt::CachedResults< Ipopt::SmartPtr< Ipopt::SymMatrix > >::GetCachedResult2Dep().

template<class T>

void Ipopt::CachedResults< T >::AddCachedResult3Dep | ( | const T & | result,
|  | const TaggedObject * | dependent1,
|  | const TaggedObject * | dependent2,
|  | const TaggedObject * | dependent3 |
| ) |  |  |

Method for adding a result to the cache, proving three dependencies as a TaggedObject explicitly.

Definition at line 641 of file IpCachedResults.hpp.

References Ipopt::CachedResults< T >::AddCachedResult(), and DBG_START_METH.

Referenced by Ipopt::CachedResults< Ipopt::SmartPtr< Ipopt::SymMatrix > >::AddCachedResult3Dep().

template<class T>

bool Ipopt::CachedResults< T >::GetCachedResult3Dep | ( | T & | retResult,
|  | const TaggedObject * | dependent1,
|  | const TaggedObject * | dependent2,
|  | const TaggedObject * | dependent3 |
| ) |  |  |

Method for retrieving a cached result, proving three dependencies as a TaggedObject explicitly.

Definition at line 659 of file IpCachedResults.hpp.

References DBG_START_METH, and Ipopt::CachedResults< T >::GetCachedResult().

Referenced by Ipopt::CachedResults< Ipopt::SmartPtr< Ipopt::SymMatrix > >::GetCachedResult3Dep().

template<class T>

bool Ipopt::CachedResults< T >::GetCachedResult1Dep | ( | T & | retResult,
|  | const TaggedObject & | dependent1 |
| ) |  |  | `[inline]`

Definition at line 161 of file IpCachedResults.hpp.

template<class T>

bool Ipopt::CachedResults< T >::GetCachedResult2Dep | ( | T & | retResult,
|  | const TaggedObject & | dependent1,
|  | const TaggedObject & | dependent2 |
| ) |  |  | `[inline]`

Definition at line 165 of file IpCachedResults.hpp.

template<class T>

bool Ipopt::CachedResults< T >::GetCachedResult3Dep | ( | T & | retResult,
|  | const TaggedObject & | dependent1,
|  | const TaggedObject & | dependent2,
|  | const TaggedObject & | dependent3 |
| ) |  |  | `[inline]`

Definition at line 171 of file IpCachedResults.hpp.

template<class T>

void Ipopt::CachedResults< T >::AddCachedResult1Dep | ( | const T & | result,
|  | const TaggedObject & | dependent1 |
| ) |  |  | `[inline]`

Definition at line 178 of file IpCachedResults.hpp.

template<class T>

void Ipopt::CachedResults< T >::AddCachedResult2Dep | ( | const T & | result,
|  | const TaggedObject & | dependent1,
|  | const TaggedObject & | dependent2 |
| ) |  |  | `[inline]`

Definition at line 183 of file IpCachedResults.hpp.

template<class T>

void Ipopt::CachedResults< T >::AddCachedResult3Dep | ( | const T & | result,
|  | const TaggedObject & | dependent1,
|  | const TaggedObject & | dependent2,
|  | const TaggedObject & | dependent3 |
| ) |  |  | `[inline]`

Definition at line 189 of file IpCachedResults.hpp.

template<class T>

bool Ipopt::CachedResults< T >::InvalidateResult | ( | const std::vector< const TaggedObject * > & | dependents,
|  | const std::vector< Number > & | scalar_dependents |
| ) |  |  |

Invalidates the result for given dependecies.

Sets the stale flag for the corresponding cached result to true if it is found. Returns true, if the result was found.

Definition at line 676 of file IpCachedResults.hpp.

References Ipopt::CachedResults< T >::cached_results_, and Ipopt::CachedResults< T >::CleanupInvalidatedResults().

template<class T>

void Ipopt::CachedResults< T >::operator= | ( | const CachedResults< T > & |  | ) | `[private]`

Overloaded Equals Operator.

template<class T>

void Ipopt::CachedResults< T >::CleanupInvalidatedResults | ( |  | ) | const`[private]`

internal method for removing stale DependentResults from the list.

It is called at the beginning of every GetDependentResult method.

Definition at line 698 of file IpCachedResults.hpp.

References Ipopt::CachedResults< T >::cached_results_, and DBG_START_METH.

Referenced by Ipopt::CachedResults< T >::AddCachedResult(), Ipopt::CachedResults< T >::GetCachedResult(), and Ipopt::CachedResults< T >::InvalidateResult().

template<class T>

void Ipopt::CachedResults< T >::DebugPrintCachedResults | ( |  | ) | const`[private]`

Print list of currently cached results.

Definition at line 725 of file IpCachedResults.hpp.

References Ipopt::CachedResults< T >::cached_results_, DBG_PRINT, DBG_START_METH, and DBG_VERBOSITY.

Referenced by Ipopt::CachedResults< T >::AddCachedResult(), and Ipopt::CachedResults< T >::GetCachedResult().

## Member Data Documentation

template<class T>

Int Ipopt::CachedResults< T >::max_cache_size_`[private]`

maximum number of cached results

Definition at line 224 of file IpCachedResults.hpp.

Referenced by Ipopt::CachedResults< T >::AddCachedResult().

template<class T>

std::list<DependentResult<T>*>* Ipopt::CachedResults< T >::cached_results_`[mutable, private]`

list of currently cached results.

Definition at line 227 of file IpCachedResults.hpp.

Referenced by Ipopt::CachedResults< T >::AddCachedResult(), Ipopt::CachedResults< T >::CleanupInvalidatedResults(), Ipopt::CachedResults< T >::DebugPrintCachedResults(), Ipopt::CachedResults< T >::GetCachedResult(), Ipopt::CachedResults< T >::InvalidateResult(), and Ipopt::CachedResults< T >::~CachedResults().

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

- /home/coin/SVN-release/Ipopt-3.2.1/Ipopt/src/Common/IpCachedResults.hpp