fixing bugs in replacers and moving some code between files

This commit is contained in:
gustavo 1999-09-21 18:14:39 +00:00
commit bc9638f53c
7 changed files with 89 additions and 103 deletions

View file

@ -58,6 +58,7 @@ main()
breeder(pop);
// reevaluation of fitness
for_each(pop.begin(), pop.end(), binary_value);
cout << "new population:" << endl;

View file

@ -3,6 +3,8 @@
// (c) GeNeura Team 1998
//-----------------------------------------------------------------------------
#include <time.h> // time
#include <stdlib.h> // srand, rand
#include <iostream> // cout
#include <eo> // eoFitness
@ -11,6 +13,9 @@
class eoFloat: public eoFitness
{
public:
eoFloat(const float x) { fitness = x; }
eoFloat(const int x) { fitness = static_cast<float>(x); }
bool operator<(const eoFitness& other) const
{
const eoFloat& x = (const eoFloat&) other;
@ -40,8 +45,13 @@ private:
main()
{
eoFloat a, b;
srand(time(0));
eoFloat a = static_cast<float>(rand()) / RAND_MAX,
b = static_cast<float>(rand()) / RAND_MAX;
cout.precision(2);
unsigned repeat = 2;
while (repeat--)
{
@ -62,7 +72,7 @@ main()
if (a == b)
cout << a << " == " << b << " is true" << endl;
else
cout << a << " == " << b << " is false" <<endl;
cout << a << " == " << b << " is false" <<endl;
cout << "testing != ";
if (a != b)

View file

@ -43,7 +43,7 @@ main()
for (unsigned POP2_SIZE = 4; POP2_SIZE <=6; POP2_SIZE++)
{
eoPop<Chrom> pop2, pop3, pop4, pop5;
eoPop<Chrom> pop2, pop3, pop4, pop5, popx;
for (i = 0; i < POP2_SIZE; i++)
{
@ -68,16 +68,19 @@ main()
}
eoInsertion<Chrom> insertion(0.75);
popx = pop;
pop3 = pop2;
insertion(pop, pop3);
insertion(popx, pop3);
eoInsertion<Chrom> insertion2;
eoInsertion<Chrom> insertion2;
popx = pop;
pop4 = pop2;
insertion2(pop, pop4);
insertion2(popx, pop4);
eoInsertion<Chrom> insertion3(1.5);
popx = pop;
pop5 = pop2;
insertion3(pop, pop5);
insertion3(popx, pop5);
cout << endl
<< "0.75 \t\t1.0 \t\t1.5" << endl