Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jschueller committed Oct 25, 2024
1 parent 2bff3e6 commit d92e915
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/algs/ags/solver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ namespace
const std::vector<double>& leftBound, const std::vector<double>& rightBound)
{
mFunctions = functions;
mConstraintsNumber = mFunctions.size() - 1;
mDimension = leftBound.size();
mConstraintsNumber = static_cast<unsigned int>(mFunctions.size() - 1);
mDimension = static_cast<unsigned int>(leftBound.size());
mLeftBound = leftBound;
mRightBound = rightBound;
}
Expand Down
6 changes: 3 additions & 3 deletions src/algs/bobyqa/bobyqa.c
Original file line number Diff line number Diff line change
Expand Up @@ -1979,12 +1979,12 @@ static nlopt_result bobyqb_(int *n, int *npt, double *x,
int ksav;
double gqsq, dist, sumw, sumz, diffa, diffb, diffc = 0.0, hdiag;
int kbase;
double alpha, delta, adelt, denom, fsave, bdtol, delsq;
double alpha = 0.0, delta, adelt = 0.0, denom, fsave, bdtol, delsq;
int nresc, nfsav;
double ratio, dnorm, vquad, pqold, tenth;
double ratio = 0.0, dnorm, vquad, pqold, tenth;
int itest;
double sumpq, scaden;
double errbig, cauchy, fracsq, biglsq, densav;
double errbig, cauchy = 0.0, fracsq, biglsq, densav;
double bdtest;
double crvmin, frhosq;
double distsq;
Expand Down
4 changes: 2 additions & 2 deletions src/algs/crs/crs.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static int crs_compare(double *k1, double *k2)
{
if (*k1 < *k2) return -1;
if (*k1 > *k2) return +1;
return k1 - k2; /* tie-breaker */
return (int)(k1 - k2); /* tie-breaker */
}

/* set x to a random trial value, as defined by CRS:
Expand All @@ -67,7 +67,7 @@ static void random_trial(crs_data *d, double *x, rb_node *best)

/* initialize x to x_0 = best point */
memcpy(x, best->k + 1, sizeof(double) * n);
i0 = (best->k - ps) / n1;
i0 = (int)((best->k - ps) / n1);

jn = nlopt_iurand(n); /* which of remaining n points is "x_n",
i.e. which to reflect through ...
Expand Down
2 changes: 1 addition & 1 deletion src/algs/neldermead/nldrmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static int simplex_compare(double *k1, double *k2)
{
if (*k1 < *k2) return -1;
if (*k1 > *k2) return +1;
return k1 - k2; /* tie-breaker */
return (int)(k1 - k2); /* tie-breaker */
}

/* return 1 if a and b are approximately equal relative to floating-point
Expand Down
4 changes: 2 additions & 2 deletions src/algs/stogo/tools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ bool TBox::CloseToMin(RVector &vec, double *objval, double eps_cl) {
return FALSE;
}

unsigned int TBox::NStationary() {
int TBox::NStationary() {
// Returns the number of trials in a box
return TList.size() ;
return static_cast<int>(TList.size());
}

void TBox::split(RTBox B1, RTBox B2) {
Expand Down
2 changes: 1 addition & 1 deletion src/algs/stogo/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class TBox: public VBox {
void ClearBox();
bool CloseToMin(RVector&, double*, double);

unsigned int NStationary(); // Returns the number of stationary points
int NStationary(); // Returns the number of stationary points

void split(RTBox, RTBox); // Split a box
void dispTrials();
Expand Down
8 changes: 4 additions & 4 deletions src/api/nlopt-in.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ namespace nlopt {
d->mf = mf;
d->f_data = f_data;

mythrow(nlopt_add_inequality_mconstraint(o, tol.size(), mymfunc, d,
mythrow(nlopt_add_inequality_mconstraint(o, static_cast<unsigned int>(tol.size()), mymfunc, d,
tol.empty() ? NULL : &tol[0]));
}

Expand Down Expand Up @@ -453,7 +453,7 @@ namespace nlopt {
d->mf = mf;
d->f_data = f_data;

mythrow(nlopt_add_equality_mconstraint(o, tol.size(), mymfunc, d,
mythrow(nlopt_add_equality_mconstraint(o, static_cast<unsigned int>(tol.size()), mymfunc, d,
tol.empty() ? NULL : &tol[0]));
}

Expand Down Expand Up @@ -489,7 +489,7 @@ namespace nlopt {
d->munge_destroy = md;
d->munge_copy = mc;

mythrow(nlopt_add_inequality_mconstraint(o, tol.size(), mymfunc, d,
mythrow(nlopt_add_inequality_mconstraint(o, static_cast<unsigned int>(tol.size()), mymfunc, d,
tol.empty() ? NULL : &tol[0]));
}
void add_equality_mconstraint(mfunc mf, void *f_data,
Expand All @@ -501,7 +501,7 @@ namespace nlopt {
d->munge_destroy = md;
d->munge_copy = mc;

mythrow(nlopt_add_equality_mconstraint(o, tol.size(), mymfunc, d,
mythrow(nlopt_add_equality_mconstraint(o, static_cast<unsigned int>(tol.size()), mymfunc, d,
tol.empty() ? NULL : &tol[0]));
}

Expand Down
2 changes: 1 addition & 1 deletion src/api/optimize.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ static nlopt_result nlopt_optimize_(nlopt_opt opt, double *x, double *minf)
nlopt_set_ftol_abs(dual_opt, nlopt_get_param(opt, "dual_ftol_abs", LO(ftol_abs, 0.0)));
nlopt_set_xtol_rel(dual_opt, nlopt_get_param(opt, "dual_xtol_rel", 0.0));
nlopt_set_xtol_abs1(dual_opt, nlopt_get_param(opt, "dual_xtol_abs", 0.0));
nlopt_set_maxeval(dual_opt, nlopt_get_param(opt, "dual_maxeval", LO(maxeval, 100000)));
nlopt_set_maxeval(dual_opt, (int)nlopt_get_param(opt, "dual_maxeval", LO(maxeval, 100000)));
#undef LO
if (algorithm == NLOPT_LD_MMA)
ret = mma_minimize(n, f, f_data, opt->m, opt->fc, lb, ub, x, minf, &stop, dual_opt, inner_maxeval, (unsigned)verbosity, rho_init, opt->dx);
Expand Down
4 changes: 2 additions & 2 deletions src/util/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ double nlopt_seconds(void)
gettimeofday(&tv, NULL);
return (tv.tv_sec - start.tv_sec) + 1.e-6 * (tv.tv_usec - start.tv_usec);
#elif defined(HAVE_TIME)
return time(NULL);
return (double)time(NULL);
#elif defined(_WIN32) || defined(__WIN32__)
static THREADLOCAL ULONGLONG start;
FILETIME ft;
Expand Down Expand Up @@ -82,7 +82,7 @@ unsigned long nlopt_time_seed(void)
gettimeofday(&tv, NULL);
return (tv.tv_sec ^ tv.tv_usec);
#elif defined(HAVE_TIME)
return time(NULL);
return (unsigned long)time(NULL);
#elif defined(_WIN32) || defined(__WIN32__)
FILETIME ft;
GetSystemTimeAsFileTime(&ft);
Expand Down

0 comments on commit d92e915

Please sign in to comment.