dlugolecki.net.pl
Dziennik
Polecane
Software
projects
/
genetic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0c268e9
)
Remove some not used namespace declarations.
author
Rafał Długołęcki
<rafal@dlugolecki.net.pl>
Fri, 1 May 2015 07:54:23 +0000
(09:54 +0200)
committer
Rafał Długołęcki
<rafal@dlugolecki.net.pl>
Fri, 1 May 2015 07:54:23 +0000
(09:54 +0200)
12 files changed:
include/chromosome.h
patch
|
blob
|
history
include/condition/condition.h
patch
|
blob
|
history
include/condition/generationLimitCondition.h
patch
|
blob
|
history
include/crossover/crossover.h
patch
|
blob
|
history
include/generation.h
patch
|
blob
|
history
include/generator/bitGenerator.h
patch
|
blob
|
history
include/generator/generator.h
patch
|
blob
|
history
include/mutation/mutation.h
patch
|
blob
|
history
include/selection/linearRankSelection.h
patch
|
blob
|
history
include/selection/rouletteSelection.h
patch
|
blob
|
history
include/selection/selection.h
patch
|
blob
|
history
src/main.cpp
patch
|
blob
|
history
diff --git
a/include/chromosome.h
b/include/chromosome.h
index 378300aa5621f138992d2d06e50b71ce096eb86f..bad2bdd410efb1805e72b6a4b3715a4888cf7750 100644
(file)
--- a/
include/chromosome.h
+++ b/
include/chromosome.h
@@
-5,8
+5,6
@@
#include "gene.h"
#include "gene.h"
-using namespace std;
-
namespace genetic {
/**
* Chromosome of given Genes.
namespace genetic {
/**
* Chromosome of given Genes.
diff --git
a/include/condition/condition.h
b/include/condition/condition.h
index 2b175751fb66d15510ae3380d36d28b7c0a8102c..29ac133194254e03896dde7bf2d41e2e18de93f0 100644
(file)
--- a/
include/condition/condition.h
+++ b/
include/condition/condition.h
@@
-4,8
+4,6
@@
#include "chromosome.h"
#include "generation.h"
#include "chromosome.h"
#include "generation.h"
-using namespace std;
-
namespace genetic {
/**
* Base Condition class.
namespace genetic {
/**
* Base Condition class.
diff --git
a/include/condition/generationLimitCondition.h
b/include/condition/generationLimitCondition.h
index e120a9655a99bbf1f3b04409677c44a733ac2c6a..3101191d8d31ad5f1804d02a529612db082d552a 100644
(file)
--- a/
include/condition/generationLimitCondition.h
+++ b/
include/condition/generationLimitCondition.h
@@
-6,8
+6,6
@@
#include "condition.h"
#include "condition.h"
-using namespace std;
-
namespace genetic {
/**
* Condition class. It is used for checking if algorithm should stop after
namespace genetic {
/**
* Condition class. It is used for checking if algorithm should stop after
@@
-15,7
+13,6
@@
namespace genetic {
*/
template < typename _Chromosome>
class GenerationLimitCondition : public Condition<_Chromosome> {
*/
template < typename _Chromosome>
class GenerationLimitCondition : public Condition<_Chromosome> {
- public:
protected:
/**
* Variable indicating current generation
protected:
/**
* Variable indicating current generation
diff --git
a/include/crossover/crossover.h
b/include/crossover/crossover.h
index 395ac60636c21fc788a969736babcb6d4f70228b..3befaed60c50698b904ba945afe18230f3aabf2b 100644
(file)
--- a/
include/crossover/crossover.h
+++ b/
include/crossover/crossover.h
@@
-1,6
+1,8
@@
#ifndef __CROSSOVER_CROSSOVER_H
#define __CROSSOVER_CROSSOVER_H
#ifndef __CROSSOVER_CROSSOVER_H
#define __CROSSOVER_CROSSOVER_H
+#include <vector>
+
#include "chromosome.h"
#include "generation.h"
#include "chromosome.h"
#include "generation.h"
@@
-55,7
+57,7
@@
namespace genetic {
// }
// }
// }
// }
- vector<GeneType> crossedChromosome;
+
std::
vector<GeneType> crossedChromosome;
for (unsigned int i = 0; i < chromosomeSize; i++) {
if (i < splitPlace) {
crossedChromosome.push_back(first[i].get());
for (unsigned int i = 0; i < chromosomeSize; i++) {
if (i < splitPlace) {
crossedChromosome.push_back(first[i].get());
diff --git
a/include/generation.h
b/include/generation.h
index f460a7fbe62cc408a6034b8ad42bf84420d9f78d..5dab37c2d5ae070fe210e20e4a8d0896e45339a2 100644
(file)
--- a/
include/generation.h
+++ b/
include/generation.h
@@
-3,10
+3,8
@@
#include <vector>
#include <vector>
-#include <gene.h>
-#include <chromosome.h>
-
-using namespace std;
+#include "gene.h"
+#include "chromosome.h"
namespace genetic {
/**
namespace genetic {
/**
@@
-18,7
+16,7
@@
namespace genetic {
/**
* Chromosomes in the given Generation
*/
/**
* Chromosomes in the given Generation
*/
- vector<_Chromosome> chromosomes;
+
std::
vector<_Chromosome> chromosomes;
template<typename> friend class Generation;
public:
template<typename> friend class Generation;
public:
diff --git
a/include/generator/bitGenerator.h
b/include/generator/bitGenerator.h
index 8e92521a608e7c553f1689600dd0d622f1828232..3b93420248386d3f5a85d5f9db2a0af895c4a100 100644
(file)
--- a/
include/generator/bitGenerator.h
+++ b/
include/generator/bitGenerator.h
@@
-52,7
+52,7
@@
namespace genetic {
* @param generationSize Indicates size of the generation
* @param chromosomeSize Indicates size of the chromosome
*/
* @param generationSize Indicates size of the generation
* @param chromosomeSize Indicates size of the chromosome
*/
- BitGenerator(
unsigned int generationSize,
unsigned int chromosomeSize)
+ BitGenerator(
const unsigned int generationSize, const
unsigned int chromosomeSize)
: Generator<_Chromosome>(generationSize, chromosomeSize) {
}
};
: Generator<_Chromosome>(generationSize, chromosomeSize) {
}
};
diff --git
a/include/generator/generator.h
b/include/generator/generator.h
index 64f2720820530fadb84d1b1fabc94deb76598864..b9e5680757a648f7d4d87c2585b55aef0c55e89c 100644
(file)
--- a/
include/generator/generator.h
+++ b/
include/generator/generator.h
@@
-1,6
+1,7
@@
#ifndef __GENERATOR_GENERATOR_H
#define __GENERATOR_GENERATOR_H
#ifndef __GENERATOR_GENERATOR_H
#define __GENERATOR_GENERATOR_H
+#include <ctime>
#include <cstdlib>
#include "../gene.h"
#include <cstdlib>
#include "../gene.h"
@@
-25,12
+26,12
@@
namespace genetic {
/**
* Size of the generation to generate
*/
/**
* Size of the generation to generate
*/
- unsigned int generationSize;
+
const
unsigned int generationSize;
/**
* Size of the chromosome to generate
*/
/**
* Size of the chromosome to generate
*/
- unsigned int chromosomeSize;
+
const
unsigned int chromosomeSize;
/**
* Breeding calculations should be done here...
/**
* Breeding calculations should be done here...
@@
-46,9
+47,8
@@
namespace genetic {
* @param generationSize Indicates size of the generation
* @param chromosomeSize Indicates size of the chromosome
*/
* @param generationSize Indicates size of the generation
* @param chromosomeSize Indicates size of the chromosome
*/
- Generator(unsigned int generationSize, unsigned int chromosomeSize) {
- this->generationSize = generationSize;
- this->chromosomeSize = chromosomeSize;
+ Generator(const unsigned int generationSize, const unsigned int chromosomeSize)
+ : generationSize(generationSize), chromosomeSize(chromosomeSize) {
time_t t;
srand((unsigned)time(&t));
time_t t;
srand((unsigned)time(&t));
diff --git
a/include/mutation/mutation.h
b/include/mutation/mutation.h
index 49b6094649c9bc09b15003df1f89593846746d51..6c2b853b0855e72f89c75c6922e84a6835d96f7e 100644
(file)
--- a/
include/mutation/mutation.h
+++ b/
include/mutation/mutation.h
@@
-1,13
+1,11
@@
#ifndef __MUTATION_MUTATION_H
#define __MUTATION_MUTATION_H
#ifndef __MUTATION_MUTATION_H
#define __MUTATION_MUTATION_H
-#include <
iostream
>
+#include <
vector
>
#include "chromosome.h"
#include "generation.h"
#include "chromosome.h"
#include "generation.h"
-using namespace std;
-
namespace genetic {
// namespace mutation {
/**
namespace genetic {
// namespace mutation {
/**
@@
-51,7
+49,7
@@
namespace genetic {
Generation<_Chromosome> mutate(Generation<_Chromosome>& _generation) {
const unsigned int generationSize = _generation.size();
const unsigned int chromosomeSize = _generation[0].size();
Generation<_Chromosome> mutate(Generation<_Chromosome>& _generation) {
const unsigned int generationSize = _generation.size();
const unsigned int chromosomeSize = _generation[0].size();
- vector<_Chromosome> newGeneration;
+
std::
vector<_Chromosome> newGeneration;
for (unsigned int i = 0; i < generationSize; i++) {
MutationChanceType random = (rand() % 10000) / 10000.0;
for (unsigned int i = 0; i < generationSize; i++) {
MutationChanceType random = (rand() % 10000) / 10000.0;
diff --git
a/include/selection/linearRankSelection.h
b/include/selection/linearRankSelection.h
index ee119d60543490f41bd932f94ba9e2c255c46e45..16a3cf82a469340077cfdabb62e6d33f51200d69 100644
(file)
--- a/
include/selection/linearRankSelection.h
+++ b/
include/selection/linearRankSelection.h
@@
-8,8
+8,6
@@
#include "fitness/fitness.h"
#include "selection/selection.h"
#include "fitness/fitness.h"
#include "selection/selection.h"
-using namespace std;
-
namespace genetic {
// namespace selection {
/**
namespace genetic {
// namespace selection {
/**
diff --git
a/include/selection/rouletteSelection.h
b/include/selection/rouletteSelection.h
index afb3ac7f74828a4c0dfe8c1e28ef6b29aac354e3..bd4e67ca3bfd6ccf191a52933e29e7f59dbde58c 100644
(file)
--- a/
include/selection/rouletteSelection.h
+++ b/
include/selection/rouletteSelection.h
@@
-8,8
+8,6
@@
#include "chromosome.h"
#include "selection.h"
#include "chromosome.h"
#include "selection.h"
-using namespace std;
-
namespace genetic {
// namespace selection {
/**
namespace genetic {
// namespace selection {
/**
diff --git
a/include/selection/selection.h
b/include/selection/selection.h
index 187db12802fc22ee152e211a96e27ad2d33e2362..de899c11d24b1b840ebe6c0a31e2831e2cfaa0c3 100644
(file)
--- a/
include/selection/selection.h
+++ b/
include/selection/selection.h
@@
-5,8
+5,6
@@
#include "generation.h"
#include "../fitness/fitness.h"
#include "generation.h"
#include "../fitness/fitness.h"
-using namespace std;
-
namespace genetic {
// namespace selection {
/**
namespace genetic {
// namespace selection {
/**
diff --git
a/src/main.cpp
b/src/main.cpp
index ccaa43e3c497a281316f3f3011a262b590d678ee..a208bbf863505071fd5af846174d223d045840c2 100644
(file)
--- a/
src/main.cpp
+++ b/
src/main.cpp
@@
-1,8
+1,3
@@
-#include <iostream>
-#include <vector>
-#include <map>
-#include <string>
-
#include "gene.h"
#include "chromosome.h"
#include "generation.h"
#include "gene.h"
#include "chromosome.h"
#include "generation.h"
@@
-18,7
+13,6
@@
#include "condition/condition.h"
#include "condition/generationLimitCondition.h"
#include "condition/condition.h"
#include "condition/generationLimitCondition.h"
-using namespace std;
using namespace genetic;
int main() {
using namespace genetic;
int main() {