1 | /* |
---|
2 | ** spr.h: Header file for the SPR routines. |
---|
3 | ** |
---|
4 | ** Wim Hordijk Last modified: 28 August 2006 |
---|
5 | */ |
---|
6 | |
---|
7 | #include <config.h> |
---|
8 | |
---|
9 | #ifndef _SPR_H_ |
---|
10 | #define _SPR_H_ |
---|
11 | |
---|
12 | #include "utilities.h" |
---|
13 | #include "models.h" |
---|
14 | #include "lk.h" |
---|
15 | #include "free.h" |
---|
16 | #include "optimiz.h" |
---|
17 | #include "alrt.h" |
---|
18 | #include "pars.h" |
---|
19 | #include "simu.h" |
---|
20 | |
---|
21 | #define ALL 1 |
---|
22 | #define BEST 2 |
---|
23 | #define ONE 3 |
---|
24 | |
---|
25 | /* |
---|
26 | ** _move_: Structure for holding the relevant information for candidate SPR moves. |
---|
27 | */ |
---|
28 | |
---|
29 | typedef struct |
---|
30 | { |
---|
31 | t_node *v_prune, *u_prune, *v_n, *v_nx1, *u_n, **path; |
---|
32 | t_edge *e_prune, *e_regraft; |
---|
33 | phydbl l_connect, l_est[3], delta_lk, d_L, d_up_v, d_un_v; |
---|
34 | int dist, rgrft_rank, optim_rank, globl_rank; |
---|
35 | } _move_; |
---|
36 | |
---|
37 | |
---|
38 | |
---|
39 | void Init_SPR (t_tree *tree); |
---|
40 | void Clean_SPR (t_tree *tree); |
---|
41 | void Optim_SPR (t_tree *tree, int max_size, int method); |
---|
42 | int Perform_SPR_Moves (t_tree *tree, int max_size); |
---|
43 | int Perform_Best_SPR (t_tree *tree, int max_size); |
---|
44 | int Perform_One_SPR (t_tree *tree, int max_size); |
---|
45 | |
---|
46 | void Calc_Tree_Length (t_edge *e_prune, t_node *v_prune, t_tree *tree); |
---|
47 | void Tree_Length (t_node *v_prune, t_node *u_prune, t_node *v_n, t_node *v_n_1, |
---|
48 | t_node *v_nx1, t_node *v_0, t_node *u_n, phydbl d_up_v_1, |
---|
49 | phydbl d_uu, phydbl d_L_1, int n, t_tree *tree); |
---|
50 | int Est_Lk_Change (t_edge *e_prune, t_node *v_prune, t_tree *tree); |
---|
51 | int Best_Lk_Change (t_edge *e_prune, t_node *v_prune, t_tree *tree); |
---|
52 | void Make_Move (_move_ *move, int type, t_tree *tree); |
---|
53 | int Find_Optim_Local (t_tree *tree); |
---|
54 | int Find_Optim_Globl (t_tree *tree); |
---|
55 | void Prune (t_edge *e, t_node *v, t_edge **e_connect, t_edge **e_avail, |
---|
56 | t_tree *tree); |
---|
57 | void Regraft (t_edge *e, t_node *v, t_edge *avail, t_tree *tree); |
---|
58 | void PostOrder_v (t_tree *tree, t_node *v, t_edge *e); |
---|
59 | void PostOrder_w (t_tree *tree, t_node *v, t_edge *v_e, t_node *w, t_edge *e); |
---|
60 | |
---|
61 | |
---|
62 | |
---|
63 | |
---|
64 | |
---|
65 | void Speed_Spr(t_tree *tree, int max_cycles); |
---|
66 | void Speed_Spr_Loop(t_tree *tree); |
---|
67 | void Make_Spr_List(t_tree *tree); |
---|
68 | void Init_One_Spr(t_spr *a_spr); |
---|
69 | t_spr *Make_One_Spr(t_tree *tree); |
---|
70 | int Spr(phydbl init_lnL, t_tree *tree); |
---|
71 | int Spr_Recur(t_node *a, t_node *d, t_tree *tree); |
---|
72 | int Test_All_Spr_Targets(t_edge *pulled, t_node *link, t_tree *tree); |
---|
73 | void Randomize_Spr_List(t_tree *tree); |
---|
74 | void Test_One_Spr_Target_Recur(t_node *a, t_node *d, t_edge *pulled, t_node *link, t_edge *residual, int *best_found, t_tree *tree); |
---|
75 | phydbl Test_One_Spr_Target(t_edge *target, t_edge *arrow, t_node *link, t_edge *residual, t_tree *tree); |
---|
76 | void Apply_Spr_Moves_One_By_One(t_tree *tree); |
---|
77 | int Try_One_Spr_Move_Triple(t_spr *move, t_tree *tree); |
---|
78 | int Try_One_Spr_Move_Full(t_spr *move, t_tree *tree); |
---|
79 | void Make_Best_Spr(t_tree *tree); |
---|
80 | void Random_Spr(int n_moves, t_tree *tree); |
---|
81 | void Include_One_Spr_To_List_Of_Spr(t_spr *move, t_tree *tree); |
---|
82 | void Reset_Spr_List(t_tree *tree); |
---|
83 | int Evaluate_List_Of_Regraft_Pos_Triple(t_spr **spr_list, int list_size, t_tree *tree); |
---|
84 | void Best_Spr(t_tree *tree); |
---|
85 | int Check_Spr_Move_Validity(t_spr *this_spr_move, t_tree *tree); |
---|
86 | void Spr_Subtree(t_edge *b, t_node *link, t_tree *tree); |
---|
87 | void Spr_Pars(t_tree *tree); |
---|
88 | void SPR_Shuffle(t_tree *tree); |
---|
89 | |
---|
90 | |
---|
91 | |
---|
92 | #endif /* _SPR_H_ */ |
---|
93 | |
---|
94 | |
---|
95 | /* |
---|
96 | ** EOF: spr.h |
---|
97 | */ |
---|