1 | /* |
---|
2 | |
---|
3 | PHYML : a program that computes maximum likelihood phylogenies from |
---|
4 | DNA or AA homologous sequences |
---|
5 | |
---|
6 | Copyright (C) Stephane Guindon. Oct 2003 onward |
---|
7 | |
---|
8 | All parts of the source except where indicated are distributed under |
---|
9 | the GNU public licence. See http://www.opensource.org for details. |
---|
10 | |
---|
11 | */ |
---|
12 | |
---|
13 | #include <config.h> |
---|
14 | |
---|
15 | #ifndef OPTIMIZ_H |
---|
16 | #define OPTIMIZ_H |
---|
17 | |
---|
18 | #include "utilities.h" |
---|
19 | #include "lk.h" |
---|
20 | #include "free.h" |
---|
21 | #include "models.h" |
---|
22 | #include "mg.h" |
---|
23 | #include "tiporder.h" |
---|
24 | |
---|
25 | |
---|
26 | void Optimiz_Ext_Br(t_tree *tree); |
---|
27 | void Optimize_Param_Parall(t_tree *tree); |
---|
28 | phydbl Optimize_Branch_Quad(t_tree *tree, calign *cdata, t_edge *b_fcus); |
---|
29 | void Optimize_After_Hide(t_tree *tree, calign *cdata, t_node *h); |
---|
30 | void Round_Optimize(t_tree *tree, calign *data, int n_round_max); |
---|
31 | int Dist_Seq_Brak(phydbl *ax, phydbl *bx, phydbl *cx, |
---|
32 | phydbl *fa, phydbl *fb, phydbl *fc, |
---|
33 | calign *data, int num1, int num2, t_mod *mod); |
---|
34 | phydbl Dist_Seq_Brent(phydbl ax, phydbl bx, phydbl cx, phydbl tol, |
---|
35 | phydbl *xmin, calign *data, |
---|
36 | int num1, int num2, t_mod *mod); |
---|
37 | phydbl Kappa_Golden(phydbl ax, phydbl bx, phydbl cx, phydbl tol, |
---|
38 | phydbl *xmin, t_tree *tree, calign *cdata); |
---|
39 | phydbl Lambda_Golden(phydbl ax, phydbl bx, phydbl cx, phydbl tol, |
---|
40 | phydbl *xmin, t_tree *tree, calign *cdata); |
---|
41 | phydbl Alpha_Golden_Br_Opt(phydbl ax, phydbl bx, phydbl cx, phydbl tol, |
---|
42 | phydbl *xmin, t_tree *tree, calign *cdata, |
---|
43 | int n_opt, phydbl *init_l); |
---|
44 | phydbl Alpha_Golden(phydbl ax, phydbl bx, phydbl cx, phydbl tol,phydbl *xmin, |
---|
45 | t_tree *tree, calign *cdata); |
---|
46 | phydbl Br_Len_Golden(phydbl ax, phydbl bx, phydbl cx, phydbl tol, |
---|
47 | phydbl *xmin, t_edge *b_fcus, t_tree *tree); |
---|
48 | phydbl Br_Len_Brent(phydbl prop_min, phydbl prop_max, t_edge *b_fcus, t_tree *tree); |
---|
49 | int Br_Len_Brak(phydbl *ax, phydbl *bx, phydbl *cx, |
---|
50 | phydbl *fa, phydbl *fb, phydbl *fc, |
---|
51 | t_edge *b_fcus, t_tree *tree); |
---|
52 | phydbl Optimize_Path_Length(t_mod *mod, calign *cdata, t_edge *a, |
---|
53 | int lra, t_edge *b, int lrb, phydbl i_len); |
---|
54 | void Optimize_Param_Serie(t_node *a, t_node *d, t_edge *b_fcus, t_tree *tree, |
---|
55 | calign *cdata, int n_passes); |
---|
56 | phydbl Optimize_Dist(t_mod *mod, phydbl init, calign *twoseqs); |
---|
57 | phydbl Pinvar_Golden(phydbl ax, phydbl bx, phydbl cx, phydbl tol, |
---|
58 | phydbl *xmin, t_tree *tree, calign *cdata, int n_iter_max); |
---|
59 | void Optimize_Pinvar(t_tree *tree); |
---|
60 | int Lambda_Brak(phydbl *ax, phydbl *bx, phydbl *cx, |
---|
61 | phydbl *fa, phydbl *fb, phydbl *fc, |
---|
62 | t_tree *tree); |
---|
63 | int Kappa_Brak(phydbl *ax, phydbl *bx, phydbl *cx, |
---|
64 | phydbl *fa, phydbl *fb, phydbl *fc, |
---|
65 | t_tree *tree); |
---|
66 | int Alpha_Brak(phydbl *ax, phydbl *bx, phydbl *cx, |
---|
67 | phydbl *fa, phydbl *fb, phydbl *fc, |
---|
68 | t_tree *tree); |
---|
69 | int Pinvar_Brak(phydbl *ax, phydbl *bx, phydbl *cx, |
---|
70 | phydbl *fa, phydbl *fb, phydbl *fc, |
---|
71 | t_tree *tree); |
---|
72 | void Optimiz_All_Free_Param(t_tree *tree, int verbose); |
---|
73 | void Optimiz_RRparam_GTR(t_tree *tree, int num_param); |
---|
74 | phydbl RRparam_GTR_Golden(phydbl ax, phydbl bx, phydbl cx, phydbl tol, |
---|
75 | phydbl *xmin, t_tree *tree, calign *cdata, phydbl *param, int n_iter_max); |
---|
76 | |
---|
77 | int Powell_GTR_Param(t_tree *tree, phydbl *p, int n, phydbl ftol); |
---|
78 | phydbl Linmin_GTR_Param(t_tree *tree,phydbl *p, phydbl *xi, int n); |
---|
79 | phydbl F1dim(t_tree *tree, phydbl x, phydbl *p, phydbl *xi, phydbl n); |
---|
80 | int Mnbrak_1dim(phydbl *ax, phydbl *bx, phydbl *cx, |
---|
81 | phydbl *fa, phydbl *fb, phydbl *fc, |
---|
82 | t_tree *tree, |
---|
83 | phydbl *p, phydbl *xi, phydbl n); |
---|
84 | phydbl Brent_1dim(phydbl ax, phydbl bx, phydbl cx, |
---|
85 | phydbl tol, phydbl *xmin, |
---|
86 | t_tree *tree, |
---|
87 | phydbl *p, phydbl *xi, phydbl n); |
---|
88 | |
---|
89 | int Min_With_Derivatives(t_tree *tree, phydbl *p, int n, phydbl ftol, phydbl step_size, |
---|
90 | phydbl (*func) (), void (*dfunc)(), phydbl (*linmin)()); |
---|
91 | void BFGS(t_tree *tree, |
---|
92 | phydbl *p, |
---|
93 | int n, |
---|
94 | phydbl gtol, |
---|
95 | phydbl difff, |
---|
96 | phydbl step_size, |
---|
97 | int logt, |
---|
98 | int is_positive, |
---|
99 | phydbl(*func)(t_tree *tree), |
---|
100 | int(*dfunc)(t_tree *tree,phydbl *param,int n_param,phydbl stepsize,int logt,phydbl(*func)(t_tree *tree),phydbl *derivatives, int is_positive), |
---|
101 | int(*lnsrch)(t_tree *tree, int n, phydbl *xold, phydbl fold,phydbl *g, phydbl *p, phydbl *x,phydbl *f, phydbl stpmax, int *check, int logt, int is_positive), |
---|
102 | int *failed); |
---|
103 | |
---|
104 | void BFGS_Nonaligned(t_tree *tree, |
---|
105 | phydbl **p, |
---|
106 | int n, |
---|
107 | phydbl gtol, |
---|
108 | phydbl difff, |
---|
109 | phydbl step_size, |
---|
110 | int logt, |
---|
111 | int is_positive, |
---|
112 | phydbl(*func)(t_tree *tree), |
---|
113 | int(*dfunc_nonaligned)(t_tree *tree,phydbl **param,int n_param,phydbl stepsize,int logt,phydbl(*func)(t_tree *tree),phydbl *derivatives, int is_positive), |
---|
114 | int(*lnsrch_nonaligned)(t_tree *tree, int n, phydbl **xold, phydbl fold,phydbl *g, phydbl *p, phydbl *x,phydbl *f, phydbl stpmax, int *check, int logt, int is_positive), |
---|
115 | int *failed); |
---|
116 | |
---|
117 | |
---|
118 | void Optimize_Single_Param_Generic(t_tree *tree, phydbl *param, phydbl lim_inf, phydbl lim_sup, phydbl tol, int n_max_iter, int quickdirty); |
---|
119 | int Generic_Brak(phydbl *param, |
---|
120 | phydbl *ax, phydbl *bx, phydbl *cx, |
---|
121 | phydbl *fa, phydbl *fb, phydbl *fc, |
---|
122 | phydbl lim_inf, phydbl lim_sup, |
---|
123 | t_tree *tree); |
---|
124 | phydbl Generic_Brent(phydbl ax, phydbl bx, phydbl cx, phydbl tol, |
---|
125 | phydbl *xmin, t_tree *tree, int n_iter_max,int quickdirty); |
---|
126 | void Optimize_Br_Len_Serie(t_tree *tree); |
---|
127 | void Optimize_Br_Len_Serie_Post(t_node *a, t_node *d, t_edge *b_fcus, t_tree *tree); |
---|
128 | void Optimize_Global_Rate(t_tree *tree); |
---|
129 | phydbl Br_Len_Brent_Default(t_edge *b_fcus, t_tree *tree); |
---|
130 | |
---|
131 | void EM_Dist(t_mod *mod, calign *data); |
---|
132 | phydbl Dist_F_Brent(phydbl ax, phydbl bx, phydbl cx, phydbl tol, int n_iter_max, |
---|
133 | phydbl *param, phydbl *F, t_mod *mod); |
---|
134 | int Dist_F_Brak(phydbl *ax, phydbl *bx, phydbl *cx, phydbl *F, phydbl *param, t_mod *mod); |
---|
135 | void Opt_Dist_F(phydbl *dist, phydbl *F, t_mod *mod); |
---|
136 | phydbl Missing_Dist_Brent(phydbl ax, phydbl bx, phydbl cx, phydbl tol, int n_iter_max, |
---|
137 | int x, int y, matrix *mat); |
---|
138 | int Missing_Dist_Brak(phydbl *ax, phydbl *bx, phydbl *cx, int x, int y, matrix *mat); |
---|
139 | void Opt_Missing_Dist(int x, int y, matrix *mat); |
---|
140 | int Optimiz_Alpha_And_Pinv(t_tree *tree, int verbose); |
---|
141 | phydbl Node_Time_Brent(phydbl ax, phydbl bx, phydbl cx, phydbl tol, |
---|
142 | t_node *anc, t_node *des, t_tree *tree, int n_iter_max); |
---|
143 | phydbl Time_Stamps_Mult_Brent(phydbl ax, phydbl bx, phydbl cx, phydbl tol, |
---|
144 | t_tree *tree, int n_iter_max); |
---|
145 | phydbl Branch_Rate_Shape_Brent(phydbl ax, phydbl bx, phydbl cx, phydbl tol, |
---|
146 | phydbl *xmin, t_tree *tree, int n_iter_max); |
---|
147 | phydbl Node_Time_Brent_Fixed_Br_Len(phydbl ax, phydbl bx, phydbl cx, phydbl tol, |
---|
148 | t_node *n, t_tree *tree, int n_iter_max); |
---|
149 | |
---|
150 | phydbl Generic_Brent_Lk(phydbl *param, phydbl ax, phydbl cx, phydbl tol, |
---|
151 | int n_iter_max, int quickdirty, |
---|
152 | phydbl (*obj_func)(t_edge *,t_tree *,supert_tree *), |
---|
153 | t_edge *branch, t_tree *tree, supert_tree *stree, int logt); |
---|
154 | void Round_Optimize_Node_Heights(t_tree *tree); |
---|
155 | void Opt_Node_Heights_Recurr_Pre(t_node *a, t_node *d, t_tree *tree); |
---|
156 | void Opt_Node_Heights_Recurr(t_tree *tree); |
---|
157 | |
---|
158 | int Lnsrch(t_tree *tree, int n, phydbl *xold, phydbl fold, phydbl *g, phydbl *p, phydbl *x, |
---|
159 | phydbl *f, phydbl stpmax, int *check, int logt, int is_positive); |
---|
160 | |
---|
161 | int Lnsrch_Nonaligned(t_tree *tree, int n, phydbl **xold, phydbl fold, phydbl *g, phydbl *p, phydbl *x, |
---|
162 | phydbl *f, phydbl stpmax, int *check, int logt, int is_positive); |
---|
163 | |
---|
164 | void Optimize_RR_Params(t_tree *mixt_tree, int verbose); |
---|
165 | void Optimize_TsTv(t_tree *mixt_tree, int verbose); |
---|
166 | void Optimize_Lambda(t_tree *mixt_tree, int verbose); |
---|
167 | void Optimize_Alpha(t_tree *mixt_tree, int verbose); |
---|
168 | void Optimize_Pinv(t_tree *mixt_tree, int verbose); |
---|
169 | void Optimize_State_Freqs(t_tree *mixt_tree, int verbose); |
---|
170 | void Optimize_Rmat_Weights(t_tree *mixt_tree, int verbose); |
---|
171 | void Optimize_Efrq_Weights(t_tree *mixt_tree, int verbose); |
---|
172 | void Optimize_Free_Rate(t_tree *mixt_tree, int verbose); |
---|
173 | void Optimize_Free_Rate_Weights(t_tree *tree, int fast, int verbose); |
---|
174 | void Optimize_Free_Rate_Rr(t_tree *tree, int fast, int verbose); |
---|
175 | |
---|
176 | #endif |
---|
177 | |
---|