# 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 > > >(#x, \
    00035         init<i1, i2 >() [WC2])\
    00036     .def("__call__", &eoReplacement<PyEO>::operator())
    00037
    00038 void replacement()
    00039 {
    00040     def_abstract_functor<eoReplacement<PyEO> >("eoReplacement");
    00041
    00042     // eoReplacement.h
    00043     DEF(eoGenerationalReplacement);
    00044
    00045     class_<eoWeakElitistReplacement<PyEO>, bases<eoReplacement<PyEO> > >
    00046         ("eoWeakElitistReplacement",
    00047          init< eoReplacement<PyEO>& >()[WC1]);
    00048
    00049     // eoMergeReduce.h
    00050     DEF3(eoMergeReduce, eoMerge<PyEO>&, eoReduce<PyEO>& );
    00051     DEF(eoPlusReplacement);
    00052     DEF(eoCommaReplacement);
    00053     DEF2(eoEPReplacement, unsigned);
    00054
    00055     // eoReduceMerge.h
    00056     DEF3(eoReduceMerge, eoReduce<PyEO>&, eoMerge<PyEO>& );
    00057     DEF(eoSSGAWorseReplacement);
    00058     DEF2(eoSSGADetTournamentReplacement, unsigned);
    00059     DEF2(eoSSGAStochTournamentReplacement, double);
    00060
    00061     // eoReduceMergeReduce.h
    00062     //class_<eoReduceMergeReduce<PyEO>, bases<eoReplacement<PyEO> > >("eoReplacement",
    00063 //          init<eoHowMany, bool, eoHowMany, eoReduce<PyEO>&,
    00064 //               eoHowMany, eoReduce<PyEO>&, eoReduce<PyEO>&>())
    00065 //      .def("__call__", &eoReplacement<PyEO>::operator());
    00066
    00067     //eoMGGReplacement
    00068     DEF(eoMGGReplacement)
    00069         .def( init<eoHowMany>() )
    00070         .def( init<eoHowMany, unsigned>() );
    00071 }
    00072