Removed some multiple declaraions inside for loops that MSVC++ doesn't like

This commit is contained in:
evomarc 2002-08-02 07:40:47 +00:00
commit 86c7c8fe95
2 changed files with 11 additions and 9 deletions

View file

@ -89,12 +89,13 @@ private :
}; };
void one_objective(const eoPop<EOT>& _pop) void one_objective(const eoPop<EOT>& _pop)
{ {
unsigned i;
eoPop<DummyEO> tmp_pop; eoPop<DummyEO> tmp_pop;
tmp_pop.resize(_pop.size()); tmp_pop.resize(_pop.size());
// copy pop to dummy population (only need the fitnesses) // copy pop to dummy population (only need the fitnesses)
for (unsigned i = 0; i < _pop.size(); ++i) for (i = 0; i < _pop.size(); ++i)
{ {
tmp_pop[i].fitness(_pop[i].fitness()); tmp_pop[i].fitness(_pop[i].fitness());
tmp_pop[i].index = i; tmp_pop[i].index = i;
@ -104,7 +105,7 @@ private :
tmp_pop.sort(); tmp_pop.sort();
// //
for (unsigned i = 0; i < _pop.size(); ++i) for (i = 0; i < _pop.size(); ++i)
{ {
value()[tmp_pop[i].index] = _pop.size() - i; // set rank value()[tmp_pop[i].index] = _pop.size() - i; // set rank
} }
@ -131,13 +132,14 @@ private :
*/ */
void two_objectives(const eoPop<EOT>& _pop) void two_objectives(const eoPop<EOT>& _pop)
{ {
unsigned i;
typedef typename EOT::Fitness::fitness_traits traits; typedef typename EOT::Fitness::fitness_traits traits;
assert(traits::nObjectives() == 2); assert(traits::nObjectives() == 2);
vector<unsigned> sort1(_pop.size()); // index into population sorted on first objective vector<unsigned> sort1(_pop.size()); // index into population sorted on first objective
for (unsigned i = 0; i < _pop.size(); ++i) for (i = 0; i < _pop.size(); ++i)
{ {
sort1[i] = i; sort1[i] = i;
} }
@ -149,7 +151,7 @@ private :
unsigned last_front = 0; unsigned last_front = 0;
double max1 = -1e+20; double max1 = -1e+20;
for (unsigned i = 0; i < _pop.size(); ++i) for (i = 0; i < _pop.size(); ++i)
{ {
max1 = max(max1, _pop[i].fitness()[1]); max1 = max(max1, _pop[i].fitness()[1]);
} }
@ -162,7 +164,7 @@ private :
vector<vector<unsigned> > fronts(_pop.size()); // to store indices into the front vector<vector<unsigned> > fronts(_pop.size()); // to store indices into the front
for (unsigned i = 0; i < _pop.size(); ++i) for (i = 0; i < _pop.size(); ++i)
{ {
unsigned index = sort1[i]; unsigned index = sort1[i];
@ -204,7 +206,7 @@ private :
// ok, and finally the niche penalty // ok, and finally the niche penalty
for (unsigned i = 0; i < fronts.size(); ++i) for (i = 0; i < fronts.size(); ++i)
{ {
if (fronts[i].size() == 0) continue; if (fronts[i].size() == 0) continue;

View file

@ -97,7 +97,7 @@ bool eoCheckPoint<EOT>::operator()(const eoPop<EOT>& _pop)
(*monitors[i])(); (*monitors[i])();
bool bContinue = true; bool bContinue = true;
for (unsigned i = 0; i < continuators.size(); ++i) for (i = 0; i < continuators.size(); ++i)
if ( !(*continuators[i])(_pop) ) if ( !(*continuators[i])(_pop) )
bContinue = false; bContinue = false;