#ifndef GENETIC_OPERATORS #define GENETIC_OPERATORS #include "Genetic.h" #include "Graf.h" #include using namespace std; /** * Class implementing the crossover operator */ class Crossover{ public: /** * the default constructor */ Crossover(){}; /** * Method that applies the crossover on 2 parents obtaining 2 children * * @param p1 the parent #1 * @param p2 the parent #2 * @param c1 the child #1 * @param c2 the child #2 */ void crossover(Chromosome & p1, Chromosome & p2, Chromosome & c1, Chromosome &c2); /** * Method that applies the crossover on a list of chromosomes * * @param chs the list of chromosomes */ void applyCrossover(vector &chs); }; /** * class implementing the simple mutation */ class SimpleMutation{ public: /** * the number of processors */ int nr_procs; /** * the maximum topological level */ int max_level; /** * the simple mutation probability */ double mutation_pb; public: /** * constructor * * @param p the number of processors * @param l the maximum topological level * @param prob the simple mutation probability */ SimpleMutation(int p = 0 , int l = 0, double prob = 0); /** * method applying the simple mutation on a chromosome * * @param ch the chromosome we want to mutate */ void mutateIndividual(Chromosome & ch); }; /** * class implementing the swap gene mutation */ class SwapMutation{ public: /** * the number of processors */ int nr_procs; /** * the maximum topological level */ int max_level; /** * the swap gene mutation probability */ double mutation_pb; public: /** * constructor * * @param p the number of processors * @param l the maximum topological level * @param prob the swap gene mutation probability */ SwapMutation(int p = 0 , int l = 0, double prob = 0); /** * method applying the swap gene mutation on a chromosome * * @param ch the chromosome we want to mutate */ void mutateIndividual(Chromosome & ch); }; /** * class implementing the hyper-mutation */ class HyperMutation { public: /** * the graph of tasks */ TaskGraf tasks; /** * the hyper-mutation probability */ double mutation_pb; public: /** * the default constructor */ HyperMutation(); /** * constructor * * @param t the graph of tasks * @param prob the hyper-mutation probability */ HyperMutation(TaskGraf &tgraf, double prob); /** * Method that increases the topological level of the current task, then analyzes its predecessors in order to find if there is another free floating node to be moved in the floating nodes list; finally deletes the current node. * * @param ch the current chromosome * @param task_id the current task id */ void increaseTopoLvl(Chromosome &ch , int task_id); /** * method applying the hyper-mutation on a chromosome * * @param ch the chromosome we want to mutate */ void mutateIndividual(Chromosome &ch); /** * method applying the hyper-mutation on a list of chromosomes * * @param pop the chromosomes list we want to mutate */ void mutate(vector &pop); }; #endif