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:
parent
4584fda53d
commit
2d12525bc5
4 changed files with 39 additions and 37 deletions
|
|
@ -43,13 +43,16 @@ bool lt_arity(const Node &node1, const Node &node2)
|
|||
return (node1.arity() < node2.arity());
|
||||
}
|
||||
|
||||
/** eoGpDepthInitializer : the initializer class for eoParseTree
|
||||
\class eoGpDepthInitializer eoParseTreeDepthInit.h gp/eoParseTreeDepthInit.h
|
||||
/** eoParseTreeDepthInit : the initializer class for eoParseTree
|
||||
\class eoParseTreeDepthInit eoParseTreeDepthInit.h gp/eoParseTreeDepthInit.h
|
||||
\ingroup ParseTree
|
||||
*/
|
||||
|
||||
// eoGpDepthInitializer is defined for backward compatibility
|
||||
#define eoGpDepthInitializer eoParseTreeDepthInit
|
||||
|
||||
template <class FType, class Node>
|
||||
class eoGpDepthInitializer : public eoInit< eoParseTree<FType, Node> >
|
||||
class eoParseTreeDepthInit : public eoInit< eoParseTree<FType, Node> >
|
||||
{
|
||||
public :
|
||||
|
||||
|
|
@ -61,7 +64,7 @@ class eoGpDepthInitializer : public eoInit< eoParseTree<FType, Node> >
|
|||
* @param _initializor A vector containing the possible nodes
|
||||
* @param _grow False results in a full tree, True result is a randomly grown tree
|
||||
*/
|
||||
eoGpDepthInitializer(
|
||||
eoParseTreeDepthInit(
|
||||
unsigned _max_depth,
|
||||
const vector<Node>& _initializor,
|
||||
bool _grow = true)
|
||||
|
|
@ -73,14 +76,14 @@ class eoGpDepthInitializer : public eoInit< eoParseTree<FType, Node> >
|
|||
{
|
||||
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)
|
||||
// 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>);
|
||||
}
|
||||
/// My class name
|
||||
virtual string className() const { return "eoDepthInitializer"; };
|
||||
virtual string className() const { return "eoParseTreeDepthInit"; };
|
||||
|
||||
/**initialize a tree
|
||||
* @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
|
||||
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.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.insert(pop.begin(), full.begin(), full.end());
|
||||
}
|
||||
|
|
@ -180,7 +183,7 @@ void eoInitRampedHalfAndHalf(eoPop< eoParseTree<FType,Node> > &pop, unsigned in
|
|||
bool g = true;
|
||||
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.insert(pop.begin(), p.begin(), p.end());
|
||||
g= !g;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// -*- 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
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
/** eoStDepthInit : the initializer class for strongly typed tree-based genetic programming
|
||||
\class eoStDepthInit eoStDepthInit.h gp/eoStDepthInit.h
|
||||
/** eoStParseTreeDepthInit : the initializer class for strongly typed tree-based genetic programming
|
||||
\class eoStParseTreeDepthInit eoStParseTreeDepthInit.h gp/eoStParseTreeDepthInit.h
|
||||
\ingroup StParseTree
|
||||
*/
|
||||
|
||||
template <class FType, class Node>
|
||||
class eoStDepthInit : public eoInit< eoParseTree<FType, Node> >
|
||||
class eoStParseTreeDepthInit : public eoInit< eoParseTree<FType, Node> >
|
||||
{
|
||||
public :
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ class eoStDepthInit : public eoInit< eoParseTree<FType, Node> >
|
|||
* @param _initializor A vector containing the possible nodes
|
||||
* @param _grow False results in a full tree, True result is a randomly grown tree
|
||||
*/
|
||||
eoStDepthInit(
|
||||
eoStParseTreeDepthInit(
|
||||
unsigned _max_depth,
|
||||
const vector<Node>& _node,
|
||||
const int& _return_type,
|
||||
|
|
@ -84,7 +84,7 @@ class eoStDepthInit : public eoInit< eoParseTree<FType, Node> >
|
|||
{
|
||||
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
|
||||
virtual string className() const { return "eoStDepthInit"; };
|
||||
virtual string className() const { return "eoStParseTreeDepthInit"; };
|
||||
|
||||
/**initialize a tree
|
||||
* @param _tree : the tree to be initialized
|
||||
|
|
|
|||
Reference in a new issue