30#ifndef GENETICALGORITHM_H
31#define GENETICALGORITHM_H
34#include "MemoryManager.h"
39 vector<double> vWeights;
42 Genome() { dFitness = 0; }
43 Genome(vector<double> w,
double f) { vWeights = w; dFitness = f; }
46 friend bool operator<(
const Genome& lhs,
const Genome& rhs)
48 return(lhs.dFitness < rhs.dFitness);
53class GeneticAlgorithm :
public CMemPME
57 GeneticAlgorithm(Sint32,
double,
double,
double, Sint32, Sint32, Sint32);
60 void init(Sint32, vector<double>);
63 vector<Genome> epoch(vector<Genome>&);
66 vector<Genome> getChromos()
const;
67 double fitnessAverage()
const;
68 double fitnessBest()
const;
69 Sint32 getMutation()
const;
70 Sint32 getCrossOver()
const;
74 vector<Genome> vPopulation;
86 double dFitnessAverage;
90 Sint32 iFittestGenome;
94 double dCrossoverRate;
95 double dMaxPerturbation;
96 Sint32 iNumElite, iNumCopiesElite;
100 Sint32 iNumCrossOver;
103 void crossover(
const vector<double>&,
const vector<double>&, vector<double>&, vector<double>&);
104 void mutate(vector<double>&);
105 Genome getChromoRoulette();
106 void grabNBest(Sint32,
const Sint32, vector<Genome>&);
107 void calculateStats();