openModeller  Version 1.4.0
GarpRuleSet Class Reference

#include <ruleset.hh>

Collaboration diagram for GarpRuleSet:

List of all members.

Public Member Functions

 GarpRuleSet (int size)
 ~GarpRuleSet ()
int size ()
int numRules ()
void clear ()
void trim (int rules)
void filter (PerfIndex perfIndex, double threshold)
GarpRuleget (int index)
int insert (PerfIndex perfIndex, GarpRule *rule)
int replace (int index, GarpRule *rule)
int remove (int index)
int add (GarpRule *rule)
int findSimilar (GarpRule *rule)
Scalar getValue (const Sample &x) const
void performanceSummary (PerfIndex perfIndex, double *best, double *worst, double *average)
void gatherRuleSetStats (int gen)
void log () const

Private Attributes

GarpRule ** _rules
int _size
int _numRules

Detailed Description

Stores a set of Garp rules. Consists of a valid Garp model. Provide basic methods for manipulating the set of rules as a whole.

Definition at line 53 of file ruleset.hh.


Constructor & Destructor Documentation

GarpRuleSet::GarpRuleSet ( int  size)

Constructor.

Parameters:
sizeDefines the maximum number of rules that can be stored in the rule set

Definition at line 54 of file ruleset.cpp.

References _numRules, _rules, _size, and size().

Here is the call graph for this function:

Definition at line 66 of file ruleset.cpp.

References _rules, and clear().

Here is the call graph for this function:


Member Function Documentation

int GarpRuleSet::add ( GarpRule rule)

Adds new rule at the end of rule set.

Parameters:
rulePointer to rule to be added to rule set. Once rule is added, rule set gains control over memory allocated to rule after insertion, i.e., rule set will deallocate memory for that rule when rule is eliminated.
Returns:
Number of rules after addition on success, 0 on failure.

Definition at line 244 of file ruleset.cpp.

References _numRules, _rules, and _size.

Referenced by Garp::_setConfiguration(), Garp::colonize(), Garp::select(), TEST(), and testHelperAddRules().

Remove all rules from rule set.

Definition at line 91 of file ruleset.cpp.

References trim().

Referenced by Garp::select(), TEST(), and ~GarpRuleSet().

Here is the call graph for this function:

void GarpRuleSet::filter ( PerfIndex  perfIndex,
double  threshold 
)

Eliminates rules with performance below a certain threshold from the rule set.

Parameters:
perfIndexIndex on performance array that will be considered for elimination of rules.
thresholdMinimum performance value a rule must present to remain in the rule set. Rules with performance value below threshold are removed from rule set.

Definition at line 122 of file ruleset.cpp.

References _numRules, and _rules.

Referenced by Garp::iterate(), and TEST().

Checks whether there is rule in the rule set that is similar to a given rule.

Parameters:
rulePointer to rule
Returns:
Index of first similar rule found in rule set or -1 if there are no similar rules in rule set.
Note:
: Similarity between rules is defined on the Rule class hierarchy by abstract method Rule->similar() and its concrete implementations in subclasses.

Definition at line 267 of file ruleset.cpp.

References _numRules, and _rules.

Referenced by Garp::keepFittest().

Definition at line 344 of file ruleset.cpp.

References _numRules, _rules, GarpRule::getPerformance(), GarpRule::getPrediction(), PerfUtil, and GarpRule::type().

Here is the call graph for this function:

GarpRule * GarpRuleSet::get ( int  index)

Returns pointer to rule at a given position in rule set

Parameters:
indexIndex of rule to be returned
Returns:
Pointer to rule at given position. This pointer should not be deallocated by caller.

Definition at line 201 of file ruleset.cpp.

References _numRules, and _rules.

Referenced by Garp::_getConfiguration(), Garp::crossover(), Garp::evaluate(), Garp::keepFittest(), Garp::mutate(), printPerfs(), Garp::select(), and TEST().

Scalar GarpRuleSet::getValue ( const Sample x) const

Returns rule prediction for a given data vector.

Returns:
Prediction value for the data vector based on GARP model

Definition at line 285 of file ruleset.cpp.

References _numRules, _rules, and GarpRule::getPrediction().

Referenced by Garp::getValue().

Here is the call graph for this function:

int GarpRuleSet::insert ( PerfIndex  perfIndex,
GarpRule rule 
)

Inserts a rule in the rule set, preserving sort order

Parameters:
perfIndexIndex on performance array that will be considered during insertion to find correct position for new rule in the rule set.
rulepointer to the new rule being inserted. Rule set gains control over memory allocated to rule after insertion, i.e., rule set will deallocate memory for that rule when rule is eliminated.
Returns:
Index where rule was inserted in the rule set.

Definition at line 165 of file ruleset.cpp.

References _numRules, _rules, and GarpRule::getPerformance().

Referenced by Garp::keepFittest().

Here is the call graph for this function:

void GarpRuleSet::log ( ) const

Definition at line 332 of file ruleset.cpp.

References _numRules, _rules, Log::info(), Log::instance(), and GarpRule::log().

Here is the call graph for this function:

Returns the number of rules currently stored in the rule set.

Definition at line 83 of file ruleset.cpp.

References _numRules.

Referenced by Garp::_getConfiguration(), Garp::colonize(), Garp::crossover(), Garp::evaluate(), Garp::keepFittest(), Garp::mutate(), printPerfs(), Garp::select(), and TEST().

void GarpRuleSet::performanceSummary ( PerfIndex  perfIndex,
double *  best,
double *  worst,
double *  average 
)

Returns performance statistics of the rule set.

Parameters:
perfIndexBase calculation on this performance array index.
bestReturns best performance value found in rule set.
worstReturns worst performance value found in rule set.
averageReturns average performance of rules in rule set.

Definition at line 304 of file ruleset.cpp.

References _numRules, _rules, and GarpRule::getPerformance().

Referenced by Garp::iterate(), Garp::select(), and TEST().

Here is the call graph for this function:

int GarpRuleSet::remove ( int  index)

Remove rule at a given position in rule set

Parameters:
indexIndex of rule to be removed.
Returns:
1 on success, 0 on failure.

Definition at line 225 of file ruleset.cpp.

References _numRules, and _rules.

Referenced by Garp::keepFittest().

int GarpRuleSet::replace ( int  index,
GarpRule rule 
)

Replaces rule at a given position in rule set by another rule provided

Parameters:
indexIndex of rule to be replaced.
rulePointer to rule that will replace old one. Once rule is added, rule set gains control over memory allocated to rule after insertion, i.e., rule set will deallocate memory for that rule when rule is eliminated.
Returns:
1 on success, 0 on failure.
Note:
This method can break the rule set sort order.

Definition at line 212 of file ruleset.cpp.

References _numRules, and _rules.

Referenced by TEST().

Returns size of rule set, i.e., the maximum number of rules that can be stored in the rule set.

Definition at line 75 of file ruleset.cpp.

References _size.

Referenced by GarpRuleSet(), and TEST().

void GarpRuleSet::trim ( int  rules)

Remove last rules in a rule set, trimming it to a certain number of rules.

Parameters:
rulesNumber of rules that will remain in the rule set. It will preserve the first rules and will eliminate remaining ones from rule set.

Definition at line 99 of file ruleset.cpp.

References _numRules, _rules, and _size.

Referenced by clear(), Garp::iterate(), and TEST().


Member Data Documentation

int GarpRuleSet::_size [private]

Definition at line 184 of file ruleset.hh.

Referenced by add(), GarpRuleSet(), size(), and trim().


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