GClasses
GClasses::GEvolutionaryOptimizer Class Reference

Detailed Description

Uses an evolutionary process to optimize a vector.

#include <GEvolutionary.h>

Inheritance diagram for GClasses::GEvolutionaryOptimizer:
GClasses::GOptimizer

Public Member Functions

 GEvolutionaryOptimizer (GTargetFunction *pCritic, size_t population, GRand *pRand, double moreFitSurvivalRate)
 moreFitSurvivalRate is the probability that the more fit member (in a tournament selection) survives More...
 
virtual ~GEvolutionaryOptimizer ()
 
virtual const GVeccurrentVector ()
 Returns the best vector found in recent iterations. More...
 
virtual double iterate ()
 Do a little bit more optimization. (This method is typically called in a loop until satisfactory results are obtained.) More...
 
- Public Member Functions inherited from GClasses::GOptimizer
 GOptimizer (GTargetFunction *pCritic)
 
virtual ~GOptimizer ()
 
void basicTest (double minAccuracy, double warnRange=0.001)
 This is a helper method used by the unit tests of several model learners. More...
 
double searchUntil (size_t nBurnInIterations, size_t nIterations, double dImprovement)
 This will first call iterate() nBurnInIterations times, then it will repeatedly call iterate() in blocks of nIterations times. If the error heuristic has not improved by the specified ratio after a block of iterations, it will stop. (For example, if the error before the block of iterations was 50, and the error after is 49, then training will stop if dImprovement is > 0.02.) If the error heuristic is not stable, then the value of nIterations should be large. More...
 

Protected Member Functions

size_t doTournament ()
 Returns the index of the tournament loser (who should typically die and be replaced). More...
 
GEvolutionaryOptimizerNode * node (size_t index)
 
void recomputeError (size_t index, GEvolutionaryOptimizerNode *pNode, const GVec &vec)
 

Protected Attributes

double m_bestErr
 
size_t m_bestIndex
 
std::vector< GEvolutionaryOptimizerNode * > m_population
 
GRandm_pRand
 
double m_tournamentProbability
 
- Protected Attributes inherited from GClasses::GOptimizer
GTargetFunctionm_pCritic
 

Constructor & Destructor Documentation

GClasses::GEvolutionaryOptimizer::GEvolutionaryOptimizer ( GTargetFunction pCritic,
size_t  population,
GRand pRand,
double  moreFitSurvivalRate 
)

moreFitSurvivalRate is the probability that the more fit member (in a tournament selection) survives

virtual GClasses::GEvolutionaryOptimizer::~GEvolutionaryOptimizer ( )
virtual

Member Function Documentation

virtual const GVec& GClasses::GEvolutionaryOptimizer::currentVector ( )
virtual

Returns the best vector found in recent iterations.

Implements GClasses::GOptimizer.

size_t GClasses::GEvolutionaryOptimizer::doTournament ( )
protected

Returns the index of the tournament loser (who should typically die and be replaced).

virtual double GClasses::GEvolutionaryOptimizer::iterate ( )
virtual

Do a little bit more optimization. (This method is typically called in a loop until satisfactory results are obtained.)

Implements GClasses::GOptimizer.

GEvolutionaryOptimizerNode* GClasses::GEvolutionaryOptimizer::node ( size_t  index)
protected
void GClasses::GEvolutionaryOptimizer::recomputeError ( size_t  index,
GEvolutionaryOptimizerNode *  pNode,
const GVec vec 
)
protected

Member Data Documentation

double GClasses::GEvolutionaryOptimizer::m_bestErr
protected
size_t GClasses::GEvolutionaryOptimizer::m_bestIndex
protected
std::vector<GEvolutionaryOptimizerNode*> GClasses::GEvolutionaryOptimizer::m_population
protected
GRand* GClasses::GEvolutionaryOptimizer::m_pRand
protected
double GClasses::GEvolutionaryOptimizer::m_tournamentProbability
protected