GClasses
GClasses::GRubberBallSwarm Class Referenceabstract

This is an algorithm for finding good starting points within a constrained optimization problem. It works by simulating "rubber balls" which bounce around inside the constrained region. After many iterations, they tend to be spread somewhat uniformly, even with very complex constrained shapes. The balls learn to approximate the shape of the shell, so if the room is wider than it is tall, the balls will learn to bounce sideways more often than vertically. More...

#include <GParticleSwarm.h>

Public Member Functions

 GRubberBallSwarm (int dims, int ballCount, GRand *pRand)
 All of the simulated rubber balls are initialized to the zero-vector, which is assumed to be within the constrained region. More...
 
virtual ~GRubberBallSwarm ()
 
double * ball (int index)
 Returns the current vector of the specified ball. More...
 
virtual bool isInside (double *pVec)=0
 This method should be implemented to return true iff pVec is within the constrained region. More...
 
void iterate ()
 Simulate another unit of time. More...
 
virtual void onBounce (double *pVec)
 This method is called when a ball bounces off of the constraint shell. More...
 

Protected Member Functions

void advanceBall (double *pBallPos)
 
void initBall (double *pBall, double speed)
 
void mutateBall (int dest, int source)
 

Protected Attributes

double m_acceleration
 
GMatrix m_balls
 
int m_compareBall
 
int m_condemnedBall
 
double m_condemnedDistance
 
int m_currentBall
 
double m_deceleration
 
int m_dims
 
double m_learningRate
 
double * m_pNormal
 
GRandm_pRand
 
double * m_pTemp
 
int m_wallPrecisionIters
 

Detailed Description

This is an algorithm for finding good starting points within a constrained optimization problem. It works by simulating "rubber balls" which bounce around inside the constrained region. After many iterations, they tend to be spread somewhat uniformly, even with very complex constrained shapes. The balls learn to approximate the shape of the shell, so if the room is wider than it is tall, the balls will learn to bounce sideways more often than vertically.

Constructor & Destructor Documentation

GClasses::GRubberBallSwarm::GRubberBallSwarm ( int  dims,
int  ballCount,
GRand pRand 
)

All of the simulated rubber balls are initialized to the zero-vector, which is assumed to be within the constrained region.

virtual GClasses::GRubberBallSwarm::~GRubberBallSwarm ( )
virtual

Member Function Documentation

void GClasses::GRubberBallSwarm::advanceBall ( double *  pBallPos)
protected
double* GClasses::GRubberBallSwarm::ball ( int  index)

Returns the current vector of the specified ball.

void GClasses::GRubberBallSwarm::initBall ( double *  pBall,
double  speed 
)
protected
virtual bool GClasses::GRubberBallSwarm::isInside ( double *  pVec)
pure virtual

This method should be implemented to return true iff pVec is within the constrained region.

void GClasses::GRubberBallSwarm::iterate ( )

Simulate another unit of time.

void GClasses::GRubberBallSwarm::mutateBall ( int  dest,
int  source 
)
protected
virtual void GClasses::GRubberBallSwarm::onBounce ( double *  pVec)
inlinevirtual

This method is called when a ball bounces off of the constraint shell.

Member Data Documentation

double GClasses::GRubberBallSwarm::m_acceleration
protected
GMatrix GClasses::GRubberBallSwarm::m_balls
protected
int GClasses::GRubberBallSwarm::m_compareBall
protected
int GClasses::GRubberBallSwarm::m_condemnedBall
protected
double GClasses::GRubberBallSwarm::m_condemnedDistance
protected
int GClasses::GRubberBallSwarm::m_currentBall
protected
double GClasses::GRubberBallSwarm::m_deceleration
protected
int GClasses::GRubberBallSwarm::m_dims
protected
double GClasses::GRubberBallSwarm::m_learningRate
protected
double* GClasses::GRubberBallSwarm::m_pNormal
protected
GRand* GClasses::GRubberBallSwarm::m_pRand
protected
double* GClasses::GRubberBallSwarm::m_pTemp
protected
int GClasses::GRubberBallSwarm::m_wallPrecisionIters
protected