First commit - Seems to pass "all 1's" evolution test
This commit is contained in:
71
Chromosome.h
Normal file
71
Chromosome.h
Normal file
@ -0,0 +1,71 @@
|
||||
|
||||
|
||||
//
|
||||
#pragma once
|
||||
|
||||
|
||||
//
|
||||
#include "BitEvolver/Includes.h"
|
||||
|
||||
|
||||
//
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
|
||||
//
|
||||
namespace BitEvolver
|
||||
{
|
||||
//
|
||||
class Chromosome
|
||||
{
|
||||
//
|
||||
public:
|
||||
|
||||
//
|
||||
Chromosome(std::shared_ptr<class Random> _random, int _bits);
|
||||
|
||||
//
|
||||
void Reset();
|
||||
void Randomize();
|
||||
|
||||
//
|
||||
void SetBitCount(int count);
|
||||
int GetBitCount();
|
||||
|
||||
//
|
||||
void FlipBit(int index);
|
||||
|
||||
//
|
||||
bool GetBit(int index);
|
||||
void SetBit(int index, bool b);
|
||||
|
||||
//
|
||||
void ResetFitness();
|
||||
void SetFitness(double d);
|
||||
void AdjustFitness(double d);
|
||||
double GetFitness();
|
||||
|
||||
//
|
||||
std::string ToString();
|
||||
|
||||
//
|
||||
const Chromosome& operator=(const Chromosome& other);
|
||||
|
||||
//
|
||||
private:
|
||||
|
||||
// Random number generator
|
||||
std::shared_ptr<class Random> random;
|
||||
|
||||
//
|
||||
std::vector<bool> bits;
|
||||
int bits_count_desired;
|
||||
|
||||
// Fitness
|
||||
double fitness;
|
||||
};
|
||||
};
|
||||
|
Reference in New Issue
Block a user