Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages | Search for

# tutorial/Lesson4/binary_value.h

    00001 #include <eo>
    00002
    00003 //-----------------------------------------------------------------------------
    00004
    00010 template <class Chrom> double binary_value(const Chrom& _chrom)
    00011 {
    00012   double sum = 0;
    00013   for (unsigned i = 0; i < _chrom.size(); i++)
    00014     if (_chrom[i])
    00015         sum += _chrom[i];
    00016   return sum;
    00017 }
    00018
    00019 struct BinaryValue
    00020 {
    00021   template <class Chrom> void operator()(Chrom& _chrom)
    00022   {
    00023     _chrom.fitness(binary_value(_chrom));
    00024   }
    00025 };