11 #ifndef DIGNEA_SCRAMBLEMUTATION_H
12 #define DIGNEA_SCRAMBLEMUTATION_H
14 #include <dignea/core/Mutation.h>
15 #include <dignea/utilities/random/PseudoRandom.h>
32 void run(S &ind,
const double &probability,
Problem<S> *)
override;
34 std::string getName()
const override {
return "Scramble Mutation"; };
53 while ((start == end)) {
60 std::random_device rd;
61 std::default_random_engine gen(rd());
62 vector vars = ind.getVariables();
63 std::shuffle(vars.begin() + start, vars.begin() + end, gen);
64 ind.setVariables(vars);
65 }
catch (OutOfRange
const &err) {
67 std::string(err.what()) +
68 " from Scramble operator with start: " + to_string(start).c_str() +
69 " and end: " + to_string(end).c_str() +
70 " with ind.vars().size() = " + to_string(ind.getNumberOfVars());
71 throw OutOfRange(msg);
Abstract Mutation interface.
Definition: Mutation.h:21
Class to represent a Problem in the tool. It includes the basic information for a problem a few metho...
Definition: Problem.h:29
static int randInt(int minBound, int maxBound)
Returns a random integer int the range [minBound, maxBound].
Definition: PseudoRandom.cpp:38
Scramble Mutation Operator for Permutation Based Problems like TSP. Fixes the first and last genes to...
Definition: ScrambleMutation.h:26
void run(S &ind, const double &probability, Problem< S > *) override
Performs Scramble Mutation Operation.
Definition: ScrambleMutation.h:49