Grail (C++)  1.4.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
grail::evolution::BaseEvoParam Class Reference

BaseEvoParam - A class that represents a parameter that is modifiable (optimizable) by evolutionary algorithms.
Unless your parameter is only a positional index (represented by an integer from 0 to max), use a specialized version 'EvoParam<Type>'.
These parameters form an encoding and are stored as member Fields or Properties in an 'Individual' and set as optimizable using 'Individual::SetMemberParameterOptimizable'.
Typically, the 'Individual.SetMemberParameterOptimizable' function should be called in the constructor of an 'Individual'-derived class. More...

#include <EvoParam.hh>

Inheritance diagram for grail::evolution::BaseEvoParam:

Public Member Functions

 BaseEvoParam (size_t domainLength)
 BaseEvoParam - Constructor. More...
 
void Randomize (std::mt19937_64 &rand_gen)
 Sets to a random possible value from a domain. More...
 
const BaseEvoParamSetNext ()
 Sets to the next possible value in the domain (wrapped, i.e. last.next -> first). More...
 
const BaseEvoParamSetPrev ()
 Sets to the previous possible value in the domain (wrapped, i.e. first.prev -> last). More...
 
const BaseEvoParamSetNextClamped ()
 Sets to the next possible value in the domain (clamped, i.e. last.next -> last). More...
 
const BaseEvoParamSetPrevClamped ()
 Sets to the previous possible value in the domain (clamped, i.e. first.prev -> first). More...
 
float GetNormalizedPositionWeight () const
 The normalized position, between 0.0 and 1.0, is the ratio of the current position index to the domainLength. More...
 
size_t GetPositionIndex () const
 Returns the position of the parameter. BaseEvoParam uses PositionIndex to point to an element from its domain. More...
 
void SetPositionIndex (size_t position)
 Sets the position of the parameter. Setting this index makes the parameter hold the PositionIndex-ith value from the domain. Index starts at zero. More...
 
virtual std::string ToString () const
 ToString - returns a string representation of the current value hold by the parameter.
 
size_t GetDomainLength () const
 Gets the number of distinct values BaseEvoParam may take.
 

Protected Attributes

const size_t domainLength = 1
 domainLength - the number of distinct values BaseEvoParam may take.
 

Detailed Description

BaseEvoParam - A class that represents a parameter that is modifiable (optimizable) by evolutionary algorithms.
Unless your parameter is only a positional index (represented by an integer from 0 to max), use a specialized version 'EvoParam<Type>'.
These parameters form an encoding and are stored as member Fields or Properties in an 'Individual' and set as optimizable using 'Individual::SetMemberParameterOptimizable'.
Typically, the 'Individual.SetMemberParameterOptimizable' function should be called in the constructor of an 'Individual'-derived class.

Constructor & Destructor Documentation

◆ BaseEvoParam()

grail::evolution::BaseEvoParam::BaseEvoParam ( size_t  domainLength)

BaseEvoParam - Constructor.

Parameters
domainLength- the number of distinct values this parameter may take.

Member Function Documentation

◆ GetNormalizedPositionWeight()

float grail::evolution::BaseEvoParam::GetNormalizedPositionWeight ( ) const

The normalized position, between 0.0 and 1.0, is the ratio of the current position index to the domainLength.

Returns
- the normalized position.

◆ GetPositionIndex()

size_t grail::evolution::BaseEvoParam::GetPositionIndex ( ) const

Returns the position of the parameter. BaseEvoParam uses PositionIndex to point to an element from its domain.

Returns
Index of the currently assigned element from the domain as value.

◆ Randomize()

void grail::evolution::BaseEvoParam::Randomize ( std::mt19937_64 &  rand_gen)

Sets to a random possible value from a domain.

Parameters
rand_gen- random number generator.

◆ SetNext()

const BaseEvoParam * grail::evolution::BaseEvoParam::SetNext ( )

Sets to the next possible value in the domain (wrapped, i.e. last.next -> first).

Returns
- the BaseEvoParam returns a pointer to itself.

◆ SetNextClamped()

const BaseEvoParam * grail::evolution::BaseEvoParam::SetNextClamped ( )

Sets to the next possible value in the domain (clamped, i.e. last.next -> last).

Returns
- the BaseEvoParam returns a pointer to itself.

◆ SetPositionIndex()

void grail::evolution::BaseEvoParam::SetPositionIndex ( size_t  position)

Sets the position of the parameter. Setting this index makes the parameter hold the PositionIndex-ith value from the domain. Index starts at zero.

Parameters
position- the number >= 0 and < domainLength.

◆ SetPrev()

const BaseEvoParam * grail::evolution::BaseEvoParam::SetPrev ( )

Sets to the previous possible value in the domain (wrapped, i.e. first.prev -> last).

Returns
- the BaseEvoParam returns a pointer to itself.

◆ SetPrevClamped()

const BaseEvoParam * grail::evolution::BaseEvoParam::SetPrevClamped ( )

Sets to the previous possible value in the domain (clamped, i.e. first.prev -> first).

Returns
- the BaseEvoParam returns a pointer to itself.

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