adding a lot of includes
This commit is contained in:
parent
a9468f38c9
commit
142c7d779c
5 changed files with 52 additions and 34 deletions
|
|
@ -2,18 +2,21 @@
|
|||
// gprop
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <stdlib.h> // EXIT_SUCCESS EXIT_FAILURE
|
||||
#include <stdexcept> // exception
|
||||
#include <iostream> // cerr cout
|
||||
#include <fstream> // ifstream
|
||||
#include <string> // string
|
||||
#include <utils/eoParser.h> // eoParser
|
||||
#include <eoPop.h> // eoPop
|
||||
#include <eoGenContinue.h> // eoGenContinue
|
||||
#include <eoProportional.h> // eoProportional
|
||||
#include <eoStochTournament.h> // eoStochTournament
|
||||
#include <eoSGA.h> // eoSGA
|
||||
#include "gprop.h" // Chrom eoChromInit eoChromMutation eoChromXover eoChromEvaluator
|
||||
#include <stdlib.h> // EXIT_SUCCESS EXIT_FAILURE
|
||||
#include <stdexcept> // exception
|
||||
#include <iostream> // cerr cout
|
||||
#include <fstream> // ifstream
|
||||
#include <string> // string
|
||||
#include <utils/eoParser.h> // eoParser
|
||||
#include <eoPop.h> // eoPop
|
||||
#include <eoGenContinue.h> // eoGenContinue
|
||||
#include <eoStochTournament.h> // eoStochTournament
|
||||
#include <eoSGA.h> // eoSGA
|
||||
#include <eoGenContinue.h> // eoGenContinue
|
||||
#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
|
||||
|
|
@ -120,8 +123,6 @@ void load_file(mlp::set& set, const string& ext)
|
|||
|
||||
void ga()
|
||||
{
|
||||
eoGenContinue<Chrom> continuator(generations.value());
|
||||
|
||||
// create population
|
||||
eoInitChrom init;
|
||||
eoPop<Chrom> pop(pop_size.value(), init);
|
||||
|
|
@ -137,13 +138,28 @@ void ga()
|
|||
// genetic operators
|
||||
eoChromMutation mutation(generations);
|
||||
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
|
||||
eoSGA<Chrom> sga(select,
|
||||
xover, xover_rate.value(),
|
||||
mutation, mut_rate.value(),
|
||||
evaluator,
|
||||
continuator);
|
||||
checkpoint);
|
||||
|
||||
cout << pop << endl;
|
||||
|
||||
|
|
|
|||
|
|
@ -34,5 +34,5 @@ AC_TYPE_SIZE_T
|
|||
dnl Checks for library functions.
|
||||
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)
|
||||
|
||||
|
|
|
|||
|
|
@ -52,21 +52,21 @@ class eoSelectPerc : public eoSelect<EOT>
|
|||
@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)
|
||||
*/
|
||||
virtual void operator()(const eoPop<EOT>& _source, eoPop<EOT>& _dest)
|
||||
{
|
||||
size_t target = static_cast<size_t>(floor(rate * _source.size()));
|
||||
|
||||
_dest.resize(target);
|
||||
|
||||
select.setup(_source);
|
||||
|
||||
for (size_t i = 0; i < _dest.size(); ++i)
|
||||
_dest[i] = select(_source);
|
||||
}
|
||||
|
||||
private :
|
||||
eoSelectOne<EOT>& select;
|
||||
float rate;
|
||||
virtual void operator()(const eoPop<EOT>& _source, eoPop<EOT>& _dest)
|
||||
{
|
||||
size_t target = static_cast<size_t>(floor(rate * _source.size()));
|
||||
|
||||
_dest.resize(target);
|
||||
|
||||
select.setup(_source);
|
||||
|
||||
for (size_t i = 0; i < _dest.size(); ++i)
|
||||
_dest[i] = select(_source);
|
||||
}
|
||||
|
||||
private :
|
||||
eoSelectOne<EOT>& select;
|
||||
float rate;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -28,9 +28,10 @@
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <functional> //
|
||||
#include <numeric> // accumulate
|
||||
#include <utils/eoRNG.h>
|
||||
#include <functional>
|
||||
#include <numeric> // accumulate
|
||||
#include <eoSelectOne.h> // eoSelectOne
|
||||
#include <utils/selectors.h> // stochastic_tournament
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** eoStochTournament: a selection method that selects ONE individual by
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#define _eoCheckPoint_h
|
||||
|
||||
#include <eoContinue.h>
|
||||
#include <utils/eoUpdater.h>
|
||||
|
||||
template <class EOT> class eoStatBase;
|
||||
template <class EOT> class eoSortedStatBase;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue