00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef MOEOBITVECTOR_H_
00014 #define MOEOBITVECTOR_H_
00015
00016 #include <core/moeoVector.h>
00017
00021 template < class MOEOObjectiveVector, class MOEOFitness, class MOEODiversity >
00022 class moeoBitVector : public moeoVector < MOEOObjectiveVector, MOEOFitness, MOEODiversity, bool >
00023 {
00024 public:
00025
00026 using moeoVector < MOEOObjectiveVector, MOEOFitness, MOEODiversity, bool > :: begin;
00027 using moeoVector < MOEOObjectiveVector, MOEOFitness, MOEODiversity, bool > :: end;
00028 using moeoVector < MOEOObjectiveVector, MOEOFitness, MOEODiversity, bool > :: resize;
00029 using moeoVector < MOEOObjectiveVector, MOEOFitness, MOEODiversity, bool > :: size;
00030
00031
00037 moeoBitVector(unsigned int _size = 0, bool _value = false) : moeoVector< MOEOObjectiveVector, MOEOFitness, MOEODiversity, bool >(_size, _value)
00038 {}
00039
00040
00045 virtual void printOn(std::ostream & _os) const
00046 {
00047 MOEO < MOEOObjectiveVector, MOEOFitness, MOEODiversity >::printOn(_os);
00048 _os << ' ';
00049 _os << size() << ' ';
00050 std::copy(begin(), end(), std::ostream_iterator<bool>(_os));
00051 }
00052
00053
00058 virtual void readFrom(std::istream & _is)
00059 {
00060 MOEO < MOEOObjectiveVector, MOEOFitness, MOEODiversity >::readFrom(_is);
00061 unsigned int s;
00062 _is >> s;
00063 std::string bits;
00064 _is >> bits;
00065 if (_is)
00066 {
00067 resize(bits.size());
00068 std::transform(bits.begin(), bits.end(), begin(), std::bind2nd(std::equal_to<char>(), '1'));
00069 }
00070 }
00071
00072 };
00073
00074 #endif