Two files left over added to the repo
This commit is contained in:
parent
259420d9ce
commit
557a06ff22
2 changed files with 102 additions and 0 deletions
18
eo/test/binary_value.h
Normal file
18
eo/test/binary_value.h
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#include <eo>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef eoBin<float> Chrom;
|
||||
|
||||
/** Just a simple function that takes binary value of a chromosome and sets
|
||||
the fitnes.
|
||||
@param _chrom A binary chromosome
|
||||
*/
|
||||
void binary_value(Chrom& _chrom)
|
||||
{
|
||||
float sum = 0;
|
||||
for (unsigned i = 0; i < _chrom.size(); i++)
|
||||
if (_chrom[i])
|
||||
sum += pow(2, _chrom.size() - i - 1);
|
||||
_chrom.fitness(sum);
|
||||
}
|
||||
Reference in a new issue