Samchon Framework for CPP  1.0.0
samchon::library::GAParameters Class Reference

A structure containing parameters of genetic algorithm. More...

#include <GAParameters.hpp>

Collaboration diagram for samchon::library::GAParameters:

Public Member Functions

 GAParameters ()
 
 GAParameters (size_t generation, size_t population, size_t tournament, double mutationRate)
 
void setGeneration (size_t val)
 
void setPopulation (size_t val)
 
void setTournament (size_t val)
 
void setMutationRate (double val)
 
auto getGeneration () const -> size_t
 
auto getPopulation () const -> size_t
 
auto getTournament () const -> size_t
 
auto getMutationRate () const -> double
 
virtual auto TAG () const -> std::string
 A tag name when represented by XML. More...
 
virtual auto toXML () const -> std::shared_ptr< library::XML > override
 Get an XML object represents the Entity. More...
 
- Public Member Functions inherited from samchon::protocol::Entity
 Entity ()
 Default Constructor. More...
 
virtual void construct (std::shared_ptr< library::XML >)=0
 Construct data of the Entity from an XML object. More...
 
virtual auto key () const -> std::string
 Get a key that can identify the Entity uniquely. More...
 

Protected Attributes

size_t generation
 A number of generation of evolution. More...
 
size_t population
 A number of population in a generation. More...
 
size_t tournament
 A number of tournament in a selection. More...
 
double mutationRate
 Rate of mutate ocurrence. More...
 

Detailed Description

A structure containing parameters of genetic algorithm.

The number and rate parameters in the structure affects success of evolution of genetic algorithm.

Example Sources
See also
library::GeneticAlgorithm
library::GAPopulation
example::tsp
Author
Jeongho Nam http://samchon.org

Definition at line 25 of file GAParameters.hpp.

Constructor & Destructor Documentation

samchon::library::GAParameters::GAParameters ( )
inline

Default Constructor.

Definition at line 70 of file GAParameters.hpp.

samchon::library::GAParameters::GAParameters ( size_t  generation,
size_t  population,
size_t  tournament,
double  mutationRate 
)
inline

Construct from members.

Definition at line 78 of file GAParameters.hpp.

References generation, mutationRate, population, and tournament.

Member Function Documentation

void samchon::library::GAParameters::setGeneration ( size_t  val)
inline

Set generation.

Definition at line 101 of file GAParameters.hpp.

void samchon::library::GAParameters::setPopulation ( size_t  val)
inline

Set population.

Definition at line 109 of file GAParameters.hpp.

void samchon::library::GAParameters::setTournament ( size_t  val)
inline

Set tournament.

Definition at line 117 of file GAParameters.hpp.

void samchon::library::GAParameters::setMutationRate ( double  val)
inline

Set mutation rate.

Definition at line 125 of file GAParameters.hpp.

auto samchon::library::GAParameters::getGeneration ( ) const -> size_t
inline

Get generation.

Definition at line 136 of file GAParameters.hpp.

References generation.

auto samchon::library::GAParameters::getPopulation ( ) const -> size_t
inline

Get population.

Definition at line 144 of file GAParameters.hpp.

References population.

auto samchon::library::GAParameters::getTournament ( ) const -> size_t
inline

Get tournament.

Definition at line 152 of file GAParameters.hpp.

References tournament.

auto samchon::library::GAParameters::getMutationRate ( ) const -> double
inline

Get mutation rate.

Definition at line 160 of file GAParameters.hpp.

References mutationRate.

virtual auto samchon::library::GAParameters::TAG ( ) const -> std::string
inlinevirtual

A tag name when represented by XML.

Returns
A tag name

Implements samchon::protocol::Entity.

Definition at line 168 of file GAParameters.hpp.

virtual auto samchon::library::GAParameters::toXML ( ) const -> std::shared_ptr<library::XML>
inlineoverridevirtual

Get an XML object represents the Entity.

Returns an XML object that can represents the Entity containing member variables into properties.

A member variable (not object, but atomic value like number, string or date) is categorized as a property within the framework of entity side. Thus, when overriding a toXML() method and archiving member variables to an XML object to return, puts each variable to be a property belongs to only an XML object.

Don't archive the member variable of atomic value to XML::value causing enormouse creation of XML objects to number of member variables. An Entity must be represented by only an XML instance (tag).

Standard Usage Non-standard usage abusing value
<memberList>
     <member id='jhnam88' name='Jeongho+Nam' birthdate='1988-03-11' />
     <member id='master' name='Administartor' birthdate='2011-07-28' />
</memberList>
<member>
     <id>jhnam88</id>
     <name>Jeongho+Nam</name>
     <birthdate>1988-03-11</birthdate>
</member>
Returns
An XML object representing the Entity.

Reimplemented from samchon::protocol::Entity.

Definition at line 172 of file GAParameters.hpp.

References samchon::protocol::Entity::toXML().

Here is the call graph for this function:

Member Data Documentation

size_t samchon::library::GAParameters::generation
protected

A number of generation of evolution.

Definition at line 35 of file GAParameters.hpp.

Referenced by GAParameters(), and getGeneration().

size_t samchon::library::GAParameters::population
protected

A number of population in a generation.

Definition at line 40 of file GAParameters.hpp.

Referenced by GAParameters(), and getPopulation().

size_t samchon::library::GAParameters::tournament
protected

A number of tournament in a selection.

Definition at line 45 of file GAParameters.hpp.

Referenced by GAParameters(), and getTournament().

double samchon::library::GAParameters::mutationRate
protected

Rate of mutate ocurrence.

A mutation rate determines the percentage of occurence of mutation in a sequence list.

  • Value from 0.0 to 1.0
Note
  • When mutationRate is too high, it is hard to ancitipate studying on genetic algorithm.
  • When mutationRate is too low and initial set of genes(GeneArray) is far away from optimal, the evolution tends to wandering outside of he optimal.

Definition at line 59 of file GAParameters.hpp.

Referenced by GAParameters(), and getMutationRate().


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