![]() |
ECF 1.7
|
#include <Algorithm.h>
Public Member Functions | |
| 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 | advanceGeneration (StateP, DemeP)=0 |
| Perform a single generation on a single deme. | |
| virtual bool | initialize (StateP) |
| Initialize the algorithm, read parameters from the system, do a sanity check. | |
| virtual void | registerParameters (StateP) |
| Register algorithm's parameters (if any). | |
| 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. | |
Public Attributes | |
| 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 | |
| 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 | |
Protected Attributes | |
| 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 | |
Algorithm base class.
All algorithms must inherit this one. An algorithm combines selection operators (SelectionOperator), crossover (Algorithm::mate), mutation (Algorithm::mutate) and additional logic to build an evolutionary procedure.
Definition at line 19 of file Algorithm.h.
|
inline |
Definition at line 85 of file Algorithm.h.
|
inlinevirtual |
Definition at line 88 of file Algorithm.h.
|
inlinevirtual |
Perform one generation of the algorithm on the whole population.
Default if not reimplemented: algorithm advances one generation on each deme
Definition at line 139 of file Algorithm.h.
|
pure virtual |
Perform a single generation on a single deme.
Must be implemented by a specific algorithm class
Implemented in AlgAEliGpea2, AlgAEliGpea, AlgGEP, AlgNSGA2, AlgSGenGpea, ArtificialBeeColony, Clonalg, CuckooSearch, DifferentialEvolution, Elimination, EvolutionStrategy, GeneticAnnealing, GenHookeJeeves, MyAlg, OptIA, ParticleSwarmOptimization, RandomSearch, RouletteWheel, SteadyStateTournament, and XCS.
|
virtual |
Parallel ECF: broadcast termination to worker processes.
Reimplemented in AlgAEliGpea.
Definition at line 290 of file Algorithm.cpp.
|
inline |
Helper function: make a copy of an individual.
Definition at line 291 of file Algorithm.h.
|
inline |
Parallel ECF: evaluate an individual.
Definition at line 227 of file Algorithm.h.
|
inline |
Helper function: evaluate an individual.
Definition at line 157 of file Algorithm.h.
|
inline |
Get algorithm name. Each algorithm is uniquely identified with its name.
Definition at line 92 of file Algorithm.h.
|
inlineprotected |
Helper function: get parameter value from the system.
| state | pointer to State object |
| name | parameter name |
Definition at line 46 of file Algorithm.h.
| void Algorithm::implicitEvaluate | ( | IndividualP | ind | ) |
Parallel ECF: implicitly evaluate an individual (store for later evaluation in implicit parallel version).
Definition at line 117 of file Algorithm.cpp.
| uint Algorithm::implicitMutate | ( | IndividualP | ind | ) |
Parallel ECF: implicitly mutate an individual (store for later mutation in implicit parallel version).
Definition at line 176 of file Algorithm.cpp.
| bool Algorithm::implicitParallelOperate | ( | StateP | state | ) |
Parallel ECF: Worker processes in implicit parallel algorithm.
Definition at line 239 of file Algorithm.cpp.
|
inlinevirtual |
Initialize the algorithm, read parameters from the system, do a sanity check.
Called by the system before the algorithm starts (Algorithm::advanceGeneration)
Reimplemented in AlgAEliGpea2, AlgAEliGpea, AlgGEP, AlgNSGA2, AlgSGenGpea, ArtificialBeeColony, Clonalg, CuckooSearch, DifferentialEvolution, Elimination, EvolutionStrategy, GeneticAnnealing, GenHookeJeeves, MyAlg, OptIA, ParticleSwarmOptimization, RandomSearch, RouletteWheel, SteadyStateTournament, and XCS.
Definition at line 115 of file Algorithm.h.
| void Algorithm::initializeImplicit | ( | StateP | state | ) |
Parallel ECF: Initialize implicit parallel mode.
Definition at line 92 of file Algorithm.cpp.
|
inline |
used only in parallel ECF
Definition at line 203 of file Algorithm.h.
|
virtual |
Evaluate initial population (called by State::run before evolution starts).
Definition at line 338 of file Algorithm.cpp.
|
inline |
Is algorithm run in implicit parallel mode (in development, see tutorial).
Definition at line 100 of file Algorithm.h.
|
inline |
Helper function: check if individual is in the pool.
Definition at line 311 of file Algorithm.h.
|
inlinevirtual |
Is algorithm parallel (false by default for all algorithms not inheriting ParallelAlgorithm class).
Reimplemented in ParallelAlgorithm.
Definition at line 96 of file Algorithm.h.
|
inline |
Helper function: crossover two individuals.
Definition at line 285 of file Algorithm.h.
|
inline |
Parallel ECF: immediately mutate an individual.
Definition at line 247 of file Algorithm.h.
|
inline |
Helper function: send a single individual to mutation.
Definition at line 175 of file Algorithm.h.
|
inline |
Parallel ECF: mutate a vector of individuals.
Definition at line 255 of file Algorithm.h.
|
inline |
Helper function: send a vector of individuals to mutation.
Definition at line 169 of file Algorithm.h.
|
inlinevirtual |
Definition at line 130 of file Algorithm.h.
|
inline |
used only in parallel ECF
Definition at line 199 of file Algorithm.h.
|
inlineprotected |
Helper function: register a single parameter with the system.
| state | pointer to State object |
| name | unique parameter name |
| value | pointer to parameter value object (caller provides) |
| T | parameter type (see Registry.h) |
Definition at line 35 of file Algorithm.h.
|
inlinevirtual |
Register algorithm's parameters (if any).
Called by the system before algorithm initialization (Algorithm::initialize)
Reimplemented in AlgAEliGpea2, AlgAEliGpea, AlgGEP, AlgSGenGpea, ArtificialBeeColony, Clonalg, CuckooSearch, DifferentialEvolution, Elimination, EvolutionStrategy, GeneticAnnealing, GenHookeJeeves, MyAlg, OptIA, ParticleSwarmOptimization, RandomSearch, RouletteWheel, SteadyStateTournament, and XCS.
Definition at line 123 of file Algorithm.h.
|
inline |
Helper function: remove victim from pool of individual pointers.
Definition at line 297 of file Algorithm.h.
|
inline |
Helper function: replace an individual in current deme.
| oldInd | individual to be replaced |
| newInd | new individual |
Definition at line 187 of file Algorithm.h.
|
inline |
Parallel ECF: replace an individual at given position in a deme.
Definition at line 275 of file Algorithm.h.
|
inline |
Helper function: replace an individual at given position in current deme.
| oldIndId | index of individual to be replaced |
| newInd | new individual |
Definition at line 195 of file Algorithm.h.
|
protected |
restores individuals whose fitness is received
Definition at line 455 of file Algorithm.cpp.
|
protected |
restores inconsistent individuals to last consistent state
Definition at line 481 of file Algorithm.cpp.
|
protected |
denotes current individual as consistent
Definition at line 424 of file Algorithm.cpp.
|
protected |
adds genotypes of individuals to 'sent' repository
Definition at line 432 of file Algorithm.cpp.
|
protected |
stores the individual (if it is consistent), resets consistency flag
Definition at line 414 of file Algorithm.cpp.
|
protected |
Definition at line 22 of file Algorithm.h.
|
protected |
implicit evaluation flag
Definition at line 59 of file Algorithm.h.
|
protected |
implicit mutation flag
Definition at line 60 of file Algorithm.h.
|
protected |
implicit parallel flag
Definition at line 24 of file Algorithm.h.
|
protected |
is implicit paralelization synchronous
Definition at line 61 of file Algorithm.h.
|
protected |
Definition at line 56 of file Algorithm.h.
| CrossoverP Algorithm::crossover_ |
sptr to container of crossover operators (set by the system)
Definition at line 80 of file Algorithm.h.
|
protected |
Definition at line 65 of file Algorithm.h.
|
protected |
Definition at line 54 of file Algorithm.h.
| EvaluateOpP Algorithm::evalOp_ |
sptr to evaluation operator (set by the system)
Definition at line 82 of file Algorithm.h.
|
protected |
is individual (genotype-fitness pair) consistent
Definition at line 69 of file Algorithm.h.
|
protected |
Definition at line 57 of file Algorithm.h.
| MutationP Algorithm::mutation_ |
sptr to container of mutation operators (set by the system)
Definition at line 81 of file Algorithm.h.
|
protected |
worker's individual vector
Definition at line 55 of file Algorithm.h.
|
protected |
algorithm name
Definition at line 23 of file Algorithm.h.
|
protected |
individual vectors for implicit mutation
Definition at line 63 of file Algorithm.h.
|
protected |
individual indexes for implicit evaluation
Definition at line 53 of file Algorithm.h.
|
protected |
individual indexes for implicit mutation
Definition at line 64 of file Algorithm.h.
|
protected |
Definition at line 52 of file Algorithm.h.
|
protected |
Definition at line 63 of file Algorithm.h.
|
protected |
Definition at line 62 of file Algorithm.h.
|
protected |
sel. operators used by algorithm
Definition at line 25 of file Algorithm.h.
|
protected |
individuals sent for evaluation
Definition at line 68 of file Algorithm.h.
| StateP Algorithm::state_ |
Definition at line 83 of file Algorithm.h.
|
protected |
individual vectors for implicit evaluation
Definition at line 52 of file Algorithm.h.
|
protected |
Definition at line 67 of file Algorithm.h.
|
protected |
Definition at line 58 of file Algorithm.h.
|
protected |
Definition at line 58 of file Algorithm.h.