00001 #ifndef BINARY_H_
00002 #define BINARY_H_
00003
00004 #include "BinaryCrsOnePoint.h"
00005 #include "BinaryCrsTwoPoint.h"
00006 #include "BinaryMutSimple.h"
00007 #include "BinaryMutMix.h"
00008 #include "BinaryCrsUniform.h"
00009 #include "BinaryCrsHalfUniform.h"
00010 #include "BinaryCrsReducedSurrogate.h"
00011 #include "BinaryCrsSegmented.h"
00012 #include "BinaryCrsShuffle.h"
00013 #include "../Genotype.h"
00014
00015 namespace Binary
00016 {
00017
00034 class Binary: public Genotype {
00035 friend class BinaryMutSimple;
00036 protected:
00037 double minValue_;
00038 double maxValue_;
00039 uint nDecimal_;
00040 uint nDimension_;
00041 uint nBits_;
00042 long potention_;
00043 bool bRounding_;
00044 typedef std::vector<bool> v_bool;
00045 v_bool vBool_;
00046
00047 double logbase(double a, double base);
00048 double round(double, int);
00049
00050 public:
00051 std::vector<long int> decValue;
00052 std::vector<double> realValue;
00053 std::vector<v_bool> variables;
00054
00055 Binary ()
00056 { name_ = "Binary"; }
00057
00059 uint getNumBits()
00060 { return nBits_; }
00061
00062 bool initialize (StateP state);
00063
00064 void registerParameters(StateP state);
00065
00067 bool update (void);
00068
00069 Binary* copy()
00070 {
00071 Binary *newObject = new Binary(*this);
00072 return newObject;
00073 }
00074
00075 std::vector<CrossoverOpP> getCrossoverOp()
00076 {
00077 std::vector<CrossoverOpP> crx;
00078 crx.push_back(static_cast<CrossoverOpP> (new BinaryCrsOnePoint));
00079 crx.push_back(static_cast<CrossoverOpP> (new BinaryCrsTwoPoint));
00080 crx.push_back(static_cast<CrossoverOpP> (new BinaryCrsUniform));
00081 crx.push_back(static_cast<CrossoverOpP> (new BinaryCrsHalfUniform));
00082 crx.push_back(static_cast<CrossoverOpP> (new BinaryCrsReducedSurrogate));
00083 crx.push_back(static_cast<CrossoverOpP> (new BinaryCrsSegmented));
00084 crx.push_back(static_cast<CrossoverOpP> (new BinaryCrsShuffle));
00085 return crx;
00086 }
00087
00088 std::vector<MutationOpP> getMutationOp()
00089 {
00090 std::vector<MutationOpP> mut;
00091 mut.push_back(static_cast<MutationOpP> (new BinaryMutSimple));
00092 mut.push_back(static_cast<MutationOpP> (new BinaryMutMix));
00093 return mut;
00094 }
00095
00096 void write(XMLNode& xBinary);
00097
00098 void read(XMLNode& xBinary);
00099 };
00100
00101 }
00102 typedef boost::shared_ptr<Binary::Binary> BinaryP;
00103 #endif