More details to make code MSVC-compatible

This commit is contained in:
evomarc 2001-12-03 11:08:17 +00:00
commit 512d368dcf
3 changed files with 8 additions and 7 deletions

View file

@ -66,7 +66,8 @@ public:
// average fitness
double sum=0.0;
for (unsigned i=0; i<pSize; i++)
unsigned i;
for (i=0; i<pSize; i++)
sum += static_cast<double>(_pop[i].fitness());
double averageFitness = sum/pSize;
@ -75,7 +76,7 @@ public:
double alpha = (pressure-1)/denom;
double beta = (bestFitness - pressure*averageFitness)/denom;
for (unsigned i=0; i<pSize; i++) // truncate to 0
for (i=0; i<pSize; i++) // truncate to 0
{
value()[i] = max(alpha*_pop[i].fitness()+beta, 0.0);
}

View file

@ -132,8 +132,8 @@ int main(int argc, char* argv[])
string foo;
cin >> foo;
}
}
#endif
}
catch(exception& e)
{
cout << e.what() << endl;

View file

@ -61,9 +61,9 @@ void testSelectMany(eoSelect<EOT> & _select, string _name)
eoDummyPop parents(pSize);
eoDummyPop offspring(0);
unsigned i;
// initialize parents
for (unsigned i=0; i<pSize; i++)
for (i=0; i<pSize; i++)
// parents[i].fitness(log(i+1));
// parents[i].fitness(exp(i));
parents[i].fitness(i);
@ -74,7 +74,7 @@ void testSelectMany(eoSelect<EOT> & _select, string _name)
// compute stats
vector<unsigned> nb(parents.size(), 0);
for (unsigned i=0; i<offspring.size(); i++)
for (i=0; i<offspring.size(); i++)
{
unsigned trouve = isInPop<Dummy>(offspring[i], parents);
if (trouve == parents.size()) // pas trouve
@ -84,7 +84,7 @@ void testSelectMany(eoSelect<EOT> & _select, string _name)
// dump to file so you can plot using gnuplot
string fName = _name + ".prop";
ofstream os(fName.c_str());
for (unsigned i=0; i<parents.size(); i++)
for (i=0; i<parents.size(); i++)
{
cout << i << " -> " << ( (double)nb[i])/offspring.size() << endl;
os << i << " " << ( (double)nb[i])/offspring.size() << endl;