-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding ChromosomeProcessor class, that can perform operations on Chro…
…mosomes. Fixing definition of deltaNclusters.
- Loading branch information
Showing
10 changed files
with
370 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
add_library(libChromosome src/Chromosome.cpp) | ||
add_library(libChromosome src/Chromosome.cpp | ||
src/ChromosomeProcessor.cpp) | ||
|
||
set_property(TARGET libChromosome PROPERTY CXX_STANDARD 17) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// ChromosomeProcessor.hpp | ||
// | ||
// Created by Jeremi Niedziela on 13/02/2019. | ||
// | ||
|
||
#ifndef ChromosomeProcessor_hpp | ||
#define ChromosomeProcessor_hpp | ||
|
||
#include "GeneticHelpers.hpp" | ||
#include "Chromosome.hpp" | ||
|
||
class ChromosomeProcessor { | ||
public: | ||
/// Default constructor | ||
ChromosomeProcessor(double _mutationChance, | ||
double _severityFactor, | ||
ECrossover _crossover); | ||
|
||
/// Default destructor | ||
~ChromosomeProcessor(); | ||
|
||
std::shared_ptr<Chromosome> GetRandomChromosome(); | ||
|
||
void CalculateScore(std::shared_ptr<Chromosome> chromo); | ||
|
||
std::pair<std::shared_ptr<Chromosome>, std::shared_ptr<Chromosome>> | ||
CrossChromosomes(const std::shared_ptr<Chromosome> mom, | ||
const std::shared_ptr<Chromosome> dad); | ||
|
||
void StoreChromosomeInConfig(const std::shared_ptr<Chromosome> chromo, | ||
std::string path=""); | ||
|
||
private: | ||
|
||
std::pair<uint64_t,uint64_t> SinglePointCrossover(uint64_t a, uint64_t b, bool fixed=false); | ||
|
||
double mutationChance; | ||
double severityFactor; // larger the value, more easily population members will die | ||
ECrossover crossover; | ||
}; | ||
|
||
#endif /* ChromosomeProcessor_hpp */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.