-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FAILURE with L-BFGS depending on system size and starting point #198
Comments
I can confirm the failure, but I don't have any suggestions. This is likely an issue in the upstream https://github.com/stevengj/nlopt.
I will note that this is a very large problem then! You could try relaxing the different tolerances. |
I've reproduced this in C, so this is not a bug in the Julia library: #include <nlopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
double callback(unsigned int n, const double *x, double *grad, void* user_data) {
if (grad != NULL) {
for (int i = 0; i < n; i++) {
grad[i] = -50 + 300 * log(x[i]);
}
}
double ret = 0.0;
for (int i = 0; i < n; i++) {
ret += -50 * x[i] + 300 * x[i] * (log(x[i]) - 1);
}
printf(" obj = %f\n", ret);
return ret;
}
int test(int n) {
nlopt_result ret;
double *lb = (double *)malloc(n * sizeof(double));
double *x = (double *)malloc(n * sizeof(double));
double target = 1.1813604128656459;
nlopt_opt opt = nlopt_create(NLOPT_LD_LBFGS, n);
ret = nlopt_set_ftol_rel(opt, 1e-10);
for (int i = 0; i < n; i++) {
lb[i] = 1e-2;
x[i] = target * (1 + 1e-3 * (2 * (double)rand() / (double)RAND_MAX - 1));
}
ret = nlopt_set_lower_bounds(opt, lb);
ret = nlopt_set_min_objective(opt, callback, NULL);
double obj_f = 0.0;
ret = nlopt_optimize(opt, x, &obj_f);
printf("n = %d : nlopt_optimize: %d\n", n, ret);
nlopt_destroy(opt);
free(lb);
free(x);
return 0;
}
int main() {
test(62339366);
test(62339365);
return 0;
}
|
Closing because this is not a bug in NLopt.jl. It seems likely that the There are a few open issues for LBFGS that end in FAILURE: stevengj/nlopt#416, stevengj/nlopt#40 |
Hi! I am facing a
FAILURE
when trying to minimize a function with 62339366 variables using L-BFGS with a box constraint. The issue does not appear when using just one less variable.The function is$f: \vec x\mapsto \sum_i -50x_i + 300 x_i(\log(x_i) - 1)$ where $\vec x$ is a vector of 62339366 variables $x_i$ . The box constraint is that the $x_i$ should be above a fixed $(\vec\nabla f(\vec x))_i = -50 + 300\log(x_i)$ does not diverge. The exact value of
SMALL_CONSTANT
, for example0.01
, so thatSMALL_CONSTANT
does not matter here, the same issue occurs usingSMALL_CONSTANT = 1e-100
.The numerical solution should be a vector of$-50 + 300\log(\omega) \approx 0$ . The initial point is a vector of numbers uniformly taken in $[(1-η)ω;\ (1+η)ω]$ where
ω = 1.1813604128656459
, sinceη = 0.001
for instance.Here is the minimal reproducer (I think it requires having 16GiB RAM):
and the observations:
If I use the target value
ω
directly as initialization (i.e. takingη = 0
), then it works:And if I set the starting point too close to the target, i.e.$η$ too small, for instance
η = 1e-9
, then it fails for both cases, but it does not perform the same number of steps:May be related to #33. The last point (optimization fails if the initial point is too close to the optimum) reflects #33 (comment), but the difference between 62339365 and 62339366 variables is new I think? My real problem is of course more complex and even larger than 62339366 variables.
The text was updated successfully, but these errors were encountered: