using namespace std;
namespace genetic {
+ /**
+ * Chromosome of given Genes.
+ */
template < typename _Gene >
class Chromosome {
public:
typedef _Gene GeneType;
protected:
+ /**
+ * Genes of the chromosome
+ */
vector<_Gene> genes;
public:
+ /**
+ * Default constructor
+ */
Chromosome() {}
Chromosome(vector<_Gene> genes) {
};
}
-#endif /* __CHROMOSOME_H */
\ No newline at end of file
+#endif /* __CHROMOSOME_H */
namespace genetic {
+ /**
+ * Gene.
+ */
template < typename Type >
class Gene {
protected:
};
}
-#endif /* __GENE_H */
\ No newline at end of file
+#endif /* __GENE_H */
using namespace std;
namespace genetic {
+ /**
+ * Generation of given Chromosomes.
+ */
template < typename _Chromosome >
class Generation {
protected:
#define __GENERATOR_GENERATION_H
#include <vector>
+#include <cstdlib>
#include "../gene.h"
#include "../chromosome.h"
public:
/**
- * Constructor.
+ * Constructor. Initializes required variables and constans
*
* @param generationSize Indicates size of the generation
* @param generationSize Indicates size of the chromosome
Generation(unsigned int generationSize, unsigned int chromosomeSize) {
this->generationSize = generationSize;
this->chromosomeSize = chromosomeSize;
+
+ time_t t;
+ srand((unsigned)time(&t));
}
/**
#include <iostream>
#include <vector>
-#include <cstdlib>
-
#include "gene.h"
#include "chromosome.h"
#include "generation.h"
const int chromosomeSize = 11;
const int generationSize = 20;
- time_t t;
- srand((unsigned)time(&t));
-
generator::Generation<_Chromosome> generationGenerator(generationSize, chromosomeSize);
Generation<_Chromosome> generation = generationGenerator.breed();