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:
parent
5312c3321e
commit
abca116edb
2 changed files with 39 additions and 1 deletions
|
|
@ -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
|
// genetic operators
|
||||||
// change subtrees to form childs
|
// change subtrees to form childs
|
||||||
void phylotreeIND::crossover(float pcross, const phylotreeIND& dad, phylotreeIND*& sis, phylotreeIND*& bro) const
|
void phylotreeIND::crossover(float pcross, const phylotreeIND& dad, phylotreeIND*& sis, phylotreeIND*& bro) const
|
||||||
|
|
@ -2219,6 +2253,8 @@ void phylotreeIND::calculate_splits4()
|
||||||
int idx;
|
int idx;
|
||||||
l = current_info->left;
|
l = current_info->left;
|
||||||
interior_edge[ it.branch() ] = current_info;
|
interior_edge[ it.branch() ] = current_info;
|
||||||
|
if( *it == it.branch().source() ) current_info->side = 0;
|
||||||
|
else current_info->side = 1;
|
||||||
|
|
||||||
if( father_info == NULL )
|
if( father_info == NULL )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,10 @@ struct split_info
|
||||||
{
|
{
|
||||||
int left, right, num_nodes, map_to_node, node_to_map;
|
int left, right, num_nodes, map_to_node, node_to_map;
|
||||||
split_info *hash;
|
split_info *hash;
|
||||||
|
int side;
|
||||||
|
|
||||||
split_info() {};
|
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; };
|
bool invalid() { return right == -1; };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -110,6 +111,7 @@ class phylotreeIND
|
||||||
void mutate_branch_lenght ( float );
|
void mutate_branch_lenght ( float );
|
||||||
edge select_edge_outsidetree ( edge source_edge ) const;
|
edge select_edge_outsidetree ( edge source_edge ) const;
|
||||||
edge choose_edge_fromside ( int id, bool side ) 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;
|
edge choose_neighboor ( edge, node ) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue