Skip to content
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

Incorrect x0 in LN_PRAXIS #575

Closed
dweindl opened this issue Nov 25, 2024 · 2 comments
Closed

Incorrect x0 in LN_PRAXIS #575

dweindl opened this issue Nov 25, 2024 · 2 comments
Labels

Comments

@dweindl
Copy link

dweindl commented Nov 25, 2024

What happened?

Since 6a9fbb0, LN_PRAXIS uses some x0 different from the one passed to optimize.

How to reproduce the issue?

Reproducible with the following example (adapted from test/t_python.py):

import nlopt
from numpy.testing import assert_allclose
import math as m
import sys

def myfunc(x, grad):
    print(f"x: {x}")
    assert_allclose(x, [0.1, 0.1], rtol=1e-2, atol=1e-16)
    if grad.size > 0:
        grad[0] = 0.0
        grad[1] = 0.5 / m.sqrt(x[1])
    return m.sqrt(x[1])

algo = nlopt.LN_PRAXIS
opt = nlopt.opt(algo, 2)
print(f"algo: {opt.get_algorithm_name()}")
opt.set_lower_bounds([0, 0])
opt.set_upper_bounds([0.5, 0.5])
opt.set_min_objective(myfunc)
opt.set_maxeval(1)
x0 = [0.1, 0.1]
x = opt.optimize(x0)

6a9fbb0:
passes the unexpected x=array([0.31706 , 0.317049]) in the first call to myfunc

4d57a8a:
passes the expected x=array([0.0 , 0.0]) in the first call to myfunc

Version

v2.9.0-2-g6a9fbb0

bad: 6a9fbb0
good: 4d57a8a

Note that this also affects nlopt==2.9.0 on PyPI (https://github.com/DanielBok/nlopt-python), which seems to be based on some more recent nlopt than v2.9.0 / c500b50.

Operating System

Linux

Installation media

from source

Additional Context

No response

@jschueller
Copy link
Collaborator

jschueller commented Nov 25, 2024

indeed the inverse transformation is wrong, also the wheel on pypi uses the wrong commit: DanielBok/nlopt-python#43
I'm pushing a new 2.9.1 version with the fix so hopefully other users do not pick up the 2.9.0 from pypi that contains a non-stable commit

@dweindl
Copy link
Author

dweindl commented Nov 25, 2024

Great, thanks for the quick response.

dweindl added a commit to dweindl/pyPESTO that referenced this issue Nov 25, 2024
We want to avoid nlopt-python 2.9.0 because it does not match nlopt v2.9.0 and is affected by stevengj/nlopt#575.

Closes ICB-DCM#1511.
github-merge-queue bot pushed a commit to ICB-DCM/pyPESTO that referenced this issue Nov 26, 2024
We want to avoid nlopt-python 2.9.0 because it does not match nlopt v2.9.0 and is affected by stevengj/nlopt#575.

Closes #1511.
dweindl added a commit to ICB-DCM/pyPESTO that referenced this issue Nov 26, 2024
We want to avoid nlopt-python 2.9.0 because it does not match nlopt v2.9.0 and is affected by stevengj/nlopt#575.

Closes #1511.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants