My Project
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes
MinorValue Class Reference

#include <Minor.h>

Public Member Functions

bool operator== (const MinorValue &mv) const
 just to make the compiler happy More...
 
bool operator< (const MinorValue &mv) const
 just to make the compiler happy More...
 
virtual int getWeight () const
 A method for retrieving the weight of a given MinorValue. More...
 
int getRetrievals () const
 A method for accessing the number of retrievals of this minor. More...
 
int getPotentialRetrievals () const
 A method for accessing the maximum number of potential retrievals of this minor. More...
 
int getMultiplications () const
 A method for accessing the multiplications performed while computing this minor. More...
 
int getAccumulatedMultiplications () const
 A method for accessing the multiplications performed while computing this minor, including all nested multiplications. More...
 
int getAdditions () const
 A method for accessing the additions performed while computing this minor. More...
 
int getAccumulatedAdditions () const
 A method for accessing the additions performed while computing this minor, including all nested additions. More...
 
void incrementRetrievals ()
 A method for incrementing the number of performed retrievals of this instance of MinorValue. More...
 
int getUtility () const
 A method for obtaining a rank measure for theiven MinorValue. More...
 
virtual std::string toString () const
 A method for providing a printable version of the represented MinorValue. More...
 
void print () const
 A method for printing a string representation of the given MinorValue to std::cout. More...
 

Static Public Member Functions

static void SetRankingStrategy (const int rankingStrategy)
 A method for determining the value ranking strategy. More...
 

Protected Member Functions

int rankMeasure1 () const
 A method for obtaining a rank measure for the given MinorValue. More...
 
int rankMeasure2 () const
 A method for obtaining a rank measure for the given MinorValue. More...
 
int rankMeasure3 () const
 A method for obtaining a rank measure for the given MinorValue. More...
 
int rankMeasure4 () const
 A method for obtaining a rank measure for the given MinorValue. More...
 
int rankMeasure5 () const
 A method for obtaining a rank measure for the given MinorValue. More...
 

Static Protected Member Functions

static int GetRankingStrategy ()
 Accessor for the static private field g_rankingStrategy. More...
 

Protected Attributes

int _retrievals
 -1 iff cache is not used, otherwise the number of retrievals so far of the current minor More...
 
int _potentialRetrievals
 -1 iff cache is not used, otherwise the maximum number of potential retrievals of this minor (e.g. More...
 
int _multiplications
 a store for the actual number of multiplications to compute the current minor More...
 
int _additions
 a store for the actual number of additions to compute the current minor More...
 
int _accumulatedMult
 a store for the accumulated number of multiplications to compute the current minor; This also includes all multiplications nested in sub-minors which may be retrieved from a cache. More...
 
int _accumulatedSum
 a store for the accumulated number of additions to compute the current minor; This also includes all additions nested in sub-minors which may be retrieved from a cache. More...
 
STATIC_VAR int g_rankingStrategy = -1
 private store for the current value ranking strategy; This member can be set using MinorValue::SetRankingStrategy (const int). More...
 

Detailed Description

Definition at line 407 of file Minor.h.

Member Function Documentation

◆ getAccumulatedAdditions()

int MinorValue::getAccumulatedAdditions ( ) const

A method for accessing the additions performed while computing this minor, including all nested additions.

Contrary to MinorValue::getAdditions () const, this method will also count additions needed to compute all cached sub-minors (, although they need not be performed again in order to compute the given instance of MinorValue).

Returns
the number of additions performed, including nested additions
See also
MinorValue::getAdditions () const

Definition at line 898 of file Minor.cc.

899{
900 return _accumulatedSum;
901}
int _accumulatedSum
a store for the accumulated number of additions to compute the current minor; This also includes all ...
Definition: Minor.h:450

◆ getAccumulatedMultiplications()

int MinorValue::getAccumulatedMultiplications ( ) const

A method for accessing the multiplications performed while computing this minor, including all nested multiplications.

Contrary to MinorValue::getMultiplications () const, this method will also count multiplications needed to compute all cached sub-minors (, although they need not be performed again in order to compute the given instance of MinorValue).

Returns
the number of multiplications performed, including nested multiplications
See also
MinorValue::getMultiplications () const

Definition at line 893 of file Minor.cc.

894{
895 return _accumulatedMult;
896}
int _accumulatedMult
a store for the accumulated number of multiplications to compute the current minor; This also include...
Definition: Minor.h:441

◆ getAdditions()

int MinorValue::getAdditions ( ) const

A method for accessing the additions performed while computing this minor.

Additions that were needed to compute cached sub-minors will not be counted, as the value of those sub-minors can be directly retrieved from the cache.

Returns
the number of additions performed
See also
MinorValue::getAccumulatedAdditions () const

Definition at line 888 of file Minor.cc.

889{
890 return _additions;
891}
int _additions
a store for the actual number of additions to compute the current minor
Definition: Minor.h:432

◆ getMultiplications()

int MinorValue::getMultiplications ( ) const

A method for accessing the multiplications performed while computing this minor.

Due to multiplication with zero entries of the underlying matrix, some sub-minors may be irrelevant. In this case, the multiplications needed to compute these sub-minors will not be counted (, as they need not be performed). Moreover, multiplications that were needed to compute cached sub-minors will not be counted either, as the value of those sub-minors can be directly retrieved from the cache.

Returns
the number of multiplications performed
See also
MinorValue::getAccumulatedMultiplications () const

Definition at line 883 of file Minor.cc.

884{
885 return _multiplications;
886}
int _multiplications
a store for the actual number of multiplications to compute the current minor
Definition: Minor.h:427

◆ getPotentialRetrievals()

int MinorValue::getPotentialRetrievals ( ) const

A method for accessing the maximum number of potential retrievals of this minor.

Multiple retrievals will occur when computing large minors by means of cached sub-minors. (Then, the latter ones may be retrieved multiple times.)

Returns
the maximum number of potential retrievals of this minor
See also
MinorValue::getRetrievals () const

Definition at line 878 of file Minor.cc.

879{
881}
int _potentialRetrievals
-1 iff cache is not used, otherwise the maximum number of potential retrievals of this minor (e....
Definition: Minor.h:421

◆ GetRankingStrategy()

int MinorValue::GetRankingStrategy ( )
staticprotected

Accessor for the static private field g_rankingStrategy.

Definition at line 919 of file Minor.cc.

920{
921 return g_rankingStrategy;
922}
STATIC_VAR int g_rankingStrategy
private store for the current value ranking strategy; This member can be set using MinorValue::SetRan...
Definition: Minor.h:541

◆ getRetrievals()

int MinorValue::getRetrievals ( ) const

A method for accessing the number of retrievals of this minor.

Multiple retrievals will occur when computing large minors by means of cached sub-minors. (Then, the latter ones may be retrieved multiple times.)

Returns
the number of retrievals of this minor
See also
MinorValue::getPotentialRetrievals () const

Definition at line 868 of file Minor.cc.

869{
870 return _retrievals;
871}
int _retrievals
-1 iff cache is not used, otherwise the number of retrievals so far of the current minor
Definition: Minor.h:414

◆ getUtility()

int MinorValue::getUtility ( ) const

A method for obtaining a rank measure for theiven MinorValue.


Rank measures are used to compare any two instances of MinorValue. The induced ordering on MinorValues has an impact on the caching behaviour of the underlying cache: Greater MinorValues will be cached longer than lower ones.
More explicitly, this means: Make the return value of this method greater, and the given MinorValue will be cached longer.
Internally, this method will call one of several implementations, depending on the pre-defined caching strategy; see MinorProcessor::SetCacheStrategy (const int).

Returns
an integer rank measure of this
See also
MinorValue::operator< (const MinorValue& mv)
MinorProcessor::SetCacheStrategy (const int)

Definition at line 926 of file Minor.cc.

927{
928 switch (this->GetRankingStrategy())
929 {
930 case 1: return this->rankMeasure1();
931 case 2: return this->rankMeasure2();
932 case 3: return this->rankMeasure3();
933 case 4: return this->rankMeasure4();
934 case 5: return this->rankMeasure5();
935 default: return this->rankMeasure1();
936 }
937}
int rankMeasure4() const
A method for obtaining a rank measure for the given MinorValue.
Definition: Minor.cc:963
int rankMeasure2() const
A method for obtaining a rank measure for the given MinorValue.
Definition: Minor.cc:946
int rankMeasure5() const
A method for obtaining a rank measure for the given MinorValue.
Definition: Minor.cc:972
int rankMeasure3() const
A method for obtaining a rank measure for the given MinorValue.
Definition: Minor.cc:953
int rankMeasure1() const
A method for obtaining a rank measure for the given MinorValue.
Definition: Minor.cc:940
static int GetRankingStrategy()
Accessor for the static private field g_rankingStrategy.
Definition: Minor.cc:919

◆ getWeight()

int MinorValue::getWeight ( ) const
virtual

A method for retrieving the weight of a given MinorValue.

The implementation of Cache uses this function to determine the total weight of an entire cache. As the user can instantiate Cache by determining its maximum total weight (see Cache::Cache(const int, const int)), the definition of weight of a MinorValue may have an impact on the behaviour of the cache.

Returns
the weight of a given instance of MinorValue
See also
Cache::getWeight () const

Reimplemented in IntMinorValue, and PolyMinorValue.

Definition at line 840 of file Minor.cc.

841{
842 assume(false); /* must be overridden in derived classes */
843 return 0;
844}
#define assume(x)
Definition: mod2.h:389

◆ incrementRetrievals()

void MinorValue::incrementRetrievals ( )

A method for incrementing the number of performed retrievals of this instance of MinorValue.


Note that, when calling MinorValue::incrementRetrievals () for some instance mv of MinorValue which has been cached in a Cache under MinorKey mk, the user should be careful: After incrementing the number of retrievals for mv, the user should always put the value again into cache, i.e. should perform Cache::put (const KeyClass&, const ValueClass&) with mk and the modified mv as arguments. This is due to the fact that changing the number of performed retrievals of a MinorValue may have an impact on its ranking in Cache. Only by calling Cache::put (const KeyClass&, const ValueClass&) can the user ensure that the pair (mk --> mv) will be correctly re-positioned within the Cache.

Definition at line 873 of file Minor.cc.

874{
875 _retrievals++;
876}

◆ operator<()

bool MinorValue::operator< ( const MinorValue mv) const

just to make the compiler happy

Definition at line 862 of file Minor.cc.

863{
864 assume(false);
865 return (this < &mv); /* compare addresses of both objects */
866}

◆ operator==()

bool MinorValue::operator== ( const MinorValue mv) const

just to make the compiler happy

Definition at line 848 of file Minor.cc.

849{
850 assume(false);
851 return (this == &mv); /* compare addresses of both objects */
852}

◆ print()

void MinorValue::print ( ) const

A method for printing a string representation of the given MinorValue to std::cout.

Definition at line 903 of file Minor.cc.

904{
905 PrintS(this->toString().c_str());
906}
virtual std::string toString() const
A method for providing a printable version of the represented MinorValue.
Definition: Minor.cc:854
void PrintS(const char *s)
Definition: reporter.cc:284

◆ rankMeasure1()

int MinorValue::rankMeasure1 ( ) const
protected

A method for obtaining a rank measure for the given MinorValue.


Rank measures are used to compare any two instances of MinorValue. The induced ordering on MinorValues has an impact on the caching behaviour in a given cache: Greater MinorValues will be cached longer than lower ones.
More explicitly, this means: Make the return value of this method greater, and the given MinorValue will be cached longer when caching strategy 1 is deployed.
Rank measure 1 is equal to the number of actually performed multiplications to compute mv.

Returns
an integer rank measure of this
See also
MinorValue::operator< (const MinorValue& mv)

Definition at line 940 of file Minor.cc.

941{
942 /* number of actually performed multiplications */
943 return this->getMultiplications();
944}
int getMultiplications() const
A method for accessing the multiplications performed while computing this minor.
Definition: Minor.cc:883

◆ rankMeasure2()

int MinorValue::rankMeasure2 ( ) const
protected

A method for obtaining a rank measure for the given MinorValue.


Rank measures are used to compare any two instances of MinorValue. The induced ordering on MinorValues has an impact on the caching behaviour in a given cache: Greater MinorValues will be cached longer than lower ones.
More explicitly, this means: Make the return value of this method greater, and the given MinorValue will be cached longer when caching strategy 1 is deployed.
Rank measure 2 is equal to the number of accumulated multiplications to compute the given MinorValue. This also includes all nested multiplications which were performed to compute all sub-minors which could be reused from cache.

Returns
an integer rank measure of this
See also
MinorValue::operator< (const MinorValue& mv)

Definition at line 946 of file Minor.cc.

947{
948 /* accumulated number of performed multiplications, i.e. all including
949 nested multiplications */
950 return this->getAccumulatedMultiplications();
951}
int getAccumulatedMultiplications() const
A method for accessing the multiplications performed while computing this minor, including all nested...
Definition: Minor.cc:893

◆ rankMeasure3()

int MinorValue::rankMeasure3 ( ) const
protected

A method for obtaining a rank measure for the given MinorValue.


Rank measures are used to compare any two instances of MinorValue. The induced ordering on MinorValues has an impact on the caching behaviour in a given cache: Greater MinorValues will be cached longer than lower ones.
More explicitly, this means: Make the return value of this method greater, and the given MinorValue will be cached longer when caching strategy 1 is deployed.
Rank measure 3 is equal to the number of actually performed multiplications, weighted with the ratio of not yet performed retrievals over the maximum number of retrievals.

Returns
an integer rank measure of this
See also
MinorValue::operator< (const MinorValue& mv)

Definition at line 953 of file Minor.cc.

954{
955 /* number of performed multiplications, weighted with the ratio of
956 not yet performed retrievals over the maximal number of retrievals */
957 return this->getMultiplications()
958 * (this->getPotentialRetrievals()
959 - this->getRetrievals())
960 / this->getPotentialRetrievals();
961}
int getPotentialRetrievals() const
A method for accessing the maximum number of potential retrievals of this minor.
Definition: Minor.cc:878
int getRetrievals() const
A method for accessing the number of retrievals of this minor.
Definition: Minor.cc:868

◆ rankMeasure4()

int MinorValue::rankMeasure4 ( ) const
protected

A method for obtaining a rank measure for the given MinorValue.


Rank measures are used to compare any two instances of MinorValue. The induced ordering on MinorValues has an impact on the caching behaviour in a given cache: Greater MinorValues will be cached longer than lower ones.
More explicitly, this means: Make the return value of this method greater, and the given MinorValue will be cached longer when caching strategy 1 is deployed.
Rank measure 4 is equal to the number of actually performed multiplications, multiplied with the number of not yet performed retrievals.

Returns
an integer rank measure of this
See also
MinorValue::operator< (const MinorValue& mv)

Definition at line 963 of file Minor.cc.

964{
965 /* number of performed multiplications,
966 multiplied with the number of not yet performed retrievals */
967 return this->getMultiplications()
968 * (this->getPotentialRetrievals()
969 - this->getRetrievals());
970}

◆ rankMeasure5()

int MinorValue::rankMeasure5 ( ) const
protected

A method for obtaining a rank measure for the given MinorValue.


Rank measures are used to compare any two instances of MinorValue. The induced ordering on MinorValues has an impact on the caching behaviour in a given cache: Greater MinorValues will be cached longer than lower ones.
More explicitly, this means: Make the return value of this method greater, and the given MinorValue will be cached longer when caching strategy 1 is deployed.
Rank measure 5 is equal to the number of not yet performed retrievals. This strategy tends to cache MinorValues longer which have a high maximum number of potential retrievals.

Returns
an integer rank measure of this
See also
MinorValue::operator< (const MinorValue& mv)

Definition at line 972 of file Minor.cc.

973{
974 /* number of not yet performed retrievals;
975 tends to cache entries longer when they are going to be retrieved more
976 often in the future */
977 return this->getPotentialRetrievals() - this->getRetrievals();
978}

◆ SetRankingStrategy()

void MinorValue::SetRankingStrategy ( const int  rankingStrategy)
static

A method for determining the value ranking strategy.


This setting has a direct effect on how long the given MinorValue will be cached in any cache that uses MinorValue to represent its cached values.

Parameters
rankingStrategyan int, so far one of 1, 2, ..., 5

Definition at line 909 of file Minor.cc.

910{
911 g_rankingStrategy = rankingStrategy;
912 //if (g_rankingStrategy == 6) : rand() is never used
913 //{
914 // /* initialize the random generator with system time */
915 // srand ( time(NULL) );
916 //}
917}

◆ toString()

string MinorValue::toString ( ) const
virtual

A method for providing a printable version of the represented MinorValue.

Returns
a printable version of the given instance as instance of class string

Reimplemented in IntMinorValue, and PolyMinorValue.

Definition at line 854 of file Minor.cc.

855{
856 assume(false); /* must be overridden in derived classes */
857 return "";
858}

Field Documentation

◆ _accumulatedMult

int MinorValue::_accumulatedMult
protected

a store for the accumulated number of multiplications to compute the current minor; This also includes all multiplications nested in sub-minors which may be retrieved from a cache.

(Thus, these nested operations do not need to be performed again.)

Definition at line 441 of file Minor.h.

◆ _accumulatedSum

int MinorValue::_accumulatedSum
protected

a store for the accumulated number of additions to compute the current minor; This also includes all additions nested in sub-minors which may be retrieved from a cache.

(Thus, these nested operations do not need to be performed again.)

Definition at line 450 of file Minor.h.

◆ _additions

int MinorValue::_additions
protected

a store for the actual number of additions to compute the current minor

Definition at line 432 of file Minor.h.

◆ _multiplications

int MinorValue::_multiplications
protected

a store for the actual number of multiplications to compute the current minor

Definition at line 427 of file Minor.h.

◆ _potentialRetrievals

int MinorValue::_potentialRetrievals
protected

-1 iff cache is not used, otherwise the maximum number of potential retrievals of this minor (e.g.

when the minor would be kept in cache forever)

Definition at line 421 of file Minor.h.

◆ _retrievals

int MinorValue::_retrievals
protected

-1 iff cache is not used, otherwise the number of retrievals so far of the current minor

Definition at line 414 of file Minor.h.

◆ g_rankingStrategy

THREAD_VAR int MinorValue::g_rankingStrategy = -1
protected

private store for the current value ranking strategy; This member can be set using MinorValue::SetRankingStrategy (const int).

Definition at line 541 of file Minor.h.


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