-/* Copyright (c) 2007-2008 Massachusetts Institute of Technology
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
p->stop->nevals++;
return f;
}
-#define FUNCTION_EVAL(fv,x,p,freeonerr) fv = function_eval(x, p); if (p->minf < p->stop->minf_max) { free(freeonerr); return NLOPT_MINF_MAX_REACHED; } else if (nlopt_stop_evals((p)->stop)) { free(freeonerr); return NLOPT_MAXEVAL_REACHED; } else if (nlopt_stop_time((p)->stop)) { free(freeonerr); return NLOPT_MAXTIME_REACHED; }
+#define FUNCTION_EVAL(fv,x,p,freeonerr) fv = function_eval(x, p); if (nlopt_stop_forced((p)->stop)) { free(freeonerr); return NLOPT_FORCED_STOP; } else if (p->minf < p->stop->minf_max) { free(freeonerr); return NLOPT_MINF_MAX_REACHED; } else if (nlopt_stop_evals((p)->stop)) { free(freeonerr); return NLOPT_MAXEVAL_REACHED; } else if (nlopt_stop_time((p)->stop)) { free(freeonerr); return NLOPT_MAXTIME_REACHED; }
#define THIRD (0.3333333333333333333333)
static nlopt_result divide_rect(double *rdiv, params *p)
{
int i;
- const const int n = p->n;
+ const int n = p->n;
const int L = p->L;
double *c = rdiv + 3; /* center of rect to divide */
double *w = c + n; /* widths of rect to divide */
int im, ip;
/* find unequal points before (im) and after (ip) to get slope */
- for (im = i-1; im >= 0 && hull[im][0] == hull[i][0]; --im);
- for (ip = i+1; ip < nhull && hull[ip][0] == hull[i][0]; ++ip);
+ for (im = i-1; im >= 0 && hull[im][0] == hull[i][0]; --im) ;
+ for (ip = i+1; ip < nhull && hull[ip][0] == hull[i][0]; ++ip) ;
if (im >= 0)
K1 = (hull[i][1] - hull[im][1]) / (hull[i][0] - hull[im][0]);
if (ip < nhull)
- K1 = (hull[i][1] - hull[ip][1]) / (hull[i][0] - hull[ip][0]);
+ K2 = (hull[i][1] - hull[ip][1]) / (hull[i][0] - hull[ip][0]);
K = MAX(K1, K2);
if (hull[i][1] - K * hull[i][0]
<= p->minf - magic_eps * fabs(p->minf) || ip == nhull) {
coordinates to a unit hypercube ... we do this simply by
wrapping cdirect() around cdirect_unscaled(). */
-double cdirect_uf(int n, const double *xu, double *grad, void *d_)
+double cdirect_uf(unsigned n, const double *xu, double *grad, void *d_)
{
cdirect_uf_data *d = (cdirect_uf_data *) d_;
double f;
- int i;
+ unsigned i;
for (i = 0; i < n; ++i)
d->x[i] = d->lb[i] + xu[i] * (d->ub[i] - d->lb[i]);
f = d->f(n, d->x, grad, d->f_data);