From d7e444710b11ba504b7eb1f8e73c414dc2749a2d Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Fri, 25 Oct 2024 19:49:46 +0200 Subject: [PATCH] POP --- src/api/optimize.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/api/optimize.c b/src/api/optimize.c index 8159309d..ab89e1d2 100644 --- a/src/api/optimize.c +++ b/src/api/optimize.c @@ -394,7 +394,7 @@ static int elimdim_wrapcheck(nlopt_opt opt) /*********************************************************************/ -#define POP(defaultpop) (opt->stochastic_population > 0 ? opt->stochastic_population : (nlopt_stochastic_population > 0 ? nlopt_stochastic_population : (defaultpop))) +#define POP(defaultpop) (opt->stochastic_population > 0 ? (int)opt->stochastic_population : (nlopt_stochastic_population > 0 ? nlopt_stochastic_population : (defaultpop))) /* unlike nlopt_optimize() below, only handles minimization case */ static nlopt_result nlopt_optimize_(nlopt_opt opt, double *x, double *minf) @@ -532,7 +532,7 @@ static nlopt_result nlopt_optimize_(nlopt_opt opt, double *x, double *minf) #ifdef NLOPT_CXX if (!finite_domain(n, lb, ub)) RETURN_ERR(NLOPT_INVALID_ARGS, opt, "finite domain required for global algorithm"); - if (!stogo_minimize(ni, f, f_data, x, minf, lb, ub, &stop, algorithm == NLOPT_GD_STOGO ? 0 : (int) POP(2 * n))) + if (!stogo_minimize(ni, f, f_data, x, minf, lb, ub, &stop, algorithm == NLOPT_GD_STOGO ? 0 : POP(2 * (int)n))) return NLOPT_FAILURE; break; #else @@ -605,7 +605,7 @@ static nlopt_result nlopt_optimize_(nlopt_opt opt, double *x, double *minf) case NLOPT_GN_CRS2_LM: if (!finite_domain(n, lb, ub)) RETURN_ERR(NLOPT_INVALID_ARGS, opt, "finite domain required for global algorithm"); - return crs_minimize(ni, f, f_data, lb, ub, x, minf, &stop, (int) POP(0), 0); + return crs_minimize(ni, f, f_data, lb, ub, x, minf, &stop, POP(0), 0); case NLOPT_G_MLSL: case NLOPT_G_MLSL_LDS: @@ -646,7 +646,7 @@ static nlopt_result nlopt_optimize_(nlopt_opt opt, double *x, double *minf) nlopt_set_xtol_rel(local_opt, 1e-7); } push_force_stop_child(opt, local_opt); - ret = mlsl_minimize(ni, f, f_data, lb, ub, x, minf, &stop, local_opt, (int) POP(0), algorithm >= NLOPT_GN_MLSL_LDS && algorithm != NLOPT_G_MLSL); + ret = mlsl_minimize(ni, f, f_data, lb, ub, x, minf, &stop, local_opt, POP(0), algorithm >= NLOPT_GN_MLSL_LDS && algorithm != NLOPT_G_MLSL); pop_force_stop_child(opt); if (!opt->local_opt) nlopt_destroy(local_opt); @@ -793,7 +793,7 @@ static nlopt_result nlopt_optimize_(nlopt_opt opt, double *x, double *minf) case NLOPT_GN_ISRES: if (!finite_domain(n, lb, ub)) RETURN_ERR(NLOPT_INVALID_ARGS, opt, "finite domain required for global algorithm"); - return isres_minimize(ni, f, f_data, (int) (opt->m), opt->fc, (int) (opt->p), opt->h, lb, ub, x, minf, &stop, (int) POP(0)); + return isres_minimize(ni, f, f_data, (int) (opt->m), opt->fc, (int) (opt->p), opt->h, lb, ub, x, minf, &stop, POP(0)); case NLOPT_GN_ESCH: if (!finite_domain(n, lb, ub))