00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef MOEOBITVECTOR_H_
00039 #define MOEOBITVECTOR_H_
00040
00041 #include <core/moeoVector.h>
00042
00046 template < class MOEOObjectiveVector, class MOEOFitness, class MOEODiversity >
00047 class moeoBitVector : public moeoVector < MOEOObjectiveVector, MOEOFitness, MOEODiversity, bool >
00048 {
00049 public:
00050
00051 using moeoVector < MOEOObjectiveVector, MOEOFitness, MOEODiversity, bool > :: begin;
00052 using moeoVector < MOEOObjectiveVector, MOEOFitness, MOEODiversity, bool > :: end;
00053 using moeoVector < MOEOObjectiveVector, MOEOFitness, MOEODiversity, bool > :: resize;
00054 using moeoVector < MOEOObjectiveVector, MOEOFitness, MOEODiversity, bool > :: size;
00055
00056
00062 moeoBitVector(unsigned int _size = 0, bool _value = false) : moeoVector< MOEOObjectiveVector, MOEOFitness, MOEODiversity, bool >(_size, _value)
00063 {}
00064
00065
00069 virtual std::string className() const
00070 {
00071 return "moeoBitVector";
00072 }
00073
00074
00079 virtual void printOn(std::ostream & _os) const
00080 {
00081 MOEO < MOEOObjectiveVector, MOEOFitness, MOEODiversity >::printOn(_os);
00082 _os << ' ';
00083 _os << size() << ' ';
00084 std::copy(begin(), end(), std::ostream_iterator<bool>(_os));
00085 }
00086
00087
00092 virtual void readFrom(std::istream & _is)
00093 {
00094 MOEO < MOEOObjectiveVector, MOEOFitness, MOEODiversity >::readFrom(_is);
00095 unsigned int s;
00096 _is >> s;
00097 std::string bits;
00098 _is >> bits;
00099 if (_is)
00100 {
00101 resize(bits.size());
00102 std::transform(bits.begin(), bits.end(), begin(), std::bind2nd(std::equal_to<char>(), '1'));
00103 }
00104 }
00105
00106 };
00107
00108 #endif