More details to make code MSVC-compatible
This commit is contained in:
parent
eaf5ea0111
commit
512d368dcf
3 changed files with 8 additions and 7 deletions
|
|
@ -66,7 +66,8 @@ public:
|
||||||
|
|
||||||
// average fitness
|
// average fitness
|
||||||
double sum=0.0;
|
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());
|
sum += static_cast<double>(_pop[i].fitness());
|
||||||
double averageFitness = sum/pSize;
|
double averageFitness = sum/pSize;
|
||||||
|
|
||||||
|
|
@ -75,7 +76,7 @@ public:
|
||||||
double alpha = (pressure-1)/denom;
|
double alpha = (pressure-1)/denom;
|
||||||
double beta = (bestFitness - pressure*averageFitness)/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);
|
value()[i] = max(alpha*_pop[i].fitness()+beta, 0.0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -132,8 +132,8 @@ int main(int argc, char* argv[])
|
||||||
string foo;
|
string foo;
|
||||||
cin >> foo;
|
cin >> foo;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
catch(exception& e)
|
catch(exception& e)
|
||||||
{
|
{
|
||||||
cout << e.what() << endl;
|
cout << e.what() << endl;
|
||||||
|
|
|
||||||
|
|
@ -61,9 +61,9 @@ void testSelectMany(eoSelect<EOT> & _select, string _name)
|
||||||
|
|
||||||
eoDummyPop parents(pSize);
|
eoDummyPop parents(pSize);
|
||||||
eoDummyPop offspring(0);
|
eoDummyPop offspring(0);
|
||||||
|
unsigned i;
|
||||||
// initialize parents
|
// initialize parents
|
||||||
for (unsigned i=0; i<pSize; i++)
|
for (i=0; i<pSize; i++)
|
||||||
// parents[i].fitness(log(i+1));
|
// parents[i].fitness(log(i+1));
|
||||||
// parents[i].fitness(exp(i));
|
// parents[i].fitness(exp(i));
|
||||||
parents[i].fitness(i);
|
parents[i].fitness(i);
|
||||||
|
|
@ -74,7 +74,7 @@ void testSelectMany(eoSelect<EOT> & _select, string _name)
|
||||||
|
|
||||||
// compute stats
|
// compute stats
|
||||||
vector<unsigned> nb(parents.size(), 0);
|
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);
|
unsigned trouve = isInPop<Dummy>(offspring[i], parents);
|
||||||
if (trouve == parents.size()) // pas trouve
|
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
|
// dump to file so you can plot using gnuplot
|
||||||
string fName = _name + ".prop";
|
string fName = _name + ".prop";
|
||||||
ofstream os(fName.c_str());
|
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;
|
cout << i << " -> " << ( (double)nb[i])/offspring.size() << endl;
|
||||||
os << i << " " << ( (double)nb[i])/offspring.size() << endl;
|
os << i << " " << ( (double)nb[i])/offspring.size() << endl;
|
||||||
|
|
|
||||||
Reference in a new issue