* indentations + whitespace cleanup

This commit is contained in:
Caner Candan 2011-05-05 16:54:00 +02:00
commit 56c6edab04
285 changed files with 6068 additions and 6223 deletions

View file

@ -11,13 +11,14 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
SET(EO_LIB_OUTPUT_PATH ${EO_BINARY_DIR}/lib) SET(EO_LIB_OUTPUT_PATH ${EO_BINARY_DIR}/lib)
SET(LIBRARY_OUTPUT_PATH ${EO_LIB_OUTPUT_PATH}) SET(LIBRARY_OUTPUT_PATH ${EO_LIB_OUTPUT_PATH})
SET (EO_SOURCES eoFunctorStore.cpp SET(EO_SOURCES
eoFunctorStore.cpp
eoPersistent.cpp eoPersistent.cpp
eoPrintable.cpp eoPrintable.cpp
eoCtrlCContinue.cpp eoCtrlCContinue.cpp
eoScalarFitnessAssembled.cpp eoScalarFitnessAssembled.cpp
eoSIGContinue.cpp) eoSIGContinue.cpp
)
ADD_LIBRARY(eo STATIC ${EO_SOURCES}) ADD_LIBRARY(eo STATIC ${EO_SOURCES})
INSTALL(TARGETS eo ARCHIVE DESTINATION lib COMPONENT libraries) INSTALL(TARGETS eo ARCHIVE DESTINATION lib COMPONENT libraries)
@ -42,6 +43,6 @@ ADD_SUBDIRECTORY(ga)
ADD_SUBDIRECTORY(gp) ADD_SUBDIRECTORY(gp)
ADD_SUBDIRECTORY(other) ADD_SUBDIRECTORY(other)
ADD_SUBDIRECTORY(utils) ADD_SUBDIRECTORY(utils)
ADD_SUBDIRECTORY(pyeo)
###################################################################################### ######################################################################################

View file

@ -171,4 +171,3 @@ private:
#endif #endif
/** @} */ /** @} */

View file

@ -570,4 +570,3 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoValu
#endif #endif

View file

@ -80,4 +80,3 @@ virtual bool operator()(EOT& , EOT& ) {return false;}
#endif #endif
/** @} */ /** @} */

View file

@ -90,4 +90,3 @@ private:
}; };
#endif #endif

View file

@ -90,4 +90,3 @@ std::vector<double> rates;
}; };
#endif #endif

View file

@ -207,4 +207,3 @@ protected:
}; };
#endif /*EOCONSTRICTEDVARIABLEWEIGHTVELOCITY_H*/ #endif /*EOCONSTRICTEDVARIABLEWEIGHTVELOCITY_H*/

View file

@ -197,4 +197,3 @@ protected:
#endif /*EOCONSTRICTEDVELOCITY_H */ #endif /*EOCONSTRICTEDVELOCITY_H */

View file

@ -68,4 +68,3 @@ public:
}; };
#endif #endif

View file

@ -84,4 +84,3 @@ public:
#endif #endif
/** @} */ /** @} */

View file

@ -71,4 +71,3 @@ template <class EOT> class eoDetTournamentSelect: public eoSelectOne<EOT>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#endif #endif

View file

@ -314,4 +314,3 @@ protected:
/** @} */ /** @} */
#endif // _eoDualFitness_h_ #endif // _eoDualFitness_h_

View file

@ -44,4 +44,3 @@ template<class EOT> class eoEDA: public eoUF<eoDistribution<EOT>&, void>
}; };
#endif #endif

View file

@ -303,4 +303,3 @@ Example of a test program building an EA algorithm.
*/ */
#endif #endif

View file

@ -84,4 +84,3 @@ private :
}; };
#endif // __eoEvalCounterThrowException_h__ #endif // __eoEvalCounterThrowException_h__

View file

@ -65,4 +65,3 @@ struct eoEvalFuncPtr: public eoEvalFunc<EOT> {
}; };
#endif #endif

View file

@ -211,4 +211,3 @@ protected:
* Example of a test program using this class: * Example of a test program using this class:
*/ */
#endif /*eoExtendedVelocity_H */ #endif /*eoExtendedVelocity_H */

View file

@ -53,4 +53,3 @@ private :
}; };
#endif #endif

View file

@ -189,4 +189,3 @@ protected:
#endif /*EOFIXEDINERTIAWEIGHTEDVELOCITY_H */ #endif /*EOFIXEDINERTIAWEIGHTEDVELOCITY_H */

View file

@ -112,4 +112,3 @@ private:
}; };
#endif #endif

View file

@ -105,4 +105,3 @@ class eoGeneralBreeder: public eoBreed<EOT>
}; };
#endif #endif

View file

@ -145,4 +145,3 @@ class eoDummy : public eoUF<POT&, void>
#endif #endif
/** @} */ /** @} */

View file

@ -193,4 +193,3 @@ protected:
#endif /*EOINTEGERVELOCITY_H */ #endif /*EOINTEGERVELOCITY_H */

View file

@ -215,11 +215,3 @@ protected:
}; };
#endif /*EOLINEARTOPOLOGY_H_ */ #endif /*EOLINEARTOPOLOGY_H_ */

View file

@ -55,14 +55,3 @@ public:
#endif /* EONEIGHBORHOOD_H_ */ #endif /* EONEIGHBORHOOD_H_ */

View file

@ -73,4 +73,3 @@ class eoObject
}; };
#endif #endif

View file

@ -119,4 +119,3 @@ class eoOneToOneBreeder: public eoBreed<EOT>
}; };
#endif #endif

View file

@ -166,4 +166,3 @@ public:
#endif #endif

View file

@ -80,4 +80,3 @@ public:
#endif /*_EOPARTICLEBESTINIT_H */ #endif /*_EOPARTICLEBESTINIT_H */
/** @} */ /** @} */

View file

@ -153,4 +153,3 @@ template <class POT> class eoParticleInitializer : public eoInitializerBase <POT
#endif /*_eoParticleFullInitializer_H*/ #endif /*_eoParticleFullInitializer_H*/
/** @} */ /** @} */

View file

@ -53,4 +53,3 @@ private:
}; };
#endif #endif

View file

@ -337,4 +337,3 @@ public:
}; };
#endif #endif

View file

@ -105,4 +105,3 @@ private:
}; };
#endif #endif

View file

@ -209,4 +209,3 @@ private:
}; };
#endif #endif

View file

@ -19,4 +19,3 @@ std::ostream & operator << ( std::ostream& _os, const eoPrintable& _o ) {
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View file

@ -60,4 +60,3 @@ class eoPrintable
std::ostream & operator << ( std::ostream& _os, const eoPrintable& _o ); std::ostream & operator << ( std::ostream& _os, const eoPrintable& _o );
#endif #endif

View file

@ -91,4 +91,3 @@ private:
}; };
#endif #endif

View file

@ -121,4 +121,3 @@ class eoSTLBF : public std::binary_function<A1, A2, R>
/** @} */ /** @} */
#endif #endif

View file

@ -36,6 +36,3 @@
// need to allocate the static variables of class eoScalarFitnessAssembledTraits // need to allocate the static variables of class eoScalarFitnessAssembledTraits
std::vector<std::string> eoScalarFitnessAssembledTraits::TermDescriptions; std::vector<std::string> eoScalarFitnessAssembledTraits::TermDescriptions;

View file

@ -282,4 +282,3 @@ std::istream& operator>>(std::istream& is, eoScalarFitnessAssembled<F, Cmp, Fitn
/** @} */ /** @} */
#endif #endif

View file

@ -74,4 +74,3 @@ public:
*/ */
#endif #endif

View file

@ -229,4 +229,3 @@ private:
}; };
#endif #endif

View file

@ -89,4 +89,3 @@ template<class EOT> class eoShiftMutation: public eoMonOp<EOT>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#endif #endif

View file

@ -104,4 +104,3 @@ template<class EOT> class eoSimpleEDA: public eoEDA<EOT>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#endif #endif

View file

@ -123,4 +123,3 @@ protected:
#endif /* EOSOCIALNEIGHBORHOOD_H_ */ #endif /* EOSOCIALNEIGHBORHOOD_H_ */

View file

@ -193,4 +193,3 @@ protected:
#endif /*EOSTANDARDVELOCITY_H */ #endif /*EOSTANDARDVELOCITY_H */

View file

@ -139,11 +139,3 @@ protected:
}; };
#endif /*EOSTARTOPOLOGY_H_ */ #endif /*EOSTARTOPOLOGY_H_ */

View file

@ -117,4 +117,3 @@ private:
}; };
#endif #endif

View file

@ -65,4 +65,3 @@ private:
}; };
#endif #endif

View file

@ -195,4 +195,3 @@ private :
/** @} */ /** @} */
#endif #endif

View file

@ -80,4 +80,3 @@ template<class Chrom> class eoSwapMutation: public eoMonOp<Chrom>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#endif #endif

View file

@ -84,11 +84,3 @@ public:
#endif /*EOTOPOLOGY_H_ */ #endif /*EOTOPOLOGY_H_ */

View file

@ -196,4 +196,3 @@ protected:
}; };
#endif /*EOVARIABLEINERTIAWEIGHTEDVELOCITY_H*/ #endif /*EOVARIABLEINERTIAWEIGHTEDVELOCITY_H*/

View file

@ -350,4 +350,3 @@ private:
/** @} */ /** @} */
#endif #endif

View file

@ -158,4 +158,3 @@ private:
/** @} */ /** @} */
#endif #endif

View file

@ -78,4 +78,3 @@ public:
}; };
#endif /*EOVELOCITY_H_H */ #endif /*EOVELOCITY_H_H */

View file

@ -144,4 +144,3 @@ private:
#endif /*EOVELOCITYINIT_H */ #endif /*EOVELOCITYINIT_H */
/** @} */ /** @} */

View file

@ -1,4 +1,3 @@
/* /*
* C++ification of Nikolaus Hansen's original C-source code for the * C++ification of Nikolaus Hansen's original C-source code for the
* CMA-ES * CMA-ES

View file

@ -49,4 +49,3 @@ class CMAParams {
} // namespace eo } // namespace eo
#endif #endif

View file

@ -362,4 +362,3 @@ bool CMAState::updateEigenSystem(unsigned max_tries, unsigned max_iters) { retur
} // namespace eo } // namespace eo

View file

@ -1,4 +1,3 @@
/* /*
* C++ification of Nikolaus Hansen's original C-source code for the * C++ification of Nikolaus Hansen's original C-source code for the
* CMA-ES. * CMA-ES.

View file

@ -1,4 +1,3 @@
/* /*
* C++ification of Nikolaus Hansen's original C-source code for the * C++ification of Nikolaus Hansen's original C-source code for the
* CMA-ES. These are the eigenvector calculations * CMA-ES. These are the eigenvector calculations

View file

@ -279,4 +279,3 @@ private:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
//@} //@}
#endif #endif

View file

@ -68,4 +68,3 @@ class eoRealInitBounded : public eoInit<EOT>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
//@} //@}
#endif #endif

View file

@ -133,5 +133,3 @@ protected:
double eta; double eta;
double range; // == 1 double range; // == 1
}; };

View file

@ -82,4 +82,3 @@ eoAlgo<eoEsFull<eoMinimizingFitness> >& make_algo_scalar(eoParser& _parser, eoS
{ {
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op); return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
} }

View file

@ -58,4 +58,3 @@ eoAlgo<eoReal<eoMinimizingFitness> >& make_algo_scalar(eoParser& _parser, eoSta
{ {
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op, _dist); return do_make_algo_scalar(_parser, _state, _eval, _continue, _op, _dist);
} }

View file

@ -79,5 +79,3 @@ eoCheckPoint<eoEsFull<eoMinimizingFitness> >& make_checkpoint(eoParser& _parser,
{ {
return do_make_checkpoint(_parser, _state, _eval, _continue); return do_make_checkpoint(_parser, _state, _eval, _continue);
} }

View file

@ -57,5 +57,3 @@ eoCheckPoint<eoReal<eoMinimizingFitness> >& make_checkpoint(eoParser& _parser, e
{ {
return do_make_checkpoint(_parser, _state, _eval, _continue); return do_make_checkpoint(_parser, _state, _eval, _continue);
} }

View file

@ -79,5 +79,3 @@ eoContinue<eoEsFull<eoMinimizingFitness> >& make_continue(eoParser& _parser, eoS
{ {
return do_make_continue(_parser, _state, _eval); return do_make_continue(_parser, _state, _eval);
} }

View file

@ -57,5 +57,3 @@ eoContinue<eoReal<eoMinimizingFitness> >& make_continue(eoParser& _parser, eoSta
{ {
return do_make_continue(_parser, _state, _eval); return do_make_continue(_parser, _state, _eval);
} }

View file

@ -77,4 +77,3 @@ eoGenOp<eoEsFull<eoMinimizingFitness> >& make_op(eoParser& _parser, eoState& _s
{ {
return do_make_op(_parser, _state, _init); return do_make_op(_parser, _state, _init);
} }

View file

@ -82,5 +82,3 @@ eoPop<eoEsFull<eoMinimizingFitness> >& make_pop(eoParser& _parser, eoState& _st
{ {
return do_make_pop(_parser, _state, _init); return do_make_pop(_parser, _state, _init);
} }

View file

@ -58,5 +58,3 @@ eoPop<eoReal<eoMinimizingFitness> >& make_pop(eoParser& _parser, eoState& _stat
{ {
return do_make_pop(_parser, _state, _init); return do_make_pop(_parser, _state, _init);
} }

View file

@ -84,4 +84,3 @@ void run_ea(eoAlgo<eoEsFull<eoMinimizingFitness> >& _ga, eoPop<eoEsFull<eoMinimi
{ {
do_run(_ga, _pop); do_run(_ga, _pop);
} }

View file

@ -60,4 +60,3 @@ void run_ea(eoAlgo<eoReal<eoMinimizingFitness> >& _ga, eoPop<eoReal<eoMinimizing
{ {
do_run(_ga, _pop); do_run(_ga, _pop);
} }

View file

@ -43,4 +43,3 @@ class square_matrix {
}; };
#endif #endif

View file

@ -18,4 +18,3 @@ that constructs the EOType initializer (make_genotype.h) and the one
that buils up the operators (make_op.h). that buils up the operators (make_op.h).
MS, April 23, 2001CVS MS, April 23, 2001CVS

View file

@ -442,4 +442,3 @@ template<class Chrom> class eoBitGxOver: public eoQuadOp<Chrom>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
//@} //@}
#endif #endif

View file

@ -170,4 +170,3 @@ public:
#endif #endif

View file

@ -61,4 +61,3 @@ eoAlgo<eoBit<eoMinimizingFitness> >& make_algo_scalar(eoParser& _parser, eoStat
{ {
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op, _dist); return do_make_algo_scalar(_parser, _state, _eval, _continue, _op, _dist);
} }

View file

@ -60,5 +60,3 @@ eoCheckPoint<eoBit<eoMinimizingFitness> >& make_checkpoint(eoParser& _parser, eo
{ {
return do_make_checkpoint(_parser, _state, _eval, _continue); return do_make_checkpoint(_parser, _state, _eval, _continue);
} }

View file

@ -60,5 +60,3 @@ eoContinue<eoBit<eoMinimizingFitness> >& make_continue(eoParser& _parser, eoStat
{ {
return do_make_continue(_parser, _state, _eval); return do_make_continue(_parser, _state, _eval);
} }

View file

@ -59,4 +59,3 @@ eoGenOp<eoBit<eoMinimizingFitness> >& make_op(eoParser& _parser, eoState& _stat
{ {
return do_make_op(_parser, _state, _init); return do_make_op(_parser, _state, _init);
} }

View file

@ -59,5 +59,3 @@ eoPop<eoBit<eoMinimizingFitness> >& make_pop(eoParser& _parser, eoState& _state
{ {
return do_make_pop(_parser, _state, _init); return do_make_pop(_parser, _state, _init);
} }

View file

@ -63,4 +63,3 @@ void run_ea(eoAlgo<eoBit<eoMinimizingFitness> >& _ga, eoPop<eoBit<eoMinimizingFi
{ {
do_run(_ga, _pop); do_run(_ga, _pop);
} }

View file

@ -82,4 +82,3 @@ public:
}; };
#endif #endif

View file

@ -33,5 +33,3 @@ eoFunctorStore.o: ../eoFunctorStore.h ../eoFunctorStore.cpp
%.o:%.cpp PyEO.h def_abstract_functor.h %.o:%.cpp PyEO.h def_abstract_functor.h
$(COMPILE) $< $(INC) $(COMPILE) $< $(INC)

View file

@ -27,5 +27,3 @@ eoFunctorStore.o: ../eoFunctorStore.h ../eoFunctorStore.cpp
%.o:%.cpp PyEO.h def_abstract_functor.h %.o:%.cpp PyEO.h def_abstract_functor.h
$(COMPILE) $< $(INC) $(COMPILE) $< $(INC)

View file

@ -21,14 +21,15 @@
#ifndef PYEO_H #ifndef PYEO_H
#define PYEO_H #define PYEO_H
#include <string> #include <string>
#include <vector> #include <vector>
#include <exception> #include <exception>
#include <boost/python.hpp> #include <boost/python.hpp>
#include <EO.h> #include <EO.h>
struct index_error : public std::exception {
struct index_error : public std::exception
{
index_error(std::string w) : what(w) {}; index_error(std::string w) : what(w) {};
virtual ~index_error() throw() {} virtual ~index_error() throw() {}
std::string what; std::string what;
@ -36,7 +37,7 @@ struct index_error : public std::exception {
class PyFitness : public boost::python::object class PyFitness : public boost::python::object
{ {
public : public :
typedef PyFitness fitness_traits; // it's its own traits class :-) typedef PyFitness fitness_traits; // it's its own traits class :-)
@ -140,13 +141,12 @@ struct PyEO_pickle_suite : boost::python::pickle_suite
{ {
typedef PyEO::Fitness Fitness; typedef PyEO::Fitness Fitness;
static static boost::python::tuple getstate(const PyEO& _eo)
boost::python::tuple getstate(const PyEO& _eo)
{ {
return boost::python::make_tuple(_eo.getFitness(), _eo.genome); return boost::python::make_tuple(_eo.getFitness(), _eo.genome);
} }
static
void setstate(PyEO& _eo, boost::python::tuple pickled) static void setstate(PyEO& _eo, boost::python::tuple pickled)
{ {
_eo.setFitness( Fitness(pickled[0]) ); _eo.setFitness( Fitness(pickled[0]) );
_eo.genome = pickled[1]; _eo.genome = pickled[1];

View file

@ -1,4 +1,3 @@
from PyEO import * from PyEO import *
try: try:
@ -15,7 +14,6 @@ else:
self.g = Gnuplot.Gnuplot() self.g = Gnuplot.Gnuplot()
self.g.reset(); self.g.reset();
def handleParam(self, i, param): def handleParam(self, i, param):
param = float(param) param = float(param)
@ -25,7 +23,6 @@ else:
self.values[i].append(param) self.values[i].append(param)
def __call__(self): def __call__(self):
l = len(self) l = len(self)
if l > 3 or l == 0: if l > 3 or l == 0:
@ -82,6 +79,5 @@ class eoAverageStat(eoStat):
self.object = sum self.object = sum
class eoBestFitnessStat(eoSortedStat): class eoBestFitnessStat(eoSortedStat):
def __call__(self, pop): def __call__(self, pop):
self.object = pop[0].fitness self.object = pop[0].fitness

View file

@ -37,9 +37,15 @@ void abstract1()
def_abstract_functor<eoTransform<PyEO> >("eoTransform"); def_abstract_functor<eoTransform<PyEO> >("eoTransform");
class_<eoSGATransform<PyEO>, bases<eoTransform<PyEO> > >("eoSGATransform", class_<eoSGATransform<PyEO>, bases<eoTransform<PyEO> > >
init< eoQuadOp<PyEO>&, double, ("eoSGATransform",
eoMonOp<PyEO>&, double>()) init<
eoQuadOp<PyEO>&,
double,
eoMonOp<PyEO>&,
double
>()
)
.def("__call__", &eoSGATransform<PyEO>::operator()); .def("__call__", &eoSGATransform<PyEO>::operator());
def_abstract_functor<eoPopEvalFunc<PyEO> >("eoPopEvalFunc"); def_abstract_functor<eoPopEvalFunc<PyEO> >("eoPopEvalFunc");

View file

@ -33,12 +33,17 @@ void algos()
def_abstract_functor<eoAlgo<PyEO> >("eoAlgo"); def_abstract_functor<eoAlgo<PyEO> >("eoAlgo");
/* Algorithms */ /* Algorithms */
class_<eoSGA<PyEO>, bases<eoAlgo<PyEO> >, boost::noncopyable>("eoSGA", class_<eoSGA<PyEO>, bases<eoAlgo<PyEO> >, boost::noncopyable>
init<eoSelectOne<PyEO>&, ("eoSGA",
eoQuadOp<PyEO>&, float, init<
eoMonOp<PyEO>&, float, eoSelectOne<PyEO>&,
eoQuadOp<PyEO>&,
float,
eoMonOp<PyEO>&,
float,
eoEvalFunc<PyEO>&, eoEvalFunc<PyEO>&,
eoContinue<PyEO>&>() eoContinue<PyEO>&
>()
[ [
with_custodian_and_ward<1,2, with_custodian_and_ward<1,2,
with_custodian_and_ward<1,3, with_custodian_and_ward<1,3,
@ -49,40 +54,55 @@ void algos()
> >
> >
>() >()
]) ]
)
.def("__call__", &eoSGA<PyEO>::operator()) .def("__call__", &eoSGA<PyEO>::operator())
; ;
class_<eoEasyEA<PyEO>, bases<eoAlgo<PyEO> > >("eoEasyEA", class_<eoEasyEA<PyEO>, bases<eoAlgo<PyEO> > >
("eoEasyEA",
init< init<
eoContinue<PyEO>&, eoContinue<PyEO>&,
eoEvalFunc<PyEO>&, eoEvalFunc<PyEO>&,
eoBreed<PyEO>&, eoBreed<PyEO>&,
eoReplacement<PyEO>& >() ) eoReplacement<PyEO>&
>()
)
.def( init<
eoContinue<PyEO>&,
eoEvalFunc<PyEO>&,
eoBreed<PyEO>&,
eoReplacement<PyEO>&,
unsigned
>() )
.def( init< .def( init<
eoContinue<PyEO>&, eoContinue<PyEO>&,
eoPopEvalFunc<PyEO>&, eoPopEvalFunc<PyEO>&,
eoBreed<PyEO>&, eoBreed<PyEO>&,
eoReplacement<PyEO>&>() ) eoReplacement<PyEO>&
>() )
.def( init< .def( init<
eoContinue<PyEO>&, eoContinue<PyEO>&,
eoEvalFunc<PyEO>&, eoEvalFunc<PyEO>&,
eoBreed<PyEO>&, eoBreed<PyEO>&,
eoMerge<PyEO>&, eoMerge<PyEO>&,
eoReduce<PyEO>& >() ) eoReduce<PyEO>&
>() )
.def( init< .def( init<
eoContinue<PyEO>&, eoContinue<PyEO>&,
eoEvalFunc<PyEO>&, eoEvalFunc<PyEO>&,
eoSelect<PyEO>&, eoSelect<PyEO>&,
eoTransform<PyEO>&, eoTransform<PyEO>&,
eoReplacement<PyEO>&>()) eoReplacement<PyEO>&
>() )
.def( init< .def( init<
eoContinue<PyEO>&, eoContinue<PyEO>&,
eoEvalFunc<PyEO>&, eoEvalFunc<PyEO>&,
eoSelect<PyEO>&, eoSelect<PyEO>&,
eoTransform<PyEO>&, eoTransform<PyEO>&,
eoMerge<PyEO>&, eoMerge<PyEO>&,
eoReduce<PyEO>&>()) eoReduce<PyEO>&
>() )
.def("__call__", &eoEasyEA<PyEO>::operator()) .def("__call__", &eoEasyEA<PyEO>::operator())
; ;

View file

@ -27,8 +27,18 @@
using namespace boost::python; using namespace boost::python;
#define DEF3(x, i1, i2) class_<x<PyEO>, bases<eoBreed<PyEO > > >(#x, \ #define DEF3(x, i1, i2) \
init<i1, i2 >()[with_custodian_and_ward<1,2,with_custodian_and_ward<1,3> >()])\ class_<x<PyEO>, bases<eoBreed<PyEO > > > \
(#x, \
init<i1, i2 >() \
[ \
with_custodian_and_ward<1,2, \
with_custodian_and_ward<1,3 \
> \
> \
() \
] \
) \
.def("__call__", &eoBreed<PyEO>::operator()) .def("__call__", &eoBreed<PyEO>::operator())
void breeders() void breeders()
@ -46,6 +56,4 @@ void breeders()
DEF3(eoOneToOneBreeder, eoGenOp<PyEO>&, eoEvalFunc<PyEO>&) DEF3(eoOneToOneBreeder, eoGenOp<PyEO>&, eoEvalFunc<PyEO>&)
.def( init<eoGenOp<PyEO>&, eoEvalFunc<PyEO>&, double>()[WC2] ) .def( init<eoGenOp<PyEO>&, eoEvalFunc<PyEO>&, double>()[WC2] )
.def( init<eoGenOp<PyEO>&, eoEvalFunc<PyEO>&, double, eoHowMany>()[WC2] ); .def( init<eoGenOp<PyEO>&, eoEvalFunc<PyEO>&, double, eoHowMany>()[WC2] );
} }

View file

@ -41,25 +41,31 @@ void continuators()
{ {
/* Counters, wrappers etc */ /* Counters, wrappers etc */
class_<eoEvalFuncCounter<PyEO>, bases<eoEvalFunc<PyEO> > >("eoEvalFuncCounter", class_<eoEvalFuncCounter<PyEO>, bases<eoEvalFunc<PyEO> > >
init< eoEvalFunc<PyEO>&, std::string>()) ("eoEvalFuncCounter",
init< eoEvalFunc<PyEO>&, std::string>()
)
.def("__call__", &eoEvalFuncCounter<PyEO>::operator()) .def("__call__", &eoEvalFuncCounter<PyEO>::operator())
; ;
/* Continuators */ /* Continuators */
def_abstract_functor<eoContinue<PyEO> >("eoContinue"); def_abstract_functor<eoContinue<PyEO> >("eoContinue");
class_<eoGenContinue<PyEO>, bases<eoContinue<PyEO> >, boost::noncopyable >("eoGenContinue", init<unsigned long>() ) class_<eoGenContinue<PyEO>, bases<eoContinue<PyEO> >, boost::noncopyable >
("eoGenContinue", init<unsigned long>() )
.def("__call__", &eoGenContinue<PyEO>::operator()) .def("__call__", &eoGenContinue<PyEO>::operator())
; ;
class_<eoCombinedContinue<PyEO>, bases<eoContinue<PyEO> > >("eoCombinedContinue", init<eoContinue<PyEO>&>()[WC1]) class_<eoCombinedContinue<PyEO>, bases<eoContinue<PyEO> > >
("eoCombinedContinue", init<eoContinue<PyEO>&>()[WC1])
.def( init<eoContinue<PyEO>&, eoContinue<PyEO>& >()[WC2] ) .def( init<eoContinue<PyEO>&, eoContinue<PyEO>& >()[WC2] )
.def("add", &eoCombinedContinue<PyEO>::add, WC1) .def("add", &eoCombinedContinue<PyEO>::add, WC1)
.def("__call__", &eoCombinedContinue<PyEO>::operator()) .def("__call__", &eoCombinedContinue<PyEO>::operator())
; ;
class_<eoEvalContinue<PyEO>, bases<eoContinue<PyEO> > >("eoEvalContinue", class_<eoEvalContinue<PyEO>, bases<eoContinue<PyEO> > >
init<eoEvalFuncCounter<PyEO>&, unsigned long>()[WC1]) ("eoEvalContinue",
init<eoEvalFuncCounter<PyEO>&, unsigned long>()[WC1]
)
.def("__call__", &eoEvalContinue<PyEO>::operator()) .def("__call__", &eoEvalContinue<PyEO>::operator())
; ;
@ -77,8 +83,8 @@ void addSortedStat(eoCheckPoint<PyEO>& c, eoSortedStatBase<PyEO>& s) { c.add(s);
void add_checkpoint() void add_checkpoint()
{ {
class_<eoCheckPoint<PyEO>, bases< eoContinue<PyEO> > >("eoCheckPoint", class_<eoCheckPoint<PyEO>, bases< eoContinue<PyEO> > >
("eoCheckPoint",
init<eoContinue<PyEO>&> ()[with_custodian_and_ward<1,2>()] init<eoContinue<PyEO>&> ()[with_custodian_and_ward<1,2>()]
) )
.def("add", addContinue, with_custodian_and_ward<1,2>() ) .def("add", addContinue, with_custodian_and_ward<1,2>() )

View file

@ -29,11 +29,11 @@
namespace eoutils { namespace eoutils {
using namespace boost::python; using namespace boost::python;
template <class Proc> template <class Proc>
class ProcWrapper : public Proc class ProcWrapper : public Proc
{ {
public: public:
PyObject* self; PyObject* self;
ProcWrapper(PyObject* s) : self(s) {} ProcWrapper(PyObject* s) : self(s) {}
@ -42,27 +42,27 @@ class ProcWrapper : public Proc
{ {
return boost::python::call_method<typename Proc::result_type>(self, "__call__"); return boost::python::call_method<typename Proc::result_type>(self, "__call__");
} }
}; };
template <class Proc> template <class Proc>
void make_abstract_functor(std::string name, typename eoFunctorBase::procedure_tag) void make_abstract_functor(std::string name, typename eoFunctorBase::procedure_tag)
{ {
typedef ProcWrapper<Proc> Wrapper; typedef ProcWrapper<Proc> Wrapper;
boost::python::class_<Proc, Wrapper,boost::noncopyable>(name.c_str(), boost::python::init<>() ) boost::python::class_<Proc, Wrapper,boost::noncopyable>(name.c_str(), boost::python::init<>() )
.def("__call__", &Wrapper::operator()); .def("__call__", &Wrapper::operator());
} }
template <class Proc> template <class Proc>
void make_abstract_functor_ref(std::string name, typename eoFunctorBase::procedure_tag) void make_abstract_functor_ref(std::string name, typename eoFunctorBase::procedure_tag)
{ {
typedef ProcWrapper<Proc> Wrapper; typedef ProcWrapper<Proc> Wrapper;
boost::python::class_<Proc, Wrapper,boost::noncopyable>(name.c_str(), boost::python::init<>() ) boost::python::class_<Proc, Wrapper,boost::noncopyable>(name.c_str(), boost::python::init<>() )
.def("__call__", &Wrapper::operator(), boost::python::return_internal_reference<>()); .def("__call__", &Wrapper::operator(), boost::python::return_internal_reference<>());
} }
template <class Unary> template <class Unary>
class UnaryWrapper : public Unary class UnaryWrapper : public Unary
{ {
public: public:
PyObject* self; PyObject* self;
UnaryWrapper(PyObject* s) : self(s) {} UnaryWrapper(PyObject* s) : self(s) {}
@ -71,31 +71,31 @@ class UnaryWrapper : public Unary
{ {
return boost::python::call_method<typename Unary::result_type>(self, "__call__", boost::ref(a) ); return boost::python::call_method<typename Unary::result_type>(self, "__call__", boost::ref(a) );
} }
}; };
template <class Unary> template <class Unary>
void make_abstract_functor(std::string name, typename eoFunctorBase::unary_function_tag) void make_abstract_functor(std::string name, typename eoFunctorBase::unary_function_tag)
{ {
typedef UnaryWrapper<Unary> Wrapper; typedef UnaryWrapper<Unary> Wrapper;
boost::python::class_<Unary, Wrapper, boost::noncopyable>(name.c_str(), boost::python::init<>() ) boost::python::class_<Unary, Wrapper, boost::noncopyable>(name.c_str(), boost::python::init<>() )
.def("__call__", &Wrapper::operator()) .def("__call__", &Wrapper::operator())
; ;
} }
template <class Unary> template <class Unary>
void make_abstract_functor_ref(std::string name, typename eoFunctorBase::unary_function_tag) void make_abstract_functor_ref(std::string name, typename eoFunctorBase::unary_function_tag)
{ {
typedef UnaryWrapper<Unary> Wrapper; typedef UnaryWrapper<Unary> Wrapper;
boost::python::class_<Unary, Wrapper, boost::noncopyable>(name.c_str(), boost::python::init<>() ) boost::python::class_<Unary, Wrapper, boost::noncopyable>(name.c_str(), boost::python::init<>() )
.def("__call__", &Wrapper::operator(), boost::python::return_internal_reference<>() ) .def("__call__", &Wrapper::operator(), boost::python::return_internal_reference<>() )
; ;
} }
template <class Binary> template <class Binary>
class BinaryWrapper : public Binary class BinaryWrapper : public Binary
{ {
public: public:
PyObject* self; PyObject* self;
BinaryWrapper(PyObject* s) : self(s) {} BinaryWrapper(PyObject* s) : self(s) {}
@ -104,23 +104,23 @@ class BinaryWrapper : public Binary
return boost::python::call_method< return boost::python::call_method<
typename Binary::result_type>(self, "__call__", boost::ref(a1), boost::ref(a2) ); typename Binary::result_type>(self, "__call__", boost::ref(a1), boost::ref(a2) );
} }
}; };
template <class Binary> template <class Binary>
void make_abstract_functor(std::string name, typename eoFunctorBase::binary_function_tag) void make_abstract_functor(std::string name, typename eoFunctorBase::binary_function_tag)
{ {
typedef BinaryWrapper<Binary> Wrapper; typedef BinaryWrapper<Binary> Wrapper;
boost::python::class_<Binary, Wrapper, boost::noncopyable>(name.c_str(), boost::python::init<>() ) boost::python::class_<Binary, Wrapper, boost::noncopyable>(name.c_str(), boost::python::init<>() )
.def("__call__", &Wrapper::operator()); .def("__call__", &Wrapper::operator());
} }
template <class Binary> template <class Binary>
void make_abstract_functor_ref(std::string name, typename eoFunctorBase::binary_function_tag) void make_abstract_functor_ref(std::string name, typename eoFunctorBase::binary_function_tag)
{ {
typedef BinaryWrapper<Binary> Wrapper; typedef BinaryWrapper<Binary> Wrapper;
boost::python::class_<Binary, Wrapper, boost::noncopyable>(name.c_str(), boost::python::init<>() ) boost::python::class_<Binary, Wrapper, boost::noncopyable>(name.c_str(), boost::python::init<>() )
.def("__call__", &Wrapper::operator(), boost::python::return_internal_reference<>() ); .def("__call__", &Wrapper::operator(), boost::python::return_internal_reference<>() );
} }
}// namespace eoutils }// namespace eoutils

View file

@ -31,7 +31,7 @@ using namespace boost::python;
class GenOpWrapper : public eoGenOp<PyEO> class GenOpWrapper : public eoGenOp<PyEO>
{ {
public: public:
PyObject* self; PyObject* self;
GenOpWrapper(PyObject* p) : self(p) {} GenOpWrapper(PyObject* p) : self(p) {}

View file

@ -38,4 +38,3 @@ void mergers()
DEF(eoPlus); DEF(eoPlus);
} }

View file

@ -26,7 +26,7 @@ using namespace boost::python;
class MonitorWrapper : public eoMonitor class MonitorWrapper : public eoMonitor
{ {
public: public:
PyObject* self; PyObject* self;
list objects; list objects;
@ -69,4 +69,3 @@ void monitors()
.def("__len__", &MonitorWrapper::size) .def("__len__", &MonitorWrapper::size)
; ;
} }

View file

@ -17,6 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include <eoNDSorting.h> #include <eoNDSorting.h>
#include "PyEO.h" #include "PyEO.h"
@ -32,7 +33,6 @@ struct Perf2WorthWrapper : public eoPerf2Worth<PyEO,double>
{ {
call_method<void>(self, "__call__", boost::ref(pop)); call_method<void>(self, "__call__", boost::ref(pop));
} }
}; };
numeric::array get_worths(eoPerf2Worth<PyEO, double>& p) numeric::array get_worths(eoPerf2Worth<PyEO, double>& p)
@ -61,8 +61,7 @@ void perf2worth()
{ {
//numeric::array::set_module_and_type("Numeric", "ArrayType"); //numeric::array::set_module_and_type("Numeric", "ArrayType");
class_< class_<eoPerf2Worth<PyEO, double>,
eoPerf2Worth<PyEO, double>,
Perf2WorthWrapper, Perf2WorthWrapper,
bases< eoValueParam<std::vector<double> > >, bases< eoValueParam<std::vector<double> > >,
boost::noncopyable>("eoPerf2Worth", init<>()) boost::noncopyable>("eoPerf2Worth", init<>())
@ -72,17 +71,19 @@ void perf2worth()
//.def("value", get_worths) //.def("value", get_worths)
; ;
class_<eoPerf2WorthCached<PyEO, double>, CachedPerf2WorthWrapper, bases<eoPerf2Worth<PyEO, double> >, boost::noncopyable> class_<eoPerf2WorthCached<PyEO, double>,
("eoPerf2WorthCached", init<>()) CachedPerf2WorthWrapper,
bases<eoPerf2Worth<PyEO, double> >,
boost::noncopyable>("eoPerf2WorthCached", init<>())
.def("__call__", &eoPerf2WorthCached<PyEO, double>::operator()) .def("__call__", &eoPerf2WorthCached<PyEO, double>::operator())
.def("calculate_worths", &CachedPerf2WorthWrapper::calculate_worths) .def("calculate_worths", &CachedPerf2WorthWrapper::calculate_worths)
; ;
//class_<eoNoPerf2Worth<PyEO>, bases<eoPerf2Worth<PyEO, double> > >("eoNoPerf2Worth") //class_<eoNoPerf2Worth<PyEO>, bases<eoPerf2Worth<PyEO, double> > >("eoNoPerf2Worth")
// .def("__call__", &eoNoPerf2Worth<PyEO>::operator()); // .def("__call__", &eoNoPerf2Worth<PyEO>::operator());
class_<eoNDSorting_II<PyEO>, bases<eoPerf2WorthCached<PyEO, double> > >("eoNDSorting_II") class_<eoNDSorting_II<PyEO>,
bases<eoPerf2WorthCached<PyEO, double> > >("eoNDSorting_II")
.def("calculate_worths", &eoNDSorting_II<PyEO>::calculate_worths); .def("calculate_worths", &eoNDSorting_II<PyEO>::calculate_worths);
} }

Some files were not shown because too many files have changed in this diff Show more