adding a lot of includes

This commit is contained in:
gustavoromero 2000-12-01 15:46:07 +00:00
commit 142c7d779c
5 changed files with 52 additions and 34 deletions

View file

@ -2,18 +2,21 @@
// gprop // gprop
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include <stdlib.h> // EXIT_SUCCESS EXIT_FAILURE #include <stdlib.h> // EXIT_SUCCESS EXIT_FAILURE
#include <stdexcept> // exception #include <stdexcept> // exception
#include <iostream> // cerr cout #include <iostream> // cerr cout
#include <fstream> // ifstream #include <fstream> // ifstream
#include <string> // string #include <string> // string
#include <utils/eoParser.h> // eoParser #include <utils/eoParser.h> // eoParser
#include <eoPop.h> // eoPop #include <eoPop.h> // eoPop
#include <eoGenContinue.h> // eoGenContinue #include <eoGenContinue.h> // eoGenContinue
#include <eoProportional.h> // eoProportional #include <eoStochTournament.h> // eoStochTournament
#include <eoStochTournament.h> // eoStochTournament #include <eoSGA.h> // eoSGA
#include <eoSGA.h> // eoSGA #include <eoGenContinue.h> // eoGenContinue
#include "gprop.h" // Chrom eoChromInit eoChromMutation eoChromXover eoChromEvaluator #include <utils/eoCheckPoint.h> // eoCheckPoint
#include <utils/eoStat.h> // eoSecondMomentStats
#include <utils/eoStdoutMonitor.h> // eoStdoutMonitor
#include "gprop.h" // Chrom eoChromInit eoChromMutation eoChromXover eoChromEvaluator
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// global variables // global variables
@ -120,8 +123,6 @@ void load_file(mlp::set& set, const string& ext)
void ga() void ga()
{ {
eoGenContinue<Chrom> continuator(generations.value());
// create population // create population
eoInitChrom init; eoInitChrom init;
eoPop<Chrom> pop(pop_size.value(), init); eoPop<Chrom> pop(pop_size.value(), init);
@ -138,12 +139,27 @@ void ga()
eoChromMutation mutation(generations); eoChromMutation mutation(generations);
eoChromXover xover; eoChromXover xover;
// stop condition
eoGenContinue<Chrom> continuator(generations.value());
// checkpoint
eoCheckPoint<Chrom> checkpoint(continuator);
// monitor
eoStdoutMonitor monitor;
checkpoint.add(monitor);
// statistics
eoSecondMomentStats<Chrom> stats;
checkpoint.add(stats);
monitor.add(stats);
// genetic algorithm // genetic algorithm
eoSGA<Chrom> sga(select, eoSGA<Chrom> sga(select,
xover, xover_rate.value(), xover, xover_rate.value(),
mutation, mut_rate.value(), mutation, mut_rate.value(),
evaluator, evaluator,
continuator); checkpoint);
cout << pop << endl; cout << pop << endl;

View file

@ -34,5 +34,5 @@ AC_TYPE_SIZE_T
dnl Checks for library functions. dnl Checks for library functions.
AC_CHECK_FUNCS(select) AC_CHECK_FUNCS(select)
AC_OUTPUT(src/obsolete/Makefile doc/Makefile src/Makefile src/utils/Makefile src/other/Makefile win/Makefile src/gp/Makefile src/es/Makefile src/ga/Makefile test/Makefile contrib/Makefile Makefile app/Makefile app/gprop/Makefile) AC_OUTPUT(src/obsolete/Makefile doc/Makefile src/Makefile src/utils/Makefile src/other/Makefile win/Makefile src/gp/Makefile src/es/Makefile src/ga/Makefile test/Makefile contrib/Makefile Makefile app/Makefile app/gprop/Makefile app/mastermind/Makefile)

View file

@ -52,21 +52,21 @@ class eoSelectPerc : public eoSelect<EOT>
@param _source the source population @param _source the source population
@param _dest the resulting population (size of this population is the number of times eoSelectOne is called. It empties the destination and adds the selection into it) @param _dest the resulting population (size of this population is the number of times eoSelectOne is called. It empties the destination and adds the selection into it)
*/ */
virtual void operator()(const eoPop<EOT>& _source, eoPop<EOT>& _dest) virtual void operator()(const eoPop<EOT>& _source, eoPop<EOT>& _dest)
{ {
size_t target = static_cast<size_t>(floor(rate * _source.size())); size_t target = static_cast<size_t>(floor(rate * _source.size()));
_dest.resize(target); _dest.resize(target);
select.setup(_source); select.setup(_source);
for (size_t i = 0; i < _dest.size(); ++i) for (size_t i = 0; i < _dest.size(); ++i)
_dest[i] = select(_source); _dest[i] = select(_source);
} }
private : private :
eoSelectOne<EOT>& select; eoSelectOne<EOT>& select;
float rate; float rate;
}; };
#endif #endif

View file

@ -28,9 +28,10 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include <functional> // #include <functional>
#include <numeric> // accumulate #include <numeric> // accumulate
#include <utils/eoRNG.h> #include <eoSelectOne.h> // eoSelectOne
#include <utils/selectors.h> // stochastic_tournament
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** eoStochTournament: a selection method that selects ONE individual by /** eoStochTournament: a selection method that selects ONE individual by

View file

@ -28,6 +28,7 @@
#define _eoCheckPoint_h #define _eoCheckPoint_h
#include <eoContinue.h> #include <eoContinue.h>
#include <utils/eoUpdater.h>
template <class EOT> class eoStatBase; template <class EOT> class eoStatBase;
template <class EOT> class eoSortedStatBase; template <class EOT> class eoSortedStatBase;