| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
#ifndef eslMINIMIZER_INCLUDED |
| 7 |
#define eslMINIMIZER_INCLUDED |
| 8 |
#include <esl_config.h> |
| 9 |
|
| 10 |
|
| 11 |
|
| 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 |
|
| 23 |
|
| 24 |
|
| 25 |
typedef struct { |
| 26 |
int max_iterations; |
| 27 |
double cg_rtol; |
| 28 |
double cg_atol; |
| 29 |
double brent_rtol; |
| 30 |
double brent_atol; |
| 31 |
int brack_maxiter; |
| 32 |
double deriv_step; |
| 33 |
double *u; |
| 34 |
int n; |
| 35 |
} ESL_MIN_CFG; |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
typedef struct { |
| 42 |
int niter; |
| 43 |
|
| 44 |
double *fx; |
| 45 |
int *brack_n; |
| 46 |
double *brack_ax; |
| 47 |
double *brack_bx; |
| 48 |
double *brack_cx; |
| 49 |
double *brack_fa; |
| 50 |
double *brack_fb; |
| 51 |
double *brack_fc; |
| 52 |
int *brent_n; |
| 53 |
double *brent_x; |
| 54 |
int *nfunc; |
| 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 |