4 #include <stddef.h> /* for ptrdiff_t */
9 #endif /* __cplusplus */
11 typedef double (*nlopt_func)(int n, const double *x,
12 double *gradient, /* NULL if not needed */
16 /* Naming conventions:
19 = global/local derivative/no-derivative optimization,
22 *_RAND algorithms involve some randomization.
24 *_NOSCAL algorithms are *not* scaled to a unit hypercube
25 (i.e. they are sensitive to the units of x)
30 NLOPT_GN_DIRECT_L_RAND,
31 NLOPT_GN_DIRECT_NOSCAL,
32 NLOPT_GN_DIRECT_L_NOSCAL,
33 NLOPT_GN_DIRECT_L_RAND_NOSCAL,
36 NLOPT_GN_ORIG_DIRECT_L,
43 NLOPT_LD_LBFGS_NOCEDAL,
53 NLOPT_LD_TNEWTON_RESTART,
54 NLOPT_LD_TNEWTON_PRECOND,
55 NLOPT_LD_TNEWTON_PRECOND_RESTART,
66 NLOPT_NUM_ALGORITHMS /* not an algorithm, just the number of them */
69 extern const char *nlopt_algorithm_name(nlopt_algorithm a);
72 NLOPT_FAILURE = -1, /* generic failure code */
73 NLOPT_INVALID_ARGS = -2,
74 NLOPT_OUT_OF_MEMORY = -3,
76 NLOPT_SUCCESS = 1, /* generic success code */
77 NLOPT_MINF_MAX_REACHED = 2,
78 NLOPT_FTOL_REACHED = 3,
79 NLOPT_XTOL_REACHED = 4,
80 NLOPT_MAXEVAL_REACHED = 5,
81 NLOPT_MAXTIME_REACHED = 6
84 extern nlopt_result nlopt_minimize(
85 nlopt_algorithm algorithm,
86 int n, nlopt_func f, void *f_data,
87 const double *lb, const double *ub, /* bounds */
88 double *x, /* in: initial guess, out: minimizer */
89 double *minf, /* out: minimum */
90 double minf_max, double ftol_rel, double ftol_abs,
91 double xtol_rel, const double *xtol_abs,
92 int maxeval, double maxtime);
94 extern nlopt_result nlopt_minimize_constrained(
95 nlopt_algorithm algorithm,
96 int n, nlopt_func f, void *f_data,
97 int m, nlopt_func fc, void *fc_data, ptrdiff_t fc_datum_size,
98 const double *lb, const double *ub, /* bounds */
99 double *x, /* in: initial guess, out: minimizer */
100 double *minf, /* out: minimum */
101 double minf_max, double ftol_rel, double ftol_abs,
102 double xtol_rel, const double *xtol_abs,
103 int maxeval, double maxtime);
105 extern void nlopt_srand(unsigned long seed);
106 extern void nlopt_srand_time(void);
108 extern void nlopt_version(int *major, int *minor, int *bugfix);
110 extern void nlopt_get_local_search_algorithm(nlopt_algorithm *deriv,
111 nlopt_algorithm *nonderiv,
113 extern void nlopt_set_local_search_algorithm(nlopt_algorithm deriv,
114 nlopt_algorithm nonderiv,
119 #endif /* __cplusplus */