Doing libes.a in src/es and adding t-eoReal.cpp in test
I had to move eoRealBounds to utils dir because of global objects Some domino consequences here and there ...
This commit is contained in:
parent
511dc26623
commit
4968d64b05
19 changed files with 120 additions and 25 deletions
|
|
@ -48,9 +48,6 @@
|
|||
#include <es/eoRealOp.h>
|
||||
#include <es/eoNormalMutation.h>
|
||||
|
||||
// and their generic counterparts
|
||||
#include <es/eoGenericRealOp.h>
|
||||
|
||||
// the ES-mutations
|
||||
#include <es/eoEsMutationInit.h>
|
||||
#include <es/eoEsMutate.h>
|
||||
|
|
|
|||
|
|
@ -4,5 +4,16 @@
|
|||
##
|
||||
###############################################################################
|
||||
|
||||
INCLUDES = -I$(top_builddir)/src
|
||||
lib_LIBRARIES = libes.a
|
||||
libes_a_SOURCES = make_algo_scalar_real.cpp \
|
||||
make_checkpoint_real.cpp \
|
||||
make_continue_real.cpp \
|
||||
make_genotype_real.cpp \
|
||||
make_help.cpp \
|
||||
make_op_real.cpp \
|
||||
make_pop_real.cpp \
|
||||
make_run_real.cpp
|
||||
CPPFLAGS = -Wall
|
||||
libeoincdir = $(includedir)/eo/es
|
||||
libeoinc_HEADERS = eoEsChromInit.h eoEsFull.h eoEsMutate.h eoEsMutationInit.h eoEsSimple.h eoEsStdev.h eoEsStdevXOver.h eoGenericRealOp.h eoNormalMutation.h eoReal.h eoRealBounds.h eoRealOp.h
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#ifndef _eoEsChromInit_H
|
||||
#define _eoEsChromInit_H
|
||||
|
||||
#include <es/eoRealBounds.h>
|
||||
#include <utils/eoRealBounds.h>
|
||||
#include <es/eoEsSimple.h>
|
||||
#include <es/eoEsStdev.h>
|
||||
#include <es/eoEsFull.h>
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
#include <es/eoEsSimple.h>
|
||||
#include <es/eoEsStdev.h>
|
||||
#include <es/eoEsFull.h>
|
||||
#include <es/eoRealBounds.h>
|
||||
#include <utils/eoRealBounds.h>
|
||||
|
||||
#include <eoOp.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
#define _eoEsStdevXOver_h
|
||||
|
||||
#include <es/eoEsStdev.h>
|
||||
#include <es/eoGenericRealOp.h>
|
||||
#include <es/eoRealOp.h>
|
||||
|
||||
/**
|
||||
\ingroup EvolutionStrategies
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
#include <utils/eoUpdatable.h>
|
||||
#include <eoEvalFunc.h>
|
||||
#include <es/eoReal.h>
|
||||
#include <es/eoRealBounds.h>
|
||||
#include <utils/eoRealBounds.h>
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** Simple normal mutation of a vector of real values.
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
#include <algorithm> // swap_ranges
|
||||
#include <utils/eoRNG.h>
|
||||
#include <es/eoReal.h>
|
||||
#include <es/eoRealBounds.h>
|
||||
#include <utils/eoRealBounds.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -24,15 +24,15 @@
|
|||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** This file contains all ***INSTANCIATED DEFINITIONS*** of operators
|
||||
/** This file contains all ***INSTANCIATED DEFINITIONS*** of pop. init.
|
||||
* of the library for ***BISTRING*** evolution inside EO.
|
||||
* It should be included in the file that calls any of the corresponding fns
|
||||
* Compiling this file allows one to generate part of the library (i.e. object
|
||||
* files that you just need to link with your own main and fitness code).
|
||||
*
|
||||
* The corresponding ***INSTANCIATED DECLARATIONS*** are contained
|
||||
* in make_algo_scalar_ga.h
|
||||
* while the TEMPLATIZED code is define in make_algo_scalar.h in the do dir
|
||||
* in src/ga/ga.h
|
||||
* while the TEMPLATIZED code is define in make_algo_scalar.h in the src/do dir
|
||||
*
|
||||
* Unlike most EO .h files, it does not (and should not) contain any code,
|
||||
* just declarations
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@
|
|||
* files that you just need to link with your own main and fitness code).
|
||||
*
|
||||
* The corresponding ***INSTANCIATED DECLARATIONS*** are contained
|
||||
* in make_continue_ga.h
|
||||
* while the TEMPLATIZED code is define in make_contninue.h in the do dir
|
||||
* in ga.h
|
||||
* while the TEMPLATIZED code is define in make_contninue.h in the src/do dir
|
||||
*
|
||||
* Unlike most EO .h files, it does not (and should not) contain any code,
|
||||
* just declarations
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@
|
|||
* files that you just need to link with your own main and fitness code).
|
||||
*
|
||||
* The corresponding ***INSTANCIATED DECLARATIONS*** are contained
|
||||
* in make_pop_ga.h
|
||||
* while the TEMPLATIZED code is define in make_pop.h in the do dir
|
||||
* in ga.h
|
||||
* while the TEMPLATIZED code is define in make_pop.h in the src/do dir
|
||||
*
|
||||
* Unlike most EO .h files, it does not (and should not) contain any code,
|
||||
* just declarations
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
INCLUDES = -I$(top_builddir)/src
|
||||
CPPFLAGS = -O2 -Wall
|
||||
lib_LIBRARIES = libeoutils.a
|
||||
libeoutils_a_SOURCES = eoParser.cpp eoRNG.cpp eoState.cpp eoUpdater.cpp eoFileMonitor.cpp eoStdoutMonitor.cpp
|
||||
libeoutils_a_SOURCES = eoParser.cpp eoRNG.cpp eoState.cpp eoUpdater.cpp eoFileMonitor.cpp eoStdoutMonitor.cpp eoRealBounds.cpp
|
||||
|
||||
libeoincdir = $(includedir)/eo/utils
|
||||
libeoinc_HEADERS = checkpointing *.h
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ inline void eoGnuplot1DMonitor::FirstPlot()
|
|||
{
|
||||
if (vec.size() < 2)
|
||||
{
|
||||
throw runtime_error("eoGnuplot1DMonitor needs at least 2 stats (X and Y)!\n");
|
||||
throw runtime_error("Must have some stats to plot!\n");
|
||||
}
|
||||
char buff[1024];
|
||||
ostrstream os(buff, 1024);
|
||||
|
|
|
|||
|
|
@ -470,7 +470,7 @@ public:
|
|||
// so here we do have arguments
|
||||
string t = _value.substr(pos+1);// the arguments
|
||||
_value.resize(pos);
|
||||
first = _value; // done for the keyword
|
||||
first = _value; // done for the keyword (NOTE: may be empty string!)
|
||||
|
||||
// now all arguments
|
||||
string delim(" (),");
|
||||
|
|
|
|||
7
eo/src/utils/eoRealBounds.cpp
Normal file
7
eo/src/utils/eoRealBounds.cpp
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include <ctime>
|
||||
#include "eoRealBounds.h"
|
||||
|
||||
// the global dummy bounds
|
||||
// (used for unbounded variables when bounds are required)
|
||||
eoRealNoBounds eoDummyRealNoBounds;
|
||||
eoRealVectorNoBounds eoDummyVectorNoBounds;
|
||||
|
|
@ -27,6 +27,9 @@
|
|||
#ifndef _eoRealBounds_h
|
||||
#define _eoRealBounds_h
|
||||
|
||||
#include <stdexcept> // exceptions!
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
/**
|
||||
\defgroup EvolutionStrategies
|
||||
|
||||
|
|
@ -408,7 +411,7 @@ Anyone with extra time in his agenda is welcome to change that :-)
|
|||
class eoRealVectorBounds : public vector<eoRealBounds *>
|
||||
{
|
||||
public:
|
||||
// virtual desctructor (to avoid warining?)
|
||||
// virtual desctructor (to avoid warning?)
|
||||
virtual ~eoRealVectorBounds(){}
|
||||
|
||||
/** Default Ctor
|
||||
|
|
@ -649,6 +652,6 @@ public:
|
|||
};
|
||||
|
||||
// one object for all
|
||||
eoRealNoBounds eoDummyRealNoBounds;
|
||||
eoRealVectorNoBounds eoDummyVectorNoBounds;
|
||||
extern eoRealNoBounds eoDummyRealNoBounds;
|
||||
extern eoRealVectorNoBounds eoDummyVectorNoBounds;
|
||||
#endif
|
||||
|
|
@ -14,10 +14,10 @@ CXXFLAGS = -g -Wall
|
|||
###############################################################################
|
||||
|
||||
check_PROGRAMS = t-eoParetoFitness t-eoPareto t-eofitness t-eoRandom t-eobin t-eoStateAndParser t-eoCheckpointing t-eoSSGA \
|
||||
t-eoExternalEO t-eoSymreg t-eo t-eoReplacement t-eoSelect t-eoGenOp t-eoGA t-eoVector
|
||||
t-eoExternalEO t-eoSymreg t-eo t-eoReplacement t-eoSelect t-eoGenOp t-eoGA t-eoReal t-eoVector
|
||||
TESTS=run_tests t-eoVector t-eoRandom t-eoSSGA t-eoPareto t-eoParetoFitness
|
||||
# removing temporarily t-eoESFull
|
||||
#noinst_PROGRAMS = t-eofitness t-eobin t-eoStateAndParser t-eoCheckpointing t-eoExternalEO t-eoESFull t-eoSymreg t-eo t-eoReplacement t-eoSelect t-eoGenOp t-eoGA
|
||||
# noinst_PROGRAMS = t-eofitness t-eobin t-eoStateAndParser t-eoCheckpointing t-eoExternalEO t-eoESFull t-eoSymreg t-eo t-eoReplacement t-eoSelect t-eoGenOp t-eoGA t-eoReal
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
|
@ -115,6 +115,13 @@ t_eoGA_LDADD = $(top_builddir)/src/ga/libga.a $(LDADDS)
|
|||
|
||||
###############################################################################
|
||||
|
||||
t_eoReal_SOURCES = t-eoReal.cpp real_value.h
|
||||
t_eoReal_DEPENDENCIES = $(DEPS) $(top_builddir)/src/es/libes.a
|
||||
t_eoReal_LDFLAGS = -lm
|
||||
t_eoReal_LDADD = $(top_builddir)/src/es/libes.a $(LDADDS)
|
||||
|
||||
###############################################################################
|
||||
|
||||
t_eoSSGA_SOURCES = t-eoSSGA.cpp binary_value.h
|
||||
t_eoSSGA_DEPENDENCIES = $(DEPS) $(top_builddir)/src/ga/libga.a
|
||||
t_eoSSGA_LDFLAGS = -lm
|
||||
|
|
|
|||
70
eo/test/t-eoReal.cpp
Normal file
70
eo/test/t-eoReal.cpp
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
#include <iostream>
|
||||
|
||||
#include <es/es.h>
|
||||
#include "real_value.h"
|
||||
#include <apply.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
typedef eoReal<eoMinimizingFitness> EOT;
|
||||
|
||||
eoParser parser(argc, argv); // for user-parameter reading
|
||||
|
||||
eoState state; // keeps all things allocated
|
||||
|
||||
///// FIRST, problem or representation dependent stuff
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
// The evaluation fn - encapsulated into an eval counter for output
|
||||
eoEvalFuncPtr<EOT, double, const std::vector<double>&>
|
||||
mainEval( real_value );
|
||||
eoEvalFuncCounter<EOT> eval(mainEval);
|
||||
|
||||
// the genotype - through a genotype initializer
|
||||
eoInit<EOT>& init = make_genotype(parser, state, eoMinimizingFitness());
|
||||
|
||||
// Build the variation operator (any seq/prop construct)
|
||||
eoGenOp<EOT>& op = make_op(parser, state, init);
|
||||
|
||||
//// Now the representation-independent things
|
||||
//////////////////////////////////////////////
|
||||
|
||||
// initialize the population - and evaluate
|
||||
// yes, this is representation indepedent once you have an eoInit
|
||||
eoPop<EOT>& pop = make_pop(parser, state, init);
|
||||
apply(eval, pop);
|
||||
|
||||
// stopping criteria
|
||||
eoContinue<EOT> & term = make_continue(parser, state, eval);
|
||||
// output
|
||||
eoCheckPoint<EOT> & checkpoint = make_checkpoint(parser, state, eval, term);
|
||||
// algorithm (need the operator!)
|
||||
eoAlgo<EOT>& ga = make_algo_scalar(parser, state, eval, checkpoint, op);
|
||||
|
||||
///// End of construction of the algorith
|
||||
/////////////////////////////////////////
|
||||
// to be called AFTER all parameters have been read!!!
|
||||
make_help(parser);
|
||||
|
||||
//// GO
|
||||
///////
|
||||
cout << "Initial Population\n";
|
||||
pop.sortedPrintOn(cout);
|
||||
cout << endl;
|
||||
|
||||
run_ea(ga, pop); // run the ga
|
||||
|
||||
cout << "Final Population\n";
|
||||
pop.sortedPrintOn(cout);
|
||||
cout << endl;
|
||||
}
|
||||
catch(exception& e)
|
||||
{
|
||||
cout << e.what() << endl;
|
||||
}
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
#include <eo>
|
||||
#include <ga.h>
|
||||
|
||||
// REPRESENTATION
|
||||
// REPRESENTATION
|
||||
//-----------------------------------------------------------------------------
|
||||
// define your individuals
|
||||
typedef eoBit<double> Indi; // A bitstring with fitness double
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ void main_function(int argc, char **argv)
|
|||
fileMonitor.add(generationCounter);
|
||||
fileMonitor.add(bestStat);
|
||||
fileMonitor.add(SecondStat);
|
||||
// the fileMonitor can monitor parameters, too, but you must tell it!
|
||||
// the gnuMonitor can monitor parameters, too, but you must tell it!
|
||||
gnuMonitor.add(eval);
|
||||
gnuMonitor.add(bestStat);
|
||||
gnuMonitor.add(averageStat);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue