Program listing for file numerics/src/tools/line_search.h

Program listing for file numerics/src/tools/line_search.h#

 1#ifndef LINESEARCH_H
 2#define LINESEARCH_H
 3
 4
 5
 6#include "Newton_methods.h"
 7#include "SiconosConfig.h"
 8
 9
10typedef struct {
11  compute_F_ptr compute_F;
12  compute_F_merit_ptr compute_F_merit;
13  double* z;
14  double* zc;
15  double* F;
16  double* F_merit;
17  double* desc_dir;
18  double alpha0;
19  double alpha_min;
20  void* data;
21  void* nm_ref_data;
22  unsigned searchtype;
23  void* set;
24  double sigma;
25  void* extra_params;
26} search_data;
27
28
29
30typedef struct {
31  int type;
32  int M;
33  int m;
34  double* previous_thetas;
35} nm_ref_struct;
36
37enum { NM_LS_DISABLE, NM_LS_MAX, NM_LS_MEAN, NM_LS_ZHANG_HAGER };
38
39enum SEARCH_TYPE { LINESEARCH, ARCSEARCH, BACKWARD_PATHSEARCH };
40
41enum LSA_ALGO { SICONOS_LSA_ARMIJO, SICONOS_LSA_GOLDSTEIN };
42
43typedef double (*sn_ls_fn)(int n, double* theta, double preRHS, search_data* ls_data);
44
45#if defined(__cplusplus) && !defined(BUILD_AS_CPP)
46extern "C"
47{
48#endif
49
50
51  static inline void set_nonmonotone_type(void* nm_ref_data, int type)
52  {
53    ((nm_ref_struct*) nm_ref_data)->type = type;
54  }
55
56
57  static inline int get_nonmonotone_type(void* nm_ref_data)
58  {
59    return ((nm_ref_struct*) nm_ref_data)->type;
60  }
61
62
63  double line_search_generic(int n, double theta, double preRHS, search_data* ls_data, unsigned searchtype, sn_ls_fn ls_fn);
64
65
66  void update_non_monotone_ref(void* nm_ref_data, double cur_merit);
67
68
69  void get_non_monotone_ref(void* nm_ref_data, double* theta_ref);
70
71
72  void fill_nm_data(nm_ref_struct* nm_ref_data, int* iparam);
73
74
75  void zero_nm_data(nm_ref_struct* nm_ref_data);
76
77
78  void free_nm_data(nm_ref_struct* nm_ref_data);
79
80
81  void free_ls_data(search_data* ls_data);
82
83#if defined(__cplusplus) && !defined(BUILD_AS_CPP)
84}
85#endif
86
87#endif