GClasses

GClasses::GRubberBallSwarm Class Reference

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>

List of all members.

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.
virtual ~GRubberBallSwarm ()
virtual bool isInside (double *pVec)=0
 This method should be implemented to return true iff pVec is within the constrained region.
virtual void onBounce (double *pVec)
 This method is called when a ball bounces off of the constraint shell.
void iterate ()
 Simulate another unit of time.
double * ball (int index)
 Returns the current vector of the specified ball.

Protected Member Functions

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

Protected Attributes

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

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) [inline, virtual]

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


Member Data Documentation