ECF 1.7
Clonalg Class Reference

Clonal Selection Algorithm (see e.g. http://en.wikipedia.org/wiki/Clonal_Selection_Algorithm). More...

#include <AlgClonalg.h>

Inheritance diagram for Clonalg:
Algorithm

Public Member Functions

void registerParameters (StateP state)
 Register algorithm's parameters (if any).
bool initialize (StateP state)
 Initialize the algorithm, read parameters from the system, do a sanity check.
bool advanceGeneration (StateP state, DemeP deme)
 Perform a single generation on a single deme.
bool markAntibodies (DemeP deme)
 mark antibodies so the alg can know which clone belongs to which parent Antibody
bool cloningPhase (StateP state, DemeP deme, std::vector< IndividualP > &clones)
bool hypermutationPhase (StateP state, DemeP deme, std::vector< IndividualP > &clones)
bool selectionPhase (StateP state, DemeP deme, std::vector< IndividualP > &clones)
bool birthPhase (StateP state, DemeP deme, std::vector< IndividualP > &clones)
bool replacePopulation (StateP state, DemeP deme, std::vector< IndividualP > &clones)
 replace population with the contents of clones vector
Public Member Functions inherited from Algorithm
std::string getName ()
 Get algorithm name. Each algorithm is uniquely identified with its name.
virtual bool isParallel ()
 Is algorithm parallel (false by default for all algorithms not inheriting ParallelAlgorithm class).
bool isImplicitParallel ()
 Is algorithm run in implicit parallel mode (in development, see tutorial).
virtual bool initializePopulation (StateP)
 Evaluate initial population (called by State::run before evolution starts).
virtual void read ()
virtual bool advanceGeneration (StateP state)
 Perform one generation of the algorithm on the whole population.
void evaluate (IndividualP ind)
 Helper function: evaluate an individual.
uint mutate (const std::vector< IndividualP > &pool)
 Helper function: send a vector of individuals to mutation.
uint mutate (const IndividualP victim)
 Helper function: send a single individual to mutation.
void replaceWith (IndividualP oldInd, IndividualP newInd)
 Helper function: replace an individual in current deme.
void replaceWith (uint oldIndId, IndividualP newInd)
 Helper function: replace an individual at given position in current deme.
void registerParallelParameters (StateP state)
 used only in parallel ECF
bool initializeParallel (StateP state)
 used only in parallel ECF
virtual bool advanceGeneration (StateP state)
 Parallel ECF: Perform one generation of the algorithm.
virtual void bcastTermination (StateP state)
 Parallel ECF: broadcast termination to worker processes.
void registerParallelParameters (StateP state)
 Parallel ECF: Register parameters for implicit parallel algorithm version.
bool initializeParallel (StateP state)
 Parallel ECF: Initialize implicit parallel algorithm.
void initializeImplicit (StateP state)
 Parallel ECF: Initialize implicit parallel mode.
bool implicitParallelOperate (StateP state)
 Parallel ECF: Worker processes in implicit parallel algorithm.
void evaluate (IndividualP ind)
 Parallel ECF: evaluate an individual.
void implicitEvaluate (IndividualP ind)
 Parallel ECF: implicitly evaluate an individual (store for later evaluation in implicit parallel version).
uint mutate (const IndividualP victim)
 Parallel ECF: immediately mutate an individual.
uint mutate (const std::vector< IndividualP > &pool)
 Parallel ECF: mutate a vector of individuals.
uint implicitMutate (IndividualP ind)
 Parallel ECF: implicitly mutate an individual (store for later mutation in implicit parallel version).
void replaceWith (IndividualP oldInd, IndividualP newInd)
 Parallel ECF: replace an individual in a deme.
void replaceWith (uint oldIndId, IndividualP newInd)
 Parallel ECF: replace an individual at given position in a deme.
bool mate (IndividualP p1, IndividualP p2, IndividualP child)
 Helper function: crossover two individuals.
IndividualP copy (IndividualP source)
 Helper function: make a copy of an individual.
bool removeFrom (IndividualP victim, std::vector< IndividualP > &pool)
 Helper function: remove victim from pool of individual pointers.
bool isMember (IndividualP single, std::vector< IndividualP > &pool)
 Helper function: check if individual is in the pool.

Static Protected Member Functions

static bool sortPopulationByFitness (IndividualP ab1, IndividualP ab2)
 sort vector of antibodies in regards to their fitness
static bool sortPopulationByParentAndFitness (IndividualP ab1, IndividualP ab2)
 sort vector of antibodies first by their antibody parents and then by their fitness

Protected Attributes

double ubound
double lbound
uint dimension
bool areGenotypesAdded_
uint n
 number of antibodies cloned every generation
double beta
 parameter which determines the number of clones for every antibody
double c
 mutation parameter
double d
 fraction of population regenerated every generation
std::string cloningVersion
 specifies whether to use static or proportional cloning
std::string selectionScheme
 specifies which selection scheme to use CLONALG1 or CLONALG2
Protected Attributes inherited from Algorithm
DemeP activeDeme_
std::string name_
 algorithm name
bool bImplicitParallel_
 implicit parallel flag
std::vector< SelectionOperatorP > selectionOp
 sel. operators used by algorithm
std::vector< IndividualP > requests_
std::vector< IndividualP > stored_
 individual vectors for implicit evaluation
std::vector< uint > requestIds_
 individual indexes for implicit evaluation
std::vector< IndividualP > demeCopy_
std::vector< IndividualP > myJob_
 worker's individual vector
CommunicatorP comm_
uint jobSize_
uint totalEvaluations_
uint wastedEvaluations_
bool bImplicitEvaluation_
 implicit evaluation flag
bool bImplicitMutation_
 implicit mutation flag
bool bSynchronized_
 is implicit paralelization synchronous
SelectionOperatorP selBestOp
std::vector< IndividualP > requestsMut_
std::vector< IndividualP > receivedMut_
 individual vectors for implicit mutation
std::vector< uint > requestMutIds_
 individual indexes for implicit mutation
IndividualP currentBest_
std::vector< IndividualP > storedInds_
std::vector< std::vector< IndividualP > > sentInds_
 individuals sent for evaluation
std::vector< bool > isConsistent_
 is individual (genotype-fitness pair) consistent

Additional Inherited Members

Public Attributes inherited from Algorithm
CrossoverP crossover_
 sptr to container of crossover operators (set by the system)
MutationP mutation_
 sptr to container of mutation operators (set by the system)
EvaluateOpP evalOp_
 sptr to evaluation operator (set by the system)
StateP state_
Protected Member Functions inherited from Algorithm
bool registerParameter (StateP state, std::string name, voidP value, enum ECF::type T, std::string description="")
 Helper function: register a single parameter with the system.
voidP getParameterValue (StateP state, std::string name)
 Helper function: get parameter value from the system.
void storeIndividual (IndividualP)
 stores the individual (if it is consistent), resets consistency flag
void storeGenotypes (std::vector< IndividualP > &)
 adds genotypes of individuals to 'sent' repository
void setConsistency (IndividualP)
 denotes current individual as consistent
void restoreIndividuals (std::vector< uint >)
 restores individuals whose fitness is received
void restorePopulation ()
 restores inconsistent individuals to last consistent state

Detailed Description

Clonal Selection Algorithm (see e.g. http://en.wikipedia.org/wiki/Clonal_Selection_Algorithm).

This CLONALG implements:

  • cloning Versions:
    • static cloning : n of the best antibodies are cloned beta*populationSize times
    • proportional cloning: number of clones per antibody is proportional to that ab's fitness
  • inversely proportional hypermutation : better antibodies are mutated less
  • selectionSchemes:
    • CLONALG1 - at new generation each antibody will be substituded by the best individual of its set of beta*population clones
    • CLONALG2 - new generation will be formed by the best (1-d)*populationSize clones ( or all if the number of clones is less than that )
  • birthPhase: where d * populationSize of new antibodies are randomly created and added to the population for diversification

CLONALG algorithm accepts only a single FloatingPoint genotype. Additionally, if chosen, selectionScheme CLONALG1 adds a FloatingPoint genotype (parentAntibody) to mark which clone came from which antibodies.

Definition at line 24 of file AlgClonalg.h.

Constructor & Destructor Documentation

◆ Clonalg()

Clonalg::Clonalg ( )

Definition at line 7 of file AlgClonalg.cpp.

Member Function Documentation

◆ advanceGeneration()

bool Clonalg::advanceGeneration ( StateP state,
DemeP deme )
virtual

Perform a single generation on a single deme.

Must be implemented by a specific algorithm class

Implements Algorithm.

Definition at line 125 of file AlgClonalg.cpp.

◆ birthPhase()

bool Clonalg::birthPhase ( StateP state,
DemeP deme,
std::vector< IndividualP > & clones )

Definition at line 275 of file AlgClonalg.cpp.

◆ cloningPhase()

bool Clonalg::cloningPhase ( StateP state,
DemeP deme,
std::vector< IndividualP > & clones )

Definition at line 152 of file AlgClonalg.cpp.

◆ hypermutationPhase()

bool Clonalg::hypermutationPhase ( StateP state,
DemeP deme,
std::vector< IndividualP > & clones )

Definition at line 188 of file AlgClonalg.cpp.

◆ initialize()

bool Clonalg::initialize ( StateP state)
virtual

Initialize the algorithm, read parameters from the system, do a sanity check.

Called by the system before the algorithm starts (Algorithm::advanceGeneration)

Reimplemented from Algorithm.

Definition at line 33 of file AlgClonalg.cpp.

◆ markAntibodies()

bool Clonalg::markAntibodies ( DemeP deme)

mark antibodies so the alg can know which clone belongs to which parent Antibody

Definition at line 141 of file AlgClonalg.cpp.

◆ registerParameters()

void Clonalg::registerParameters ( StateP state)
virtual

Register algorithm's parameters (if any).

Called by the system before algorithm initialization (Algorithm::initialize)

Reimplemented from Algorithm.

Definition at line 16 of file AlgClonalg.cpp.

◆ replacePopulation()

bool Clonalg::replacePopulation ( StateP state,
DemeP deme,
std::vector< IndividualP > & clones )

replace population with the contents of clones vector

Definition at line 296 of file AlgClonalg.cpp.

◆ selectionPhase()

bool Clonalg::selectionPhase ( StateP state,
DemeP deme,
std::vector< IndividualP > & clones )

Definition at line 244 of file AlgClonalg.cpp.

◆ sortPopulationByFitness()

bool Clonalg::sortPopulationByFitness ( IndividualP ab1,
IndividualP ab2 )
inlinestaticprotected

sort vector of antibodies in regards to their fitness

Definition at line 41 of file AlgClonalg.h.

◆ sortPopulationByParentAndFitness()

bool Clonalg::sortPopulationByParentAndFitness ( IndividualP ab1,
IndividualP ab2 )
inlinestaticprotected

sort vector of antibodies first by their antibody parents and then by their fitness

Definition at line 44 of file AlgClonalg.h.

Member Data Documentation

◆ areGenotypesAdded_

bool Clonalg::areGenotypesAdded_
protected

Definition at line 31 of file AlgClonalg.h.

◆ beta

double Clonalg::beta
protected

parameter which determines the number of clones for every antibody

Definition at line 34 of file AlgClonalg.h.

◆ c

double Clonalg::c
protected

mutation parameter

Definition at line 35 of file AlgClonalg.h.

◆ cloningVersion

std::string Clonalg::cloningVersion
protected

specifies whether to use static or proportional cloning

Definition at line 37 of file AlgClonalg.h.

◆ d

double Clonalg::d
protected

fraction of population regenerated every generation

Definition at line 36 of file AlgClonalg.h.

◆ dimension

uint Clonalg::dimension
protected

Definition at line 30 of file AlgClonalg.h.

◆ lbound

double Clonalg::lbound
protected

Definition at line 29 of file AlgClonalg.h.

◆ n

uint Clonalg::n
protected

number of antibodies cloned every generation

Definition at line 33 of file AlgClonalg.h.

◆ selectionScheme

std::string Clonalg::selectionScheme
protected

specifies which selection scheme to use CLONALG1 or CLONALG2

Definition at line 38 of file AlgClonalg.h.

◆ ubound

double Clonalg::ubound
protected

Definition at line 28 of file AlgClonalg.h.


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