Debian Codegraph @

easel/esl_minimizer.h

raw symbols SCIP
1 /* Multidimensional optimization by conjugate gradient descent.
2 *
3 * SRE, Wed 22 Jun 2005
4 * SRE, Fri 20 Jul 2018 : adding ESL_MIN_{CFG,DAT}
5 */
6 #ifndef eslMINIMIZER_INCLUDED
7 #define eslMINIMIZER_INCLUDED
8 #include <esl_config.h>
9
10 /* Default parameters
11 * These can be customized by passing in an ESL_MIN_CFG.
12 */
13 #define eslMIN_MAXITER 100
14 #define eslMIN_CG_RTOL 1e-5
15 #define eslMIN_CG_ATOL 1e-10
16 #define eslMIN_BRACK_MAXITER 100
17 #define eslMIN_BRACK_STEP 1.0
18 #define eslMIN_BRENT_RTOL 1e-3
19 #define eslMIN_BRENT_ATOL 1e-8
20 #define eslMIN_DERIV_STEP 1e-4
21
22 /* ESL_MIN_CFG
23 * optional configuration/customization of a run of the minimizer
24 */
25 typedef struct {
26 int max_iterations; // maximum number of CG iterations
27 double cg_rtol; // CG convergence test on obj func: relative tolerance
28 double cg_atol; // ... absolute tolerance
29 double brent_rtol; // 1D line minim convergence test: relative tolerance
30 double brent_atol; // ... absolute tolerance
31 int brack_maxiter; // max number of bracketing iterations
32 double deriv_step; // numeric deriv takes steps of deriv_step * u[i]
33 double *u; // custom initial step sizes for bracketer and numeric deriv
34 int n; // number of optimized parameters, size of <u>
35 } ESL_MIN_CFG;
36
37
38 /* ESL_MIN_DAT
39 * optional data collected from a run of the minimizer
40 */
41 typedef struct {
42 int niter;
43
44 double *fx; // fx[i=0..niter] = objective function value after update i; initial is i=0
45 int *brack_n; // number of iterations in bracket() minimum bracketing; [0] = 0
46 double *brack_ax; // ax < bx < cx bracketing triplet; [0] = 0
47 double *brack_bx;
48 double *brack_cx;
49 double *brack_fa; // bracketing's objective functions f(a) > f(b) < f(c) [0] = 0
50 double *brack_fb;
51 double *brack_fc;
52 int *brent_n; // number of iterations in brent() line minimization; [0] = 0
53 double *brent_x; // one-d step size taken at CG iteration i; [0] = 0
54 int *nfunc; // total number of objective function calls at each iteration; [0] = 1
55
56 } ESL_MIN_DAT;
57
58
59
60 extern int esl_min_ConjugateGradientDescent(ESL_MIN_CFG *cfg, double *x, int n,
61 double (*func)(double *, int, void *),
62 void (*dfunc)(double *, int, void *, double *),
63 void *prm, double *ret_fx, ESL_MIN_DAT *dat);
64
65 extern ESL_MIN_CFG *esl_min_cfg_Create(int n);
66 extern void esl_min_cfg_Destroy(ESL_MIN_CFG *cfg);
67
68 extern ESL_MIN_DAT *esl_min_dat_Create(ESL_MIN_CFG *cfg);
69 extern void esl_min_dat_Destroy(ESL_MIN_DAT *dat);
70 extern int esl_min_dat_Dump(FILE *fp, ESL_MIN_DAT *dat);
71
72
73 #endif /*eslMINIMIZER_INCLUDED*/