A few changes for MSVC++ compatibility

This commit is contained in:
evomarc 2002-04-12 15:13:45 +00:00
commit 42a2a4f69e
3 changed files with 10 additions and 8 deletions

View file

@ -56,13 +56,14 @@ public :
*/ */
virtual void operator()(const eoPop<EOT>& _pop) virtual void operator()(const eoPop<EOT>& _pop)
{ {
unsigned i;
if (!boolOpt) // take the local best if (!boolOpt) // take the local best
theBest = _pop.best_element(); theBest = _pop.best_element();
unsigned int pSize = _pop.size(); unsigned int pSize = _pop.size();
distToBest.value().resize(pSize); distToBest.value().resize(pSize);
fitnesses.value().resize(pSize); fitnesses.value().resize(pSize);
double sumFit = 0.0, sumDist = 0.0; double sumFit = 0.0, sumDist = 0.0;
for (unsigned i=0; i<pSize; i++) for (i=0; i<pSize; i++)
{ {
sumDist += (distToBest.value()[i] = dist(_pop[i], theBest)); sumDist += (distToBest.value()[i] = dist(_pop[i], theBest));
sumFit += (fitnesses.value()[i] = _pop[i].fitness()); sumFit += (fitnesses.value()[i] = _pop[i].fitness());
@ -72,7 +73,7 @@ public :
double avgFit = sumFit/pSize; double avgFit = sumFit/pSize;
sumDist = sumFit = 0.0; sumDist = sumFit = 0.0;
double num = 0.0; double num = 0.0;
for (unsigned i=0; i<pSize; i++) for (i=0; i<pSize; i++)
{ {
double devDist = distToBest.value()[i] - avgDist ; double devDist = distToBest.value()[i] - avgDist ;
double devFit = fitnesses.value()[i] - avgFit ; double devFit = fitnesses.value()[i] - avgFit ;

View file

@ -27,7 +27,7 @@
#ifndef _eoTimeCounter_h #ifndef _eoTimeCounter_h
#define _eoTimeCounter_h #define _eoTimeCounter_h
#include <sys/times.h> #include <time.h>
#include <utils/eoStat.h> #include <utils/eoStat.h>
@ -45,7 +45,7 @@ public:
virtual void operator()() virtual void operator()()
{ {
// ask for system time // ask for system time
times(&tmsStruct); utime = clock();
// if (firstTime) /* first generation */ // if (firstTime) /* first generation */
// { // {
// firstTime=false; // firstTime=false;
@ -53,13 +53,13 @@ public:
// } // }
// store elapsed user time // store elapsed user time
// value(tmsStruct.tms_utime - firstUtime); // value(tmsStruct.tms_utime - firstUtime);
value()=double(tmsStruct.tms_utime)/100; value()=double(utime)/CLOCKS_PER_SEC;
} }
private: private:
// bool firstTime; // bool firstTime;
// clock_t firstUtime; // clock_t firstUtime;
struct tms tmsStruct; // stores time clock_t utime;
}; };
#endif #endif

View file

@ -27,6 +27,7 @@
#ifndef _eoUpdater_h #ifndef _eoUpdater_h
#define _eoUpdater_h #define _eoUpdater_h
#include <string>
#include <eoFunctor.h> #include <eoFunctor.h>
#include <utils/eoState.h> #include <utils/eoState.h>
#include <utils/eoParam.h> #include <utils/eoParam.h>
@ -69,13 +70,13 @@ class eoIncrementorParam : public eoUpdater, public eoValueParam<T>
{ {
public : public :
/** Default Ctor : a name and optionally an increment*/ /** Default Ctor : a name and optionally an increment*/
eoIncrementorParam(string _name, T _stepsize = 1) : eoIncrementorParam( std::string _name, T _stepsize = 1) :
eoValueParam<T>(T(0), _name), stepsize(_stepsize) {} eoValueParam<T>(T(0), _name), stepsize(_stepsize) {}
/** Ctor with a name and non-zero initial value /** Ctor with a name and non-zero initial value
* and mandatory stepSize to remove ambiguity * and mandatory stepSize to remove ambiguity
*/ */
eoIncrementorParam(string _name, T _countValue, T _stepsize) : eoIncrementorParam( std::string _name, T _countValue, T _stepsize) :
eoValueParam<T>(_countValue, _name), stepsize(_stepsize) {} eoValueParam<T>(_countValue, _name), stepsize(_stepsize) {}
/** Simply increments */ /** Simply increments */