Skip to content

Keep BOBYQA and COBYLA unscaled coordinates within original bounds - #648

Open
CAOShurong wants to merge 3 commits into
stevengj:masterfrom
CAOShurong:codex/bobyqa-original-bounds
Open

CAOShurong wants to merge 3 commits into
stevengj:masterfrom
CAOShurong:codex/bobyqa-original-bounds

Conversation

@CAOShurong

@CAOShurong CAOShurong commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #625.

Unscaling BOBYQA coordinates can round a point outside the original bounds, including points passed to the objective. Reusing a returned point can then fail with INVALID_ARGS. COBYLA callbacks can encounter the same roundoff.

Move bounds snapping into nlopt_unscale and use it for BOBYQA and COBYLA callbacks and returned coordinates. BOBYQA still leaves the input untouched when scaling is rejected before transformation.

C regressions cover lower and upper bounds, default/equal/unequal/negative steps, returned-point reuse, and COBYLA objective and constraint callbacks.

Verified on Windows/MSVC: 110 CTest tests, 80 C-only AddressSanitizer tests, installed C/C++/Python interfaces, 216 BOBYQA configurations with unchanged results and callback traces, and 24 COBYLA configurations. The new COBYLA regression fails 12 cases against the previous library and passes all 24 with this change.

Comment thread src/algs/bobyqa/bobyqa.c Resolved
@stevengj

Copy link
Copy Markdown
Owner

This looks good, but I would rather change the nlopt_unscale to itself take lb and ub parameters and do the bounds-snapping itself. Then also call this in cobyla.c, which potentially has the same problem with unscaling.

@CAOShurong CAOShurong changed the title Keep BOBYQA evaluations and results within original bounds Keep BOBYQA and COBYLA unscaled coordinates within original bounds Oct 17, 2026
@CAOShurong

Copy link
Copy Markdown
Contributor Author

Moved bounds snapping into nlopt_unscale and routed both BOBYQA and COBYLA through it. The new COBYLA regressions cover objective/constraint callbacks and returned-point reuse; 110 CTest tests and 80 AddressSanitizer tests pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BOBYQA violates bounds constraints by roundoff error

3 participants