Modifications 22/02/2007

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@183 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
legrand 2007-02-22 15:38:01 +00:00
commit 8312d91a84
19 changed files with 930 additions and 805 deletions

View file

@ -24,8 +24,7 @@
/**
* This class allows to save the fitnesses of solutions contained in an archive into a file at each generation.
*/
template <class EOT>
class moeoArchiveFitnessSavingUpdater : public eoUpdater
template < class EOT > class moeoArchiveFitnessSavingUpdater:public eoUpdater
{
public:
@ -35,21 +34,25 @@ public:
* @param _filename target filename
* @param _id own ID
*/
moeoArchiveFitnessSavingUpdater (moeoArchive<EOT> & _arch, const std::string & _filename = "Res/Arch", int _id = -1) : arch(_arch), filename(_filename), id(_id), counter(0)
{}
moeoArchiveFitnessSavingUpdater (moeoArchive < EOT > &_arch, const std::string & _filename = "Res/Arch", int _id = -1):arch (_arch), filename (_filename), id (_id),
counter
(0)
{
}
/**
* Saves the fitness of the archive's members into the file
*/
void operator()() {
void operator () ()
{
char buff[MAX_BUFFER_SIZE];
if (id == -1)
sprintf (buff, "%s.%u", filename.c_str(), counter ++);
sprintf (buff, "%s.%u", filename.c_str (), counter++);
else
sprintf (buff, "%s.%u.%u", filename.c_str(), id, counter ++);
std::ofstream f(buff);
sprintf (buff, "%s.%u.%u", filename.c_str (), id, counter++);
std::ofstream f (buff);
for (unsigned i = 0; i < arch.size (); i++)
f << arch[i].objectiveVector() << std::endl;
f << arch[i].objectiveVector () << std::endl;
f.close ();
}
@ -57,14 +60,14 @@ public:
private:
/** local archive */
moeoArchive<EOT> & arch;
moeoArchive < EOT > &arch;
/** target filename */
std::string filename;
std::string filename;
/** own ID */
int id;
int id;
/** counter */
unsigned counter;
unsigned counter;
};
#endif /*MOEOARCHIVEFITNESSSAVINGUPDATER_H_*/
#endif /*MOEOARCHIVEFITNESSSAVINGUPDATER_H_ */