# eoSymInit.h

    00001 /*
    00002  *             Copyright (C) 2005 Maarten Keijzer
    00003  *
    00004  *          This program is free software; you can redistribute it and/or modify
    00005  *          it under the terms of version 2 of the GNU General Public License as
    00006  *          published by the Free Software Foundation.
    00007  *
    00008  *          This program is distributed in the hope that it will be useful,
    00009  *          but WITHOUT ANY WARRANTY; without even the implied warranty of
    00010  *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00011  *          GNU General Public License for more details.
    00012  *
    00013  *          You should have received a copy of the GNU General Public License
    00014  *          along with this program; if not, write to the Free Software
    00015  *          Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00016  */
    00017
    00018 #ifndef EOSYMINIT_H
    00019 #define EOSYMINIT_H
    00020
    00021 #include <eoInit.h>
    00022 #include <TreeBuilder.h>
    00023
    00025 template <class EoType>
    00026 class eoSymInit : public eoInit<EoType> {
    00027
    00028     TreeBuilder& builder;
    00029
    00030     double      own_grow_prob;
    00031     unsigned    own_max_depth;
    00032
    00033
    00034     double& grow_prob;
    00035     unsigned& max_depth;
    00036
    00037     public:
    00038
    00040         eoSymInit(TreeBuilder& _builder)
    00041         :   builder(_builder),
    00042             own_grow_prob(0.5),
    00043             own_max_depth(6),
    00044             grow_prob(own_grow_prob),
    00045             max_depth(own_max_depth)
    00046         {}
    00047
    00049         eoSymInit(TreeBuilder& _builder, double& _grow_prob, unsigned& _max_depth)
    00050         :   builder(_builder),
    00051             grow_prob(_grow_prob),
    00052             max_depth(_max_depth)
    00053         {}
    00054
    00056         void operator()(EoType& tree) {
    00057             int depth_to_use = rng.random(max_depth-2) + 2; // two levels minimum
    00058             builder.build_tree(tree, depth_to_use, rng.flip(grow_prob));
    00059         }
    00060
    00061 };
    00062
    00063 #endif
    00064