shark::BitflipMutator Struct Reference

Bitflip mutation operator. More...

#include <shark/Algorithms/DirectSearch/Operators/Mutation/BitflipMutator.h>

Public Member Functions

 BitflipMutator ()
 Default c'tor. More...
 
template<typename Function >
void init (const Function &f)
 Initializes the operator for the supplied fitness function. More...
 
template<typename Rng , typename IndividualType >
void operator() (Rng &rng, IndividualType &ind)
 Mutates the supplied individual. More...
 
template<typename Archive >
void serialize (Archive &archive, const unsigned int version)
 Serializes this instance to the supplied archive. More...
 

Public Attributes

double m_mutationStrength
 

Detailed Description

Bitflip mutation operator.

Given a binary vector, a coin is flipped for every element. If it is heads, the element of the vector is flipped. By initializing the mutator with the objective function, this strength is set to a dfault value of 1/dimensions, thus in the mean one element is flipped.

Definition at line 44 of file BitflipMutator.h.

Constructor & Destructor Documentation

◆ BitflipMutator()

shark::BitflipMutator::BitflipMutator ( )
inline

Default c'tor.

Definition at line 47 of file BitflipMutator.h.

Member Function Documentation

◆ init()

template<typename Function >
void shark::BitflipMutator::init ( const Function &  f)
inline

Initializes the operator for the supplied fitness function.

Parameters
[in]fInstance of the objective function to initialize the operator for.

Definition at line 53 of file BitflipMutator.h.

References m_mutationStrength.

◆ operator()()

template<typename Rng , typename IndividualType >
void shark::BitflipMutator::operator() ( Rng &  rng,
IndividualType ind 
)
inline

Mutates the supplied individual.

Parameters
[in,out]indIndividual to be mutated.

Definition at line 61 of file BitflipMutator.h.

References shark::random::coinToss(), m_mutationStrength, and shark::Individual< PointType, FitnessTypeT, Chromosome >::searchPoint().

◆ serialize()

template<typename Archive >
void shark::BitflipMutator::serialize ( Archive &  archive,
const unsigned int  version 
)
inline

Serializes this instance to the supplied archive.

Parameters
[in,out]archiveThe archive to serialize to.
[in]versionVersion information (optional and not used here).

Definition at line 75 of file BitflipMutator.h.

References m_mutationStrength.

Member Data Documentation

◆ m_mutationStrength

double shark::BitflipMutator::m_mutationStrength

Definition at line 79 of file BitflipMutator.h.

Referenced by init(), operator()(), and serialize().


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