GClasses
|
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. | |
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 |
GRand * | m_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 |
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.
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] |
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.
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] |