OptiPy
Loading...
Searching...
No Matches
Best2 Class Reference
Inheritance diagram for Best2:
Mutation

Public Member Functions

std::vector< double > mutate (const std::vector< std::vector< double > > &population, size_t targetIndex, double F, const std::vector< double > &bestVector, MersenneTwister &mt, double lowerBound, double upperBound) override
 Generates a mutant vector using DE/best/2 strategy.
Public Member Functions inherited from Mutation
virtual ~Mutation ()=default
 Virtual destructor for safe polymorphic deletion.

Additional Inherited Members

Protected Member Functions inherited from Mutation
std::vector< size_t > getSubset (size_t populationSize, size_t subsetSize, size_t source, MersenneTwister &mt)
 Selects a random subset of population indices, excluding a source index.

Member Function Documentation

◆ mutate()

std::vector< double > Best2::mutate ( const std::vector< std::vector< double > > & population,
size_t targetIndex,
double F,
const std::vector< double > & bestVector,
MersenneTwister & mt,
double lowerBound,
double upperBound )
inlineoverridevirtual

Generates a mutant vector using DE/best/2 strategy.

Applies the formula: mutant = best + F * (r1 - r2) + F * (r3 - r4) where r1, r2, r3, r4 are four randomly selected distinct individuals.

Parameters
[in]populationCurrent population of solutions
[in]targetIndexIndex of the target individual (excluded from selection)
[in]FDifferential weight; typical range 0.5-1.0
[in]bestVectorThe best solution found so far (used as base)
[in,out]mtRandom number generator for selection
[in]lowerBoundLower domain bound
[in]upperBoundUpper domain bound
Returns
Mutant vector with all values clamped to [lowerBound, upperBound]

Implements Mutation.


The documentation for this class was generated from the following file:
  • src/opti_py/cpp/include/opti_py/Optimizer/DifferentialEvolution/Mutation/Best2.h