Skip to content

Commit

Permalink
c89 compatibility (#261)
Browse files Browse the repository at this point in the history
c89 compatibility
  • Loading branch information
stevengj authored and jschueller committed Apr 12, 2019
1 parent f52fe16 commit 16e200f
Show file tree
Hide file tree
Showing 17 changed files with 205 additions and 204 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ matrix:
- pip install mkdocs python-markdown-math --user
- PATH=$PATH:~/.local/bin mkdocs build
- mkdir build && pushd build
- cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_MATLAB=OFF -DNLOPT_FORTRAN=ON -DCMAKE_C_FLAGS='-Wall -Wextra' -DCMAKE_CXX_FLAGS='-Wall -Wextra' ..
- cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_MATLAB=OFF -DNLOPT_FORTRAN=ON -DCMAKE_C_FLAGS='-std=c89 -pedantic -D_POSIX_C_SOURCE=200112L -Wall -Wextra -Werror' -DCMAKE_CXX_FLAGS='-Wall -Wextra' ..
- make install -j2 && ctest -j2 --output-on-failure
- rm -rf * ~/.local
- cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_PYTHON=OFF -DNLOPT_OCTAVE=OFF -DNLOPT_GUILE=OFF -DNLOPT_MATLAB=OFF -DNLOPT_FORTRAN=ON -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/toolchain-x86_64-w64-mingw32.cmake ..
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ branches:
- master
environment:
matrix:
- CMAKE_PLATFORM: "Visual Studio 10 2010"
- CMAKE_PLATFORM: "Visual Studio 14 2015"
- CMAKE_PLATFORM: "Visual Studio 14 2015 Win64"
install:
Expand Down
2 changes: 1 addition & 1 deletion src/algs/ags/ags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int ags_minimize(unsigned n, nlopt_func func, void *data, unsigned m, nlopt_cons
{
if (fc[i].m != 1)
return NLOPT_INVALID_ARGS;
functions.push_back([fc, data, n, i](const double* x) {
functions.push_back([fc, n, i](const double* x) {
double val = 0;
nlopt_eval_constraint(&val, NULL, &fc[i], n, x);
return val;
Expand Down
19 changes: 10 additions & 9 deletions src/algs/ags/ags.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@
extern "C" {
#endif

//The algorithm supports 3 types of stop criterions: stop by execution time, stop by value and stop by exceeding limit of iterations.
/* The algorithm supports 3 types of stop criterions: stop by execution time, stop by value and stop by exceeding limit of iterations. */

int ags_minimize(unsigned n, nlopt_func func, void *data, unsigned m, nlopt_constraint *fc,
double *x, double *minf, const double *l, const double *u, nlopt_stopping *stop);

extern double ags_eps; //method tolerance in Holder metric on 1d interval. Less value -- better search precision, less probability of early stop.
extern double ags_r; //reliability parameter. Higher value of r -- slower convergence, higher chance to cache the global minima.
extern double eps_res; // parameter which prevents method from paying too much attention to constraints. Greater values of this parameter speed up convergence,
// but global minima can be lost.
extern unsigned evolvent_density; // density of evolvent. By default density is 2^-12 on hybercube [0,1]^N,
// which means that maximum search accuracyis 2^-12. If search hypercube is large the density can be increased accordingly to achieve better accuracy.
extern int ags_refine_loc; //refine the final optimum using built-in local optimizer
extern int ags_verbose; //print additional info
extern double ags_eps; /* method tolerance in Holder metric on 1d interval. Less value -- better search precision, less probability of early stop. */
extern double ags_r; /* reliability parameter. Higher value of r -- slower convergence, higher chance to cache the global minima. */
extern double eps_res; /* parameter which prevents method from paying too much attention to constraints. Greater values of this parameter speed up convergence,
but global minima can be lost. */
extern unsigned evolvent_density; /* density of evolvent. By default density is 2^-12 on hybercube [0,1]^N,
which means that maximum search accuracyis 2^-12. If search hypercube is large the density
can be increased accordingly to achieve better accuracy. */
extern int ags_refine_loc; /* refine the final optimum using built-in local optimizer */
extern int ags_verbose; /* print additional info */

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion src/algs/bobyqa/bobyqa.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static nlopt_result rescue_(int *n, int *npt, const double *xl, const double *xu
/* Local variables */
double f;
int i__, j, k, ih, jp, ip, iq, np, iw;
double xp = 0.0, xq, den;
double xp = 0.0, xq = 0.0, den;
int ihp = 0;
double one;
int ihq, jpn, kpt;
Expand Down
1 change: 0 additions & 1 deletion src/algs/cdirect/hybrid.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ static nlopt_result optimize_rect(double *r, params *p)
double minf;
nlopt_stopping *stop = p->stop;
nlopt_result ret;
nlopt_opt opt;

if (stop->maxeval > 0 &&
*(stop->nevals_p) >= stop->maxeval) return NLOPT_MAXEVAL_REACHED;
Expand Down
16 changes: 8 additions & 8 deletions src/algs/direct/DIRserial.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@
/* +-----------------------------------------------------------------------+ */
/* | SUBROUTINE for sampling. | */
/* +-----------------------------------------------------------------------+ */
/* Subroutine */ void direct_dirsamplef_(doublereal *c__, integer *arrayi, doublereal
*delta, integer *sample, integer *new__, integer *length,
FILE *logfile, doublereal *f, integer *free, integer *maxi,
/* Subroutine */ void direct_dirsamplef_(doublereal *c__, integer *arrayi, doublereal
*delta, integer *sample, integer *new__, integer *length,
FILE *logfile, doublereal *f, integer *free, integer *maxi,
integer *point, fp fcn, doublereal *x, doublereal *l, doublereal *
minf, integer *minpos, doublereal *u, integer *n, integer *maxfunc,
minf, integer *minpos, doublereal *u, integer *n, integer *maxfunc,
const integer *maxdeep, integer *oops, doublereal *fmax, integer *
ifeasiblef, integer *iinfesiblef, void *fcn_data, int *force_stop)
{
(void) logfile; (void) free; (void) maxfunc; (void) maxdeep; (void) oops;
(void) delta; (void) sample;

/* System generated locals */
integer length_dim1, length_offset, c_dim1, c_offset, i__1, i__2;
doublereal d__1;

/* Local variables */
integer i__, j, helppoint, pos, kret;

(void) logfile; (void) free; (void) maxfunc; (void) maxdeep; (void) oops;
(void) delta; (void) sample;

/* +-----------------------------------------------------------------------+ */
/* | JG 07/16/01 fcn must be declared external. | */
/* +-----------------------------------------------------------------------+ */
Expand Down Expand Up @@ -86,7 +86,7 @@
if (force_stop && *force_stop) /* skip eval after forced stop */
f[(pos << 1) + 1] = *fmax;
else
direct_dirinfcn_(fcn, &x[1], &l[1], &u[1], n, &f[(pos << 1) + 1],
direct_dirinfcn_(fcn, &x[1], &l[1], &u[1], n, &f[(pos << 1) + 1],
&kret, fcn_data);
if (force_stop && *force_stop)
kret = -1; /* mark as invalid point */
Expand Down
Loading

0 comments on commit 16e200f

Please sign in to comment.