From abca116edb3fc9d00a00d1f47af82205a0ad4a5e Mon Sep 17 00:00:00 2001 From: wcancino Date: Fri, 26 Jun 2009 15:15:59 +0000 Subject: [PATCH] More work on split new infraestructure git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1593 331e1502-861f-0410-8da2-ba01fb791d7f --- .../PhyloMOEA/PhyloMOEA/phylotreeIND.cpp | 36 +++++++++++++++++++ .../PhyloMOEA/PhyloMOEA/phylotreeIND.h | 4 ++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/contribution/branches/PhyloMOEA/PhyloMOEA/phylotreeIND.cpp b/contribution/branches/PhyloMOEA/PhyloMOEA/phylotreeIND.cpp index fdf723c0b..c66c90a54 100644 --- a/contribution/branches/PhyloMOEA/PhyloMOEA/phylotreeIND.cpp +++ b/contribution/branches/PhyloMOEA/PhyloMOEA/phylotreeIND.cpp @@ -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 ) { diff --git a/contribution/branches/PhyloMOEA/PhyloMOEA/phylotreeIND.h b/contribution/branches/PhyloMOEA/PhyloMOEA/phylotreeIND.h index 6dfc87490..3f9c88aa8 100644 --- a/contribution/branches/PhyloMOEA/PhyloMOEA/phylotreeIND.h +++ b/contribution/branches/PhyloMOEA/PhyloMOEA/phylotreeIND.h @@ -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;