More work on split new infraestructure

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1593 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
wcancino 2009-06-26 15:15:59 +00:00
commit abca116edb
2 changed files with 39 additions and 1 deletions

View file

@ -250,6 +250,40 @@ edge phylotreeIND::choose_edge_fromside( int idx, bool side ) const
}
// select and edge from a side of a split
// true = inside
// false = outside
edge phylotreeIND::choose_edge_fromside_2( struct split_info &info, bool inside ) const
{
edge edgeaux;
bool chosen = false;
do
{
edgeaux = select_edge();
struct split_info *info2 = interior_edge[edgeaux];
if( is_internal(edgeaux) )
{
int taxon_map = splitstable[ taxon_id(edgeaux.target()) ].map_to_node;
if( inside)
chosen = ( taxon_map >= info.left && taxon_map <= info.right );
else
chosen = ( taxon_map < info.left || taxon_map > info.right );
}
else
{
if ( inside )
chosen = ( info.left <= info2->left && info.right >= info2->right );
else
chosen = ( info.left > info2->right || info.right < info2->left );
}
}
while( !chosen );
return edgeaux;
}
// genetic operators
// change subtrees to form childs
void phylotreeIND::crossover(float pcross, const phylotreeIND& dad, phylotreeIND*& sis, phylotreeIND*& bro) const
@ -2219,6 +2253,8 @@ void phylotreeIND::calculate_splits4()
int idx;
l = current_info->left;
interior_edge[ it.branch() ] = current_info;
if( *it == it.branch().source() ) current_info->side = 0;
else current_info->side = 1;
if( father_info == NULL )
{

View file

@ -42,9 +42,10 @@ struct split_info
{
int left, right, num_nodes, map_to_node, node_to_map;
split_info *hash;
int side;
split_info() {};
split_info(int n) : left(n), right(-1), num_nodes(0), hash(NULL), map_to_node(-1), node_to_map(-1) {};
split_info(int n) : left(n), right(-1), num_nodes(0), hash(NULL), map_to_node(-1), node_to_map(-1), side(0) {};
bool invalid() { return right == -1; };
};
@ -110,6 +111,7 @@ class phylotreeIND
void mutate_branch_lenght ( float );
edge select_edge_outsidetree ( edge source_edge ) const;
edge choose_edge_fromside ( int id, bool side ) const;
edge choose_edge_fromside_2( struct split_info &info, bool inside ) const;
edge choose_neighboor ( edge, node ) const;