Skip to content

Commit

Permalink
Changed header. Added a bit on crossover.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Tsiogkas committed Apr 3, 2016
1 parent b79209c commit 4bf4f51
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions include/ctop_ga.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#include <chrono>
#include <thread>
#include <future>
#include <include/ga_types.h>
#include "ga_types.h"
#include "ga_utils.h"


class Gene {
Expand Down Expand Up @@ -74,6 +75,4 @@ Chromosome ga_cop(Matrix<double> &cost_mat,
uint idx_start,
uint idx_finish);

std::vector<size_t> get_population_sample(size_t pop_size, int samples);

#endif //LWGA_CTOP_GA_H
10 changes: 5 additions & 5 deletions src/ctop_ga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ std::pair<Chromosome, Chromosome> cx(Chromosome &c1,
*/
std::sort(c1.genes.begin(), c1.genes.end(), [](Gene &g1, Gene &g2){ return g1.fitness > g2.fitness; });
std::sort(c2.genes.begin(), c2.genes.end(), [](Gene &g1, Gene &g2){ return g1.fitness > g2.fitness; });
Gene g1_best = c1.fitness
//Gene g1_best = c1.genes.front();
c1.genes.back() = c2.genes.front();
c2.genes.back() = c1.genes.front();
std::sort(c1.genes.begin(), c1.genes.end(), [](Gene &g1, Gene &g2){ return g1.fitness > g2.fitness; });
std::sort(c2.genes.begin(), c2.genes.end(), [](Gene &g1, Gene &g2){ return g1.fitness > g2.fitness; });
}

Chromosome mutate(Chromosome &c,
Expand Down Expand Up @@ -131,7 +135,3 @@ Chromosome ga_cop(Matrix<double> &cost_mat,
uint idx_finish){

}

std::vector<size_t> get_population_sample(size_t pop_size, int samples){

}

0 comments on commit 4bf4f51

Please sign in to comment.