|
OptiPy
|
Abstract base class for Differential Evolution crossover strategies. More...
#include <Crossover.h>
Public Member Functions | |
| virtual | ~Crossover ()=default |
| Virtual destructor for safe polymorphic deletion. | |
| virtual void | crossover (std::vector< double > &target, const std::vector< double > &mutant, double cr, MersenneTwister &mt)=0 |
| Performs crossover between target and mutant vectors. | |
Abstract base class for Differential Evolution crossover strategies.
Crossover defines the interface for all DE crossover operators. Each concrete crossover strategy (BinCrossover, ExpCrossover) implements the crossover() method to recombine a target vector and mutant vector, creating a trial vector for evaluation.
Crossover Role in DE:
In Differential Evolution, crossover blends the target and mutant vectors:
Purpose of Crossover:
Crossover Rate (CR) Semantics:
CR is a probability in range [0, 1]:
The pair (F, CR) controls search behavior:
Strategy Comparison:
Two main strategies:
|
pure virtual |
Performs crossover between target and mutant vectors.
Pure virtual method that each concrete crossover strategy implements to recombine a target vector and mutant vector. The target vector is modified in-place to become a trial vector.
Algorithm Pattern:
All crossover strategies follow this general workflow:
In-Place Modification:
The target vector is modified directly, replacing its contents with the trial vector. This is efficient (no copy) and standard in DE.
Guarantees:
Parameters:
| [in,out] | target | The target (parent) vector from current population. Modified in-place to become the trial vector. Size: equals mutant.size() and problem dimension. |
| [in] | mutant | The mutant vector produced by mutation strategy. Used as source for inherited parameters. Size: equals target.size(). |
| [in] | cr | Crossover rate (probability of inheritance). Range: [0, 1].
|
| [in,out] | mt | Mersenne Twister random number generator. Passed by reference; state is modified during execution. Used to randomly select parameters to inherit. |
Strategy-Specific Behavior:
Different concrete strategies implement different inheritance patterns:
Postconditions:
After crossover completes:
Usage in DE:
Complexity:
Time: O(dimension) - must examine each parameter Space: O(1) - modifies target in-place
Implemented in BinCrossover, and ExpCrossover.