Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages | Search for

# TreeBuilder.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 TREEBUILDER_H_
    00019 #define TREEBUILDER_H_
    00020
    00021 #include "Sym.h"
    00022 #include "LanguageTable.h"
    00023
    00024 class TreeBuilder {
    00025     const LanguageTable& table;
    00026
    00027     // probability of selecting a var versus a const when the choice boils down to selecting a terminal
    00028     double vcprob;
    00029
    00030     Sym make_terminal() const;
    00031     public:
    00032
    00033     TreeBuilder(const LanguageTable& t) : table(t), vcprob(0.9) {};
    00034     TreeBuilder(const LanguageTable& t, double vc) : table(t), vcprob(vc) {};
    00035
    00036     void set_var_vs_const_probability(double p) { vcprob = p; }
    00037
    00038     Sym build_tree(unsigned max_depth, bool grow) const;
    00039
    00040     void build_tree(Sym& tree, unsigned max_depth, bool grow) const { tree = build_tree(max_depth, grow); }
    00041
    00042 };
    00043
    00044 #endif
    00045