Skip to content

Commit b22a9f7

Browse files
authored
renamed alpha, beta and gamma since some systems might define them in math.h (#622)
1 parent a75f3d9 commit b22a9f7

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/algs/neldermead/nldrmd.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
Richardson and Kuester (1973), as mentioned below. */
3333

3434
/* heuristic "strategy" constants: */
35-
static const double alpha = 1, beta = 0.5, gamm = 2, delta = 0.5;
35+
static const double ALPHA = 1, BETA = 0.5, GAMMA = 2, DELTA = 0.5;
3636

3737
/* sort order in red-black tree: keys [f(x), x] are sorted by f(x) */
3838
static int simplex_compare(double *k1, double *k2)
@@ -228,14 +228,14 @@ nlopt_result nldrmd_minimize_(int n, nlopt_func f, void *f_data,
228228
}
229229

230230
/* reflection */
231-
if (!reflectpt(n, xcur, c, alpha, xh, lb, ub)) {
231+
if (!reflectpt(n, xcur, c, ALPHA, xh, lb, ub)) {
232232
ret=NLOPT_XTOL_REACHED; goto done;
233233
}
234234
fr = f(n, xcur, NULL, f_data);
235235
CHECK_EVAL(xcur, fr);
236236

237237
if (fr < fl) { /* new best point, expand simplex */
238-
if (!reflectpt(n, xh, c, gamm, xh, lb, ub)) {
238+
if (!reflectpt(n, xh, c, GAMMA, xh, lb, ub)) {
239239
ret=NLOPT_XTOL_REACHED; goto done;
240240
}
241241
fh = f(n, xh, NULL, f_data);
@@ -251,7 +251,7 @@ nlopt_result nldrmd_minimize_(int n, nlopt_func f, void *f_data,
251251
}
252252
else { /* new worst point, contract */
253253
double fc;
254-
if (!reflectpt(n,xcur,c, fh <= fr ? -beta : beta, xh, lb,ub)) {
254+
if (!reflectpt(n,xcur,c, fh <= fr ? -BETA : BETA, xh, lb,ub)) {
255255
ret=NLOPT_XTOL_REACHED; goto done;
256256
}
257257
fc = f(n, xcur, NULL, f_data);
@@ -266,7 +266,7 @@ nlopt_result nldrmd_minimize_(int n, nlopt_func f, void *f_data,
266266
for (i = 0; i < n+1; ++i) {
267267
double *pt = pts + i * (n+1);
268268
if (pt+1 != xl) {
269-
if (!reflectpt(n,pt+1, xl,-delta,pt+1, lb,ub)) {
269+
if (!reflectpt(n,pt+1, xl,-DELTA,pt+1, lb,ub)) {
270270
ret = NLOPT_XTOL_REACHED;
271271
goto done;
272272
}

0 commit comments

Comments
 (0)