EvolvingObjects
replacement.cpp
00001 /*
00002     PyEO
00003 
00004     Copyright (C) 2003 Maarten Keijzer
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 */
00020 
00021 #include <eoReplacement.h>
00022 #include <eoMergeReduce.h>
00023 #include <eoReduceMerge.h>
00024 #include <eoReduceMergeReduce.h>
00025 #include <eoMGGReplacement.h>
00026 
00027 #include "PyEO.h"
00028 #include "def_abstract_functor.h"
00029 
00030 using namespace boost::python;
00031 
00032 #define DEF(x) class_<x<PyEO>, bases<eoReplacement<PyEO > > >(#x).def("__call__", &eoReplacement<PyEO>::operator())
00033 #define DEF2(x, i1) class_<x<PyEO>, bases<eoReplacement<PyEO > > >(#x, init<i1>() ).def("__call__", &eoReplacement<PyEO>::operator())
00034 #define DEF3(x, i1, i2) class_<x<PyEO>, bases<eoReplacement<PyEO > > >  \
00035     (#x,                                                                \
00036      init<i1, i2 >() [WC2])                                             \
00037     .def("__call__", &eoReplacement<PyEO>::operator())
00038 
00039 void replacement()
00040 {
00041     def_abstract_functor<eoReplacement<PyEO> >("eoReplacement");
00042 
00043     // eoReplacement.h
00044     DEF(eoGenerationalReplacement);
00045 
00046     class_<eoWeakElitistReplacement<PyEO>, bases<eoReplacement<PyEO> > >
00047         ("eoWeakElitistReplacement",
00048          init< eoReplacement<PyEO>& >()[WC1]);
00049 
00050     // eoMergeReduce.h
00051     DEF3(eoMergeReduce, eoMerge<PyEO>&, eoReduce<PyEO>& );
00052     DEF(eoPlusReplacement);
00053     DEF(eoCommaReplacement);
00054     DEF2(eoEPReplacement, unsigned);
00055 
00056     // eoReduceMerge.h
00057     DEF3(eoReduceMerge, eoReduce<PyEO>&, eoMerge<PyEO>& );
00058     DEF(eoSSGAWorseReplacement);
00059     DEF2(eoSSGADetTournamentReplacement, unsigned);
00060     DEF2(eoSSGAStochTournamentReplacement, double);
00061 
00062     // eoReduceMergeReduce.h
00063     //class_<eoReduceMergeReduce<PyEO>, bases<eoReplacement<PyEO> > >("eoReplacement",
00064     //      init<eoHowMany, bool, eoHowMany, eoReduce<PyEO>&,
00065     //           eoHowMany, eoReduce<PyEO>&, eoReduce<PyEO>&>())
00066     //  .def("__call__", &eoReplacement<PyEO>::operator());
00067 
00068     //eoMGGReplacement
00069     DEF(eoMGGReplacement)
00070         .def( init<eoHowMany>() )
00071         .def( init<eoHowMany, unsigned>() );
00072 }
 All Classes Namespaces Files Functions Variables Typedefs Friends