11 #ifndef DIGNEA_UNIFORMCROSSOVER_H
12 #define DIGNEA_UNIFORMCROSSOVER_H
14 #include <dignea/core/Crossover.h>
15 #include <dignea/utilities/random/PseudoRandom.h>
31 void run(S &firstInd, S &secondInd)
override;
33 std::string getName()
const override {
return "Uniform One Crossover"; };
46 vector secondIndVars = secondInd.getVariables();
47 vector firstIndVars = firstInd.getVariables();
49 for (
int i = 0; i < firstInd.getNumberOfVars(); i++) {
51 auto tmpVariable = secondIndVars[i];
52 auto copyVar = firstIndVars[i];
53 secondIndVars[i] = copyVar;
54 firstIndVars[i] = tmpVariable;
57 firstInd.setVariables(firstIndVars);
58 secondInd.setVariables(secondIndVars);
Abstract Crossover interface.
Definition: Crossover.h:19
static double randDouble()
Generates a random double value between 0.0 and 1.0.
Definition: PseudoRandom.cpp:31