SOT
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
sot::GeneticAlgorithm Class Reference

Genetic Algorithm. More...

#include <genetic_algorithm.h>

Public Member Functions

 GeneticAlgorithm (std::shared_ptr< Problem > &data, int numIndividuals, int numGenerations)
 Constructor. More...
 
 GeneticAlgorithm (std::shared_ptr< Problem > &data, int numIndividuals, int numGenerations, int numThreads)
 Constructor. More...
 
 GeneticAlgorithm (std::shared_ptr< Problem > &data, std::shared_ptr< ExpDesign > &expDes, int numIndividuals, int numGenerations)
 Constructor. More...
 
 GeneticAlgorithm (std::shared_ptr< Problem > &data, std::shared_ptr< ExpDesign > &expDes, int numIndividuals, int numGenerations, int numThreads)
 Constructor. More...
 
Result run ()
 Runs the optimization algorithm. More...
 

Protected Member Functions

void evalBatch (const mat &batch, vec &funVals)
 Evalaute a batch of points in parallel. More...
 

Protected Attributes

std::shared_ptr< ProblemmData
 
std::shared_ptr< ExpDesignmExpDes
 
double mSigma = 0.2
 
int mTournamentSize = 5
 
double mpCross = 0.9
 
double mpMutation
 
int mDim
 
vec mxLow
 
vec mxUp
 
int mNumVariables
 
int mNumIndividuals
 
int mNumGenerations
 
std::string mName = "Genetic Algorithm"
 
bool mRandomInit
 
int mNumThreads
 
int mEvalCount = 0
 
std::mutex mMutex
 

Detailed Description

Genetic Algorithm.

This is an implementation of the popular Genetic Algorithm. The implementation is of a real-valued GA and the mutation operator used is a normally distributed perturbation. The number of evaluations carried out by the method is mNumIndividuals * mNumGenerations.

Author
David Eriksson, dme65.nosp@m.@cor.nosp@m.nell..nosp@m.edu

Constructor & Destructor Documentation

sot::GeneticAlgorithm::GeneticAlgorithm ( std::shared_ptr< Problem > &  data,
int  numIndividuals,
int  numGenerations 
)
inline

Constructor.

Parameters
dataA shared pointer to the optimization problem
numIndividualsNumber of individuals in the population
numGenerationsNumber of generations
sot::GeneticAlgorithm::GeneticAlgorithm ( std::shared_ptr< Problem > &  data,
int  numIndividuals,
int  numGenerations,
int  numThreads 
)
inline

Constructor.

Parameters
dataA shared pointer to the optimization problem
numIndividualsNumber of individuals in the population
numGenerationsNumber of generations
numThreadsNumber of threads
sot::GeneticAlgorithm::GeneticAlgorithm ( std::shared_ptr< Problem > &  data,
std::shared_ptr< ExpDesign > &  expDes,
int  numIndividuals,
int  numGenerations 
)
inline

Constructor.

Parameters
dataA shared pointer to the optimization problem
expDesExperimental design used to generate the initial population
numIndividualsNumber of individuals in the population
numGenerationsNumber of generations
Exceptions
std::logic_errorif the size of the experimental design doesn't match
sot::GeneticAlgorithm::GeneticAlgorithm ( std::shared_ptr< Problem > &  data,
std::shared_ptr< ExpDesign > &  expDes,
int  numIndividuals,
int  numGenerations,
int  numThreads 
)
inline

Constructor.

Parameters
dataA shared pointer to the optimization problem
expDesA shared pointer to the experimental design
numIndividualsNumber of individuals in the population
numGenerationsNumber of generations
numThreadsNumber of threads

Member Function Documentation

void sot::GeneticAlgorithm::evalBatch ( const mat batch,
vec funVals 
)
inlineprotected

Evalaute a batch of points in parallel.

Parameters
batchBatch of points to be evaluated
funValsVector to write the function values to
Result sot::GeneticAlgorithm::run ( )
inline

Runs the optimization algorithm.

Returns
A Result object with the results from the run

Member Data Documentation

std::shared_ptr<Problem> sot::GeneticAlgorithm::mData
protected

A shared pointer to the optimization problem

int sot::GeneticAlgorithm::mDim
protected

Number of dimensions (extracted from mData)

int sot::GeneticAlgorithm::mEvalCount = 0
protected

Evaluation counter for evalauting batches

std::shared_ptr<ExpDesign> sot::GeneticAlgorithm::mExpDes
protected

A shared pointer to the experimental design (if used)

std::mutex sot::GeneticAlgorithm::mMutex
protected

Mutex for assigning evaluations to the threads

std::string sot::GeneticAlgorithm::mName = "Genetic Algorithm"
protected

Strategy name

int sot::GeneticAlgorithm::mNumGenerations
protected

Number of generations

int sot::GeneticAlgorithm::mNumIndividuals
protected

Number of individuals in the population

int sot::GeneticAlgorithm::mNumThreads
protected

Number of threads

int sot::GeneticAlgorithm::mNumVariables
protected

Number of variables (extracted from mData)

double sot::GeneticAlgorithm::mpCross = 0.9
protected

Crossover probability

double sot::GeneticAlgorithm::mpMutation
protected

Mutation probability

bool sot::GeneticAlgorithm::mRandomInit
protected

True if the initial population is uniformly random

double sot::GeneticAlgorithm::mSigma = 0.2
protected

Standard deviation for the mutatio w.r.t. the unit box

int sot::GeneticAlgorithm::mTournamentSize = 5
protected

Tournament size

vec sot::GeneticAlgorithm::mxLow
protected

Lower variable bounds (extracted from mData)

vec sot::GeneticAlgorithm::mxUp
protected

Upper variable bounds (extracted from mData)


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