the name of the eoGpDepthInitializer class (initializer for

parse_tree's has been changed to

eoParseTreeDepthInit but backward compatibility is maintained by
using a #define statement:

#define eoGpDepthInitializer eoParseTreeDepthInit

The initializer for strongly typed GP has been changed to
eoStParseTreeDepthInit

the gpsymreg application has been changed to use the new name
This commit is contained in:
jeggermo 2001-11-03 22:10:11 +00:00
commit 2d12525bc5
4 changed files with 39 additions and 37 deletions

View file

@ -71,7 +71,7 @@ int main(int argc, char *argv[])
RegFitness<FitnessType, Node > eval(generationCounter, initSequence, parameter); RegFitness<FitnessType, Node > eval(generationCounter, initSequence, parameter);
// Depth Initializor, defaults to grow method. // Depth Initializor, defaults to grow method.
eoGpDepthInitializer<FitnessType, Node> initializer(parameter.InitMaxDepth, initSequence); eoParseTreeDepthInit<FitnessType, Node> initializer(parameter.InitMaxDepth, initSequence);
// create the initial population // create the initial population
Pop pop(parameter.population_size, initializer); Pop pop(parameter.population_size, initializer);

View file

@ -12,23 +12,22 @@
# config.status only pays attention to the cache file if you give it the # config.status only pays attention to the cache file if you give it the
# --recheck option to rerun configure. # --recheck option to rerun configure.
# #
ac_cv_type_size_t=${ac_cv_type_size_t='yes'} ac_cv_c_const=${ac_cv_c_const=yes}
ac_cv_func_select=${ac_cv_func_select='yes'} ac_cv_c_inline=${ac_cv_c_inline=inline}
ac_cv_path_install=${ac_cv_path_install='/usr/bin/install -c'} ac_cv_func_select=${ac_cv_func_select=yes}
ac_cv_prog_CXX=${ac_cv_prog_CXX='c++'} ac_cv_header_limits_h=${ac_cv_header_limits_h=yes}
ac_cv_prog_RANLIB=${ac_cv_prog_RANLIB='ranlib'} ac_cv_header_stdc=${ac_cv_header_stdc=yes}
ac_cv_prog_cxx_cross=${ac_cv_prog_cxx_cross='no'} ac_cv_lib_eo_main=${ac_cv_lib_eo_main=no}
ac_cv_lib_eo_main=${ac_cv_lib_eo_main='no'} ac_cv_lib_eoutils_main=${ac_cv_lib_eoutils_main=no}
ac_cv_c_const=${ac_cv_c_const='yes'} ac_cv_lib_m_main=${ac_cv_lib_m_main=yes}
ac_cv_prog_LN_S=${ac_cv_prog_LN_S='ln -s'} ac_cv_path_install=${ac_cv_path_install=$'/usr/bin/install -c'}
ac_cv_header_limits_h=${ac_cv_header_limits_h='yes'} ac_cv_prog_CPP=${ac_cv_prog_CPP=$'cc -E'}
ac_cv_header_stdc=${ac_cv_header_stdc='yes'} ac_cv_prog_CXX=${ac_cv_prog_CXX=c++}
ac_cv_prog_make_make_set=${ac_cv_prog_make_make_set='yes'} ac_cv_prog_LN_S=${ac_cv_prog_LN_S=$'ln -s'}
ac_cv_prog_cxx_works=${ac_cv_prog_cxx_works='yes'} ac_cv_prog_RANLIB=${ac_cv_prog_RANLIB=ranlib}
ac_cv_c_inline=${ac_cv_c_inline='inline'} ac_cv_prog_cxx_cross=${ac_cv_prog_cxx_cross=no}
ac_cv_lib_m_main=${ac_cv_lib_m_main='yes'} ac_cv_prog_cxx_g=${ac_cv_prog_cxx_g=yes}
ac_cv_lib_eoutils_main=${ac_cv_lib_eoutils_main='no'} ac_cv_prog_cxx_works=${ac_cv_prog_cxx_works=yes}
ac_cv_prog_cxx_g=${ac_cv_prog_cxx_g='yes'} ac_cv_prog_gxx=${ac_cv_prog_gxx=yes}
ac_cv_prog_gxx=${ac_cv_prog_gxx='yes'} ac_cv_prog_make_make_set=${ac_cv_prog_make_make_set=yes}
ac_cv_prog_CPP=${ac_cv_prog_CPP='cc -E'} ac_cv_type_size_t=${ac_cv_type_size_t=yes}

View file

@ -43,13 +43,16 @@ bool lt_arity(const Node &node1, const Node &node2)
return (node1.arity() < node2.arity()); return (node1.arity() < node2.arity());
} }
/** eoGpDepthInitializer : the initializer class for eoParseTree /** eoParseTreeDepthInit : the initializer class for eoParseTree
\class eoGpDepthInitializer eoParseTreeDepthInit.h gp/eoParseTreeDepthInit.h \class eoParseTreeDepthInit eoParseTreeDepthInit.h gp/eoParseTreeDepthInit.h
\ingroup ParseTree \ingroup ParseTree
*/ */
// eoGpDepthInitializer is defined for backward compatibility
#define eoGpDepthInitializer eoParseTreeDepthInit
template <class FType, class Node> template <class FType, class Node>
class eoGpDepthInitializer : public eoInit< eoParseTree<FType, Node> > class eoParseTreeDepthInit : public eoInit< eoParseTree<FType, Node> >
{ {
public : public :
@ -61,7 +64,7 @@ class eoGpDepthInitializer : public eoInit< eoParseTree<FType, Node> >
* @param _initializor A vector containing the possible nodes * @param _initializor A vector containing the possible nodes
* @param _grow False results in a full tree, True result is a randomly grown tree * @param _grow False results in a full tree, True result is a randomly grown tree
*/ */
eoGpDepthInitializer( eoParseTreeDepthInit(
unsigned _max_depth, unsigned _max_depth,
const vector<Node>& _initializor, const vector<Node>& _initializor,
bool _grow = true) bool _grow = true)
@ -73,14 +76,14 @@ class eoGpDepthInitializer : public eoInit< eoParseTree<FType, Node> >
{ {
if(initializor.empty()) if(initializor.empty())
{ {
throw logic_error("eoGpDepthInitializer: uhm, wouldn't you rather give a non-empty set of Nodes?"); throw logic_error("eoParseTreeDepthInit: uhm, wouldn't you rather give a non-empty set of Nodes?");
} }
// lets sort the initializor vector according to arity (so we can be sure the terminals are in front) // lets sort the initializor vector according to arity (so we can be sure the terminals are in front)
// we use stable_sort so that if element i was in front of element j and they have the same arity i remains in front of j // we use stable_sort so that if element i was in front of element j and they have the same arity i remains in front of j
stable_sort(initializor.begin(), initializor.end(), lt_arity<Node>); stable_sort(initializor.begin(), initializor.end(), lt_arity<Node>);
} }
/// My class name /// My class name
virtual string className() const { return "eoDepthInitializer"; }; virtual string className() const { return "eoParseTreeDepthInit"; };
/**initialize a tree /**initialize a tree
* @param _tree : the tree to be initialized * @param _tree : the tree to be initialized
@ -168,11 +171,11 @@ void eoInitRampedHalfAndHalf(eoPop< eoParseTree<FType,Node> > &pop, unsigned in
// initialize with Depth's (D) -> 2 // initialize with Depth's (D) -> 2
for(m=init_max_depth; m >= 2; m--) for(m=init_max_depth; m >= 2; m--)
{ {
eoGpDepthInitializer<FType, Node> grow_initializer(m, initializor, true); eoParseTreeDepthInit<FType, Node> grow_initializer(m, initializor, true);
Pop grow(part_pop_size, grow_initializer); Pop grow(part_pop_size, grow_initializer);
pop.insert(pop.begin(), grow.begin(), grow.end()); pop.insert(pop.begin(), grow.begin(), grow.end());
eoGpDepthInitializer<FType, Node> full_initializer(m, initializor, false); eoParseTreeDepthInit<FType, Node> full_initializer(m, initializor, false);
Pop full(part_pop_size, full_initializer); Pop full(part_pop_size, full_initializer);
pop.insert(pop.begin(), full.begin(), full.end()); pop.insert(pop.begin(), full.begin(), full.end());
} }
@ -180,7 +183,7 @@ void eoInitRampedHalfAndHalf(eoPop< eoParseTree<FType,Node> > &pop, unsigned in
bool g = true; bool g = true;
while (pop.size() < population_size) while (pop.size() < population_size)
{ {
eoGpDepthInitializer<FType, Node> initializer(init_max_depth, initializor, g); eoParseTreeDepthInit<FType, Node> initializer(init_max_depth, initializor, g);
Pop p(1, initializer); Pop p(1, initializer);
pop.insert(pop.begin(), p.begin(), p.end()); pop.insert(pop.begin(), p.begin(), p.end());
g= !g; g= !g;

View file

@ -1,7 +1,7 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// eoStDepthInit.h : initializor strongly type GP // eoStParseTreeDepthInit.h : initializor strongly type GP
// (c) Jeroen Eggermont 2001 // (c) Jeroen Eggermont 2001
/* /*
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
@ -53,13 +53,13 @@ using namespace std;
Tree pruning strongly typed trees is not possible at the moment. Tree pruning strongly typed trees is not possible at the moment.
*/ */
/** eoStDepthInit : the initializer class for strongly typed tree-based genetic programming /** eoStParseTreeDepthInit : the initializer class for strongly typed tree-based genetic programming
\class eoStDepthInit eoStDepthInit.h gp/eoStDepthInit.h \class eoStParseTreeDepthInit eoStParseTreeDepthInit.h gp/eoStParseTreeDepthInit.h
\ingroup StParseTree \ingroup StParseTree
*/ */
template <class FType, class Node> template <class FType, class Node>
class eoStDepthInit : public eoInit< eoParseTree<FType, Node> > class eoStParseTreeDepthInit : public eoInit< eoParseTree<FType, Node> >
{ {
public : public :
@ -71,7 +71,7 @@ class eoStDepthInit : public eoInit< eoParseTree<FType, Node> >
* @param _initializor A vector containing the possible nodes * @param _initializor A vector containing the possible nodes
* @param _grow False results in a full tree, True result is a randomly grown tree * @param _grow False results in a full tree, True result is a randomly grown tree
*/ */
eoStDepthInit( eoStParseTreeDepthInit(
unsigned _max_depth, unsigned _max_depth,
const vector<Node>& _node, const vector<Node>& _node,
const int& _return_type, const int& _return_type,
@ -84,7 +84,7 @@ class eoStDepthInit : public eoInit< eoParseTree<FType, Node> >
{ {
if(_node.empty()) if(_node.empty())
{ {
throw logic_error("eoGpDepthInitializer: uhm, wouldn't you rather give a non-empty set of Nodes?"); throw logic_error("eoStParseTreeDepthInit: uhm, wouldn't you rather give a non-empty set of Nodes?");
} }
@ -118,7 +118,7 @@ class eoStDepthInit : public eoInit< eoParseTree<FType, Node> >
} }
/// My class name /// My class name
virtual string className() const { return "eoStDepthInit"; }; virtual string className() const { return "eoStParseTreeDepthInit"; };
/**initialize a tree /**initialize a tree
* @param _tree : the tree to be initialized * @param _tree : the tree to be initialized