- Main Page
- Namespaces
- Classes
- Files

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

# Ipopt::TaggedObject Class Reference

TaggedObject class. More...

`#include <IpTaggedObject.hpp>`

Inheritance diagram for Ipopt::TaggedObject:

[legend]
Collaboration diagram for Ipopt::TaggedObject:

[legend]
List of all members.

## Public Types
typedef unsigned int | Tag
| Type for the Tag values.
## Public Member Functions
| TaggedObject ()
| Constructor.
virtual | ~TaggedObject ()
| Destructor.
Tag | GetTag () const
| Users of TaggedObjects call this to update their own internal tags every time they perform the expensive operation.
bool | HasChanged (const Tag comparison_tag) const
| Users of TaggedObjects call this to check if the object HasChanged since they last updated their own internal tag.
## Protected Member Functions
void | ObjectChanged ()
| Objects derived from TaggedObject MUST call this method every time their internal state changes to update the internal tag for comparison.
## Private Member Functions
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.
| TaggedObject (const TaggedObject &)
| Copy Constructor.
void | operator= (const TaggedObject &)
| Overloaded Equals Operator.
## Private Attributes
Tag | tag_
| The tag indicating the current state of the object.
Index | cache_priority_
| The index indicating the cache priority for this TaggedObject.
## Static Private Attributes
static Tag | unique_tag_
| static data member that is incremented every time ANY TaggedObject changes.

## Detailed Description

TaggedObject class.

Often, certain calculations or operations are expensive, and it can be very inefficient to perform these calculations again if the input to the calculation has not changed since the result was last stored. This base class provides an efficient mechanism to update a tag, indicating that the object has changed. Users of a TaggedObject class, need their own Tag data member to keep track of the state of the TaggedObject, the last time they performed a calculation. A basic use case for users of a class inheriting off of TaggedObject follows like this:

Initialize your own Tag to zero in constructor.

Before an expensive calculation, check if the TaggedObject has changed, passing in your own Tag, indicating the last time you used the object for the calculation. If it has changed, perform the calculation again, and store the result. If it has not changed, simply return the stored result.

Here is a simple example:

              if (vector.HasChanged(my_vector_tag_)) {
                my_vector_tag_ = vector.GetTag();
                result = PerformExpensiveCalculation(vector);
                return result;
              }
              else {
                return result;
              }

Objects derived from TaggedObject: Objects derived from TaggedObject must indicate that they have changed to the base class using the protected member function ObjectChanged(). For example, a Vector class, inside its own set method, MUST call ObjectChanged() to update the internally stored tag for comparison.

Definition at line 63 of file IpTaggedObject.hpp.

## Member Typedef Documentation

typedef unsigned int Ipopt::TaggedObject::Tag

Type for the Tag values.

Definition at line 67 of file IpTaggedObject.hpp.

## Constructor & Destructor Documentation

Ipopt::TaggedObject::TaggedObject | ( |  | ) | `[inline]`

Constructor.

Definition at line 70 of file IpTaggedObject.hpp.

References ObjectChanged().

virtual Ipopt::TaggedObject::~TaggedObject | ( |  | ) | `[inline, virtual]`

Destructor.

Definition at line 78 of file IpTaggedObject.hpp.

Ipopt::TaggedObject::TaggedObject | ( | const TaggedObject & |  | ) | `[private]`

Copy Constructor.

## Member Function Documentation

Tag Ipopt::TaggedObject::GetTag | ( |  | ) | const`[inline]`

Users of TaggedObjects call this to update their own internal tags every time they perform the expensive operation.

Definition at line 85 of file IpTaggedObject.hpp.

References tag_.

Referenced by Ipopt::Vector::Amax(), Ipopt::Vector::Asum(), Ipopt::Vector::Copy(), Ipopt::Vector::HasValidNumbers(), Ipopt::Vector::Max(), Ipopt::Vector::Min(), Ipopt::Vector::Nrm2(), Ipopt::Vector::Sum(), and Ipopt::Vector::SumLogs().

bool Ipopt::TaggedObject::HasChanged | ( | const Tag | comparison_tag | ) | const`[inline]`

Users of TaggedObjects call this to check if the object HasChanged since they last updated their own internal tag.

Definition at line 95 of file IpTaggedObject.hpp.

References tag_.

void Ipopt::TaggedObject::ObjectChanged | ( |  | ) | `[inline, protected]`

Objects derived from TaggedObject MUST call this method every time their internal state changes to update the internal tag for comparison.

Definition at line 104 of file IpTaggedObject.hpp.

References DBG_ASSERT, DBG_START_METH, Ipopt::Subject::Notify(), Ipopt::Observer::NT_Changed, tag_, and unique_tag_.

Referenced by Ipopt::Vector::AddScalar(), Ipopt::Vector::AddTwoVectors(), Ipopt::Vector::AddVectorQuotient(), Ipopt::Vector::Axpy(), Ipopt::Vector::Copy(), Ipopt::Vector::ElementWiseAbs(), Ipopt::Vector::ElementWiseDivide(), Ipopt::Vector::ElementWiseMax(), Ipopt::Vector::ElementWiseMin(), Ipopt::Vector::ElementWiseMultiply(), Ipopt::Vector::ElementWiseReciprocal(), Ipopt::Vector::ElementWiseSgn(), Ipopt::Vector::ElementWiseSqrt(), Ipopt::CompoundVector::GetCompNonConst(), Ipopt::CompoundSymMatrix::GetCompNonConst(), Ipopt::CompoundMatrix::GetCompNonConst(), Ipopt::SymScaledMatrix::GetUnscaledMatrixNonConst(), Ipopt::ScaledMatrix::GetUnscaledMatrixNonConst(), Ipopt::MultiVectorMatrix::GetVectorNonConst(), Ipopt::Vector::Set(), Ipopt::LowRankUpdateSymMatrix::SetDiag(), Ipopt::LowRankUpdateSymMatrix::SetU(), Ipopt::SymScaledMatrix::SetUnscaledMatrix(), Ipopt::ScaledMatrix::SetUnscaledMatrix(), Ipopt::SymScaledMatrix::SetUnscaledMatrixNonConst(), Ipopt::ScaledMatrix::SetUnscaledMatrixNonConst(), Ipopt::LowRankUpdateSymMatrix::SetV(), TaggedObject(), Ipopt::GenTMatrix::Values(), Ipopt::DenseVector::Values(), Ipopt::DenseSymMatrix::Values(), and Ipopt::DenseGenMatrix::Values().

void Ipopt::TaggedObject::operator= | ( | const TaggedObject & |  | ) | `[private]`

Overloaded Equals Operator.

## Member Data Documentation

Tag Ipopt::TaggedObject::unique_tag_`[static, private]`

static data member that is incremented every time ANY TaggedObject changes.

This allows us to obtain a unique Tag when the object changes

Definition at line 132 of file IpTaggedObject.hpp.

Referenced by ObjectChanged().

Tag Ipopt::TaggedObject::tag_`[private]`

The tag indicating the current state of the object.

We use this to compare against the comparison_tag in the HasChanged method. This member is updated from the unique_tag_ every time the object changes.

Definition at line 139 of file IpTaggedObject.hpp.

Referenced by GetTag(), HasChanged(), and ObjectChanged().

Index Ipopt::TaggedObject::cache_priority_`[private]`

The index indicating the cache priority for this TaggedObject.

If a result that depended on this TaggedObject is cached, it will be cached with this priority

Definition at line 146 of file IpTaggedObject.hpp.

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

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