Updated makefiles, updated the moo stuff and cleaned up some stuff that refused to compile

This commit is contained in:
maartenkeijzer 2007-11-12 16:23:57 +00:00
commit 18adaef056
19 changed files with 66 additions and 48 deletions

View file

@ -94,7 +94,7 @@ To add two values, do
Sym sym = var + const; Sym sym = var + const;
This will create a tree with tree nodes. All other operations work identically. This will create a tree with three nodes. Other operators are overloaded similarily.
=== Evaluation (eval/) === === Evaluation (eval/) ===

View file

@ -17,20 +17,20 @@
# The PROJECT_NAME tag is a single word (or a sequence of words surrounded # The PROJECT_NAME tag is a single word (or a sequence of words surrounded
# by quotes) that should identify the project. # by quotes) that should identify the project.
PROJECT_NAME = EO PROJECT_NAME = Evolving Objects
# The PROJECT_NUMBER tag can be used to enter a project or revision number. # The PROJECT_NUMBER tag can be used to enter a project or revision number.
# This could be handy for archiving the generated documentation or # This could be handy for archiving the generated documentation or
# if some version control system is used. # if some version control system is used.
PROJECT_NUMBER = 1.0.2-cvs PROJECT_NUMBER = 1.02-cvs1
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put. # base path where the generated documentation will be put.
# If a relative path is entered, it will be relative to the location # If a relative path is entered, it will be relative to the location
# where doxygen was started. If left blank the current directory will be used. # where doxygen was started. If left blank the current directory will be used.
OUTPUT_DIRECTORY = OUTPUT_DIRECTORY = /home/mkeijzer/projects/eo/doc
# The OUTPUT_LANGUAGE tag is used to specify the language in which all # The OUTPUT_LANGUAGE tag is used to specify the language in which all
# documentation generated by doxygen is written. Doxygen will use this # documentation generated by doxygen is written. Doxygen will use this
@ -104,7 +104,7 @@ FULL_PATH_NAMES = NO
# If left blank the directory from which doxygen is run is used as the # If left blank the directory from which doxygen is run is used as the
# path to strip. # path to strip.
STRIP_FROM_PATH = STRIP_FROM_PATH = /home/mkeijzer/projects/eo
# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
# (but less readable) file names. This can be useful is your file systems # (but less readable) file names. This can be useful is your file systems
@ -391,7 +391,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories # directories like "/usr/src/myproject". Separate the files or directories
# with spaces. # with spaces.
INPUT = .. INPUT = /home/mkeijzer/projects/eo
# If the value of the INPUT tag contains directories, you can use the # If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
@ -414,7 +414,7 @@ RECURSIVE = YES
# excluded from the INPUT source files. This way you can easily exclude a # excluded from the INPUT source files. This way you can easily exclude a
# subdirectory from a directory tree whose root is specified with the INPUT tag. # subdirectory from a directory tree whose root is specified with the INPUT tag.
EXCLUDE = ../src/obsolete EXCLUDE = /home/mkeijzer/projects/eo/src/obsolete
# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories # The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories
# that are symbolic links (a Unix filesystem feature) are excluded from the input. # that are symbolic links (a Unix filesystem feature) are excluded from the input.

View file

@ -47,11 +47,8 @@ public:
typedef F Fitness; typedef F Fitness;
/** Default constructor. /** Default constructor.
Fitness must have a ctor which takes 0 as a value; we can not use void
ctors here since default types like float have no void initializer.
VC++ allows it, but gcc does not
*/ */
EO(): repFitness(Fitness()), invalidFitness(true) {} EO(): repFitness(Fitness()), invalidFitness(true) { }
/// Virtual dtor /// Virtual dtor
virtual ~EO() {}; virtual ~EO() {};

View file

@ -143,6 +143,7 @@ pkginclude_HEADERS = eo \
eoWeightUpdater.h \ eoWeightUpdater.h \
es.h \ es.h \
ga.h \ ga.h \
PO.h PO.h \
eoTimeContinue.h
AM_CXXFLAGS = -I$(top_srcdir)/src AM_CXXFLAGS = -I$(top_srcdir)/src

View file

@ -127,6 +127,7 @@
#include <eoParetoRanking.h> #include <eoParetoRanking.h>
#include <eoNDSorting.h> #include <eoNDSorting.h>
// Algorithms // Algorithms
#include <eoEasyEA.h> #include <eoEasyEA.h>
#include <eoSGA.h> #include <eoSGA.h>

View file

@ -295,7 +295,6 @@ class eoPop: public std::vector<EOT>, public eoObject, public eoPersistent
this->operator[](i).invalidate(); this->operator[](i).invalidate();
} }
protected: protected:
}; };

View file

@ -89,7 +89,7 @@ public :
} }
} }
for (i=0; i < _pop.size(); i++) for (i=0; i < offspring.size(); i++)
{ {
if (rng.flip(mutationRate) ) if (rng.flip(mutationRate) )
{ {

View file

@ -47,7 +47,9 @@ class eoCMABreed : public eoBreed< eoVector<FitT, double> > {
// two temporary arrays of pointers to store the sorted population // two temporary arrays of pointers to store the sorted population
std::vector<const EOT*> sorted(parents.size()); std::vector<const EOT*> sorted(parents.size());
std::vector<const std::vector<double>* > mu(parents.size());
// mu stores population as vector (instead of eoPop)
std::vector<const std::vector<double>* > mu(parents.size());
parents.sort(sorted); parents.sort(sorted);
for (unsigned i = 0; i < sorted.size(); ++i) { for (unsigned i = 0; i < sorted.size(); ++i) {
@ -55,7 +57,6 @@ class eoCMABreed : public eoBreed< eoVector<FitT, double> > {
} }
// learn // learn
state.reestimate(mu, sorted[0]->fitness(), sorted.back()->fitness()); state.reestimate(mu, sorted[0]->fitness(), sorted.back()->fitness());
if (!state.updateEigenSystem(10)) { if (!state.updateEigenSystem(10)) {

View file

@ -5,7 +5,14 @@ libeomoo_a_SOURCES = eoFrontSorter.cpp \
eoNSGA_IIa_Eval.cpp \ eoNSGA_IIa_Eval.cpp \
eoNSGA_II_Eval.cpp eoNSGA_II_Eval.cpp
pkginclude_HEADERS = eoFrontSorter.h \ pkginclude_HEADERS =\
eoMOFitness.h eoEpsilonArchive.h\
eoEpsMOEA.h\
eoFrontSorter.h\
eoMOEval.h\
eoMOFitness.h\
eoNSGA_I_Eval.h\
eoNSGA_IIa_Eval.h\
eoNSGA_II_Eval.h
AM_CXXFLAGS = -I$(top_srcdir)/src AM_CXXFLAGS = -I$(top_srcdir)/src

View file

@ -16,7 +16,7 @@ class eoEpsMOEA : public eoAlgo<EOT> {
eoEvalFunc<EOT>& _eval, eoEvalFunc<EOT>& _eval,
eoGenOp<EOT>& _op, eoGenOp<EOT>& _op,
const std::vector<double>& eps, const std::vector<double>& eps,
unsigned max_archive_size unsigned max_archive_size = std::numeric_limits<unsigned>::max()
) : continuator(_continuator), ) : continuator(_continuator),
eval (_eval), eval (_eval),
loopEval(_eval), loopEval(_eval),

View file

@ -114,26 +114,6 @@ exitLoop:
} }
} }
/*
static unsigned counter = 0;
if (++counter % 500 == 0) {
std::vector<long> mins(archive[0].discretized.size(), std::numeric_limits<long>::max());
std::vector<long> maxs(archive[0].discretized.size(), std::numeric_limits<long>::min());
for (unsigned i = 0; i < archive.size(); ++i) {
for (unsigned dim = 0; dim < archive[i].discretized.size(); ++dim) {
mins[dim] = std::min( mins[dim], archive[i].discretized[dim] );
maxs[dim] = std::max( maxs[dim], archive[i].discretized[dim] );
}
}
std::cout << "Range ";
for (unsigned dim = 0; dim < mins.size(); ++dim) {
std::cout << (maxs[dim] - mins[dim]) << ' ';
}
std::cout << archive.size() << std::endl;
}*/
if (archive.size() > max_size) { if (archive.size() > max_size) {
unsigned idx = rng.random(archive.size()); unsigned idx = rng.random(archive.size());
if (idx != archive.size()-1) std::swap(archive[idx], archive.back()); if (idx != archive.size()-1) std::swap(archive[idx], archive.back());

View file

@ -1,6 +1,5 @@
#include <limits> #include <limits>
#include <eoNSGA_II_Eval.h> #include <moo/eoNSGA_II_Eval.h>
namespace nsga2 { namespace nsga2 {

View file

@ -25,7 +25,7 @@ class eoNSGA_II_Eval : public eoMOEval<EOT>
eoNSGA_II_Eval(eoPopEvalFunc<EOT>& eval) : eoMOEval<EOT>(eval) {} eoNSGA_II_Eval(eoPopEvalFunc<EOT>& eval) : eoMOEval<EOT>(eval) {}
virtual void operator()(eoPop<EOT>& parents, eoPop<EOT>& offspring) { virtual void operator()(eoPop<EOT>& parents, eoPop<EOT>& offspring) {
eval(parents, offspring); this->eval(parents, offspring);
std::vector<EOT*> pop; std::vector<EOT*> pop;
pop.reserve(parents.size() + offspring.size()); pop.reserve(parents.size() + offspring.size());

View file

@ -18,13 +18,15 @@ OBJECTS=eoFunctorStore.o PyEO.o abstract1.o algos.o \
mergers.o valueParam.o perf2worth.o monitors.o\ mergers.o valueParam.o perf2worth.o monitors.o\
statistics.o statistics.o
LIB=../libeo.a ../utils/libeoutils.a
all: PyEO/PyEO.so all: PyEO/PyEO.so
clean: clean:
rm PyEO/*.so *.o test/*.pyc rm PyEO/*.so *.o test/*.pyc
PyEO/PyEO.so: $(OBJECTS) PyEO/PyEO.so: $(OBJECTS)
$(LINK) -o PyEO/PyEO.so $(OBJECTS) -lboost_python -lpython2.4 -shared #-lstlport $(LINK) -o PyEO/PyEO.so $(OBJECTS) -lboost_python -lpython2.4 ${LIB} -shared #-lstlport
eoFunctorStore.o: ../eoFunctorStore.h ../eoFunctorStore.cpp eoFunctorStore.o: ../eoFunctorStore.h ../eoFunctorStore.cpp
$(COMPILE) -o eoFunctorStore.o ../eoFunctorStore.cpp $(INC) $(COMPILE) -o eoFunctorStore.o ../eoFunctorStore.cpp $(INC)

View file

@ -180,7 +180,7 @@ BOOST_PYTHON_MODULE(PyEO)
boost::python::class_<eoPop<PyEO> >("eoPop", init<>() ) boost::python::class_<eoPop<PyEO> >("eoPop", init<>() )
.def( init< unsigned, eoInit<PyEO>& >()[with_custodian_and_ward<1,3>()] ) .def( init< unsigned, eoInit<PyEO>& >()[with_custodian_and_ward<1,3>()] )
.def("append", &eoPop<PyEO>::append) .def("append", &eoPop<PyEO>::append, "docstring?")
.def("__str__", to_string<eoPop<PyEO> >) .def("__str__", to_string<eoPop<PyEO> >)
.def("__len__", pop_size) .def("__len__", pop_size)
.def("sort", pop_sort ) .def("sort", pop_sort )

View file

@ -108,4 +108,10 @@ t_eoEasyPSO_SOURCES = t-eoEasyPSO.cpp
t_eoNSGA_SOURCES = t-eoNSGA.cpp t_eoNSGA_SOURCES = t-eoNSGA.cpp
t_eoFrontSorter_SOURCES = t-eoFrontSorter.cpp t_eoFrontSorter_SOURCES = t-eoFrontSorter.cpp
t_eoEpsMOEA_SOURCES = t-eoEpsMOEA.cpp t_eoEpsMOEA_SOURCES = t-eoEpsMOEA.cpp
t_eoInt_SOURCES = t-eoInt.cpp
t_eoInitPermutation_SOURCES = t-eoInitPermutation.cpp
t_eoSwapMutation_SOURCES = t-eoSwapMutation.cpp
t_eoShiftMutation_SOURCES = t-eoShiftMutation.cpp
t_eoTwoOptMutation_SOURCES = t-eoTwoOptMutation.cpp
t_eoRingTopology_SOURCES = t-eoRingTopology.cpp

View file

@ -9,7 +9,6 @@
typedef EO<float> Chrom; typedef EO<float> Chrom;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
int main() int main()
{ {
Chrom chrom1, chrom2; Chrom chrom1, chrom2;
@ -17,6 +16,7 @@ int main()
std::cout << "chrom1 = " << chrom1 << std::endl std::cout << "chrom1 = " << chrom1 << std::endl
<< "chrom2 = " << chrom2 << std::endl; << "chrom2 = " << chrom2 << std::endl;
return 0; return 0;
} }

View file

@ -2,6 +2,7 @@
#include <eo> #include <eo>
#include <moo/eoEpsMOEA.h> #include <moo/eoEpsMOEA.h>
#include <utils/eoFuncPtrStat.h>
using namespace std; using namespace std;
@ -133,6 +134,17 @@ class Init : public eoInit<eoDouble>
} }
}; };
template <class EOT>
unsigned get_size(const eoPop<EOT>& pop) {
return pop.size();
}
template <class EOT>
unsigned counter(const eoPop<EOT>& pop) {
static unsigned c = 0;
return c++;
}
// Test pareto dominance and perf2worth, and while you're at it, test the eoGnuPlot monitor as well // Test pareto dominance and perf2worth, and while you're at it, test the eoGnuPlot monitor as well
void the_main(int argc, char* argv[]) void the_main(int argc, char* argv[])
{ {
@ -175,6 +187,19 @@ void the_main(int argc, char* argv[])
snapshot.add(fitness0); snapshot.add(fitness0);
snapshot.add(fitness1); snapshot.add(fitness1);
eoGnuplot1DMonitor monitor("sizemon");
cp.add(monitor);
eoFuncPtrStat<eoDouble, unsigned> size(get_size<eoDouble>);
eoFuncPtrStat<eoDouble, unsigned> counterStat(counter<eoDouble>);
monitor.add(counterStat);
monitor.add(size);
cp.add(size);
cp.add(counterStat);
// the algo // the algo
eoEpsMOEA<eoDouble> ea(cp, eval, opsel, MinimizingFitnessTraits::eps ); eoEpsMOEA<eoDouble> ea(cp, eval, opsel, MinimizingFitnessTraits::eps );