GrayTranscribe.cpp
Go to the documentation of this file.00001 #include "GrayTranscribe.h"
00002 #include <cmath>
00003
00004 namespace gplib
00005 {
00006 GrayTranscribe::GrayTranscribe(const ttranscribed &base,
00007 const ttranscribed &step, const tsizev &gene) :
00008 BinaryTranscribe(base, step, gene)
00009 {
00010 }
00011
00012 GrayTranscribe::~GrayTranscribe()
00013 {
00014 }
00015
00016 ttranscribed GrayTranscribe::GetValues(const tpopmember &member)
00017 {
00018 unsigned int currentindex = 0;
00019 unsigned int currentmaxindex = 0;
00020 double currentvalue;
00021 double exponent;
00022
00023 ttranscribed ReturnValues(genesizes.size());
00024
00025 for (unsigned int i = 0; i < genesizes.size(); ++i)
00026 {
00027 currentvalue = 0;
00028
00029 currentmaxindex = currentindex + genesizes(i);
00030 for (unsigned int j = currentindex; j < currentmaxindex; ++j)
00031 {
00032 exponent = 0.0;
00033 for (unsigned int k = j; k < currentmaxindex; ++k)
00034 {
00035 exponent += member(k);
00036 }
00037 currentvalue += -1.0 * member(j) * std::pow(-1.0, exponent) * (std::pow(
00038 2, j - currentindex + 1) - 1.0);
00039 }
00040 currentvalue *= stepsizes(i);
00041 currentvalue += basevalues(i);
00042 currentindex += genesizes(i);
00043 ReturnValues(i) = currentvalue;
00044 }
00045 return (ReturnValues);
00046 }
00047 }