WhichStack Class Reference

#include <WhichStack.h>

List of all members.

Public Member Functions

 WhichStack ()
 WhichStack (int maxSize)
 ~WhichStack ()
void create (Data *data, int type, float alpha=1, float beta=1, float gamma=1)
bool push (Rule *r)
int select (int count=2000, int check=200, float improve=0.2)
bool pickTwo ()
unsigned int size ()
RulegetBest ()
RulegetRule (int index)
std::ostream & report (std::ostream &stream, int n)
void print (std::ostream &stream)
bool push (int[] attVal, float(*scoreFcn)(Rule *))

Protected Member Functions

bool contains (Rule *r)
int pick (std::vector< float > scores, float sum)


Detailed Description

Represents a Which-specific stack. It is sorted and has special facilities geared towards Which.

Constructor & Destructor Documentation

WhichStack::WhichStack (  ) 

Empty Constructor.

WhichStack::WhichStack ( int  maxSize  ) 

Creates a WhichStack that has a maximum size.

Parameters:
maxSize The maximum size this WhichStack can be. If it is -1, the size if infinite.

WhichStack::~WhichStack (  ) 

Destructor.


Member Function Documentation

void WhichStack::create ( Data data,
int  type,
float  alpha = 1,
float  beta = 1,
float  gamma = 1 
)

Creates a WhichStack having Rules of single attribute-value pairs.

Parameters:
data The data file to use to create the Rules from.
type The type of Rules to create.
alpha The weight for pd.
beta The weight of pf.
gamma The weight for effort.

bool WhichStack::push ( Rule r  ) 

Pushes a Rule onto the WhichStack in the position based on the Rule's score. If the Rule would be last on a WhichStack of finite size that is full, the item will not be pushed. --- THE RULE WILL NOT BE DELETED IF IT IS NOT ADDED ---

Parameters:
r The Rule to push onto the WhichStack.
Returns:
True if the Rule made it onto the WhichStack, false otherwise.

int WhichStack::select ( int  count = 2000,
int  check = 200,
float  improve = 0.2 
)

Calls pickTwo a series of times to attempt to create a "best" Rules.

Parameters:
count The number of times to call PickTwo total.
check How many pickTwo calls to allow to pass before a check is made to make sure improvement is still happening.
improve A decimal number representing the percentage of increase in score a current "best" Rule must have since the last check in order to continue calling pickTwo.
Returns:
The true number of times pickTwo was called. A number <= count.

bool WhichStack::pickTwo (  ) 

Based on a weighted distribution, picks two Rules from the WhichStack and combines them.

Returns:
True if the new Rule made it onto the WhichStack, false otherwise.

unsigned int WhichStack::size (  ) 

Gets the number of Rules in the WhichStack.

Returns:
The number of Rules in the WhichStack.

Rule * WhichStack::getBest (  ) 

Gets the best Rule in the WhichStack.

Returns:
The top of the WhichStack.

Rule * WhichStack::getRule ( int  index  ) 

Gets the Rule indexed by index.

Parameters:
index The index of the Rule to get( 0 is the same as calling getBest() );
Returns:
The Rule at index index.

std::ostream& WhichStack::report ( std::ostream &  stream,
int  n 
)

Prints the first n Rules in the WhichStack.

Parameters:
stream The stream to print to.
n The number of Rules to print.
Returns:
The stream;

void WhichStack::print ( std::ostream &  stream  ) 

Outputs the WhichStack to a stream.

Parameters:
stream The stream to output to.

bool WhichStack::push ( int[]  attVal,
float(*)(Rule *)  scoreFcn 
)

This is a special method for using the WhichStack as an API. This allows a user to push items in isolation into the WhickStack, much like the standard construction does.

Parameters:
attVal A length 1x2 array that stores an attribute index and its value index to be added to the WhichStack.
scoreFcn A pointer to the method of evaluating a Rule.

bool WhichStack::contains ( Rule r  )  [protected]

Checks to see if a Rule is already in this WhichStack.

Parameters:
r The Rulet to look for.
Returns:
True if r is in this WhichStack, false otherwise.

int WhichStack::pick ( std::vector< float >  scores,
float  sum 
) [protected]

Picks a Rule from the WhichStack.

Parameters:
scores The vector of scores for the rule.
max The maximum number to select.
Returns:
The position in the WhichStack of the chosen rule.


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

Generated on Wed Feb 20 13:52:40 2008 for Which by  doxygen 1.5.5