Skip to content

Conversation

@ChrisRackauckas-Claude
Copy link

Summary

Fixes #1020

This PR adds a clear error message when NLopt's AUGLAG algorithms are used without specifying a local_method parameter, preventing undefined behavior.

Problem

As reported in #1020 and confirmed by @ChrisRackauckas, NLopt's AUGLAG algorithms require a local optimization method to function properly. When used without one:

  • The algorithm returns incorrect results (e.g., [0.0, 0.0] with Inf objective)
  • This is undefined behavior that should not be allowed

Solution

  • Added validation in __map_optimizer_args! to check if an AUGLAG algorithm is being used without a local_method
  • Throws a descriptive error message with usage example when this condition is detected
  • Added test cases to verify the error is thrown for both LN_AUGLAG and LD_AUGLAG

Test plan

✅ All existing tests pass
✅ Added specific test cases for the error condition
✅ Manually verified the fix resolves the issue described in #1020

🤖 Generated with Claude Code

…_method

Fixes SciML#1020

NLopt's AUGLAG algorithms require a local optimization method to be specified.
Previously, using them without a local_method would result in undefined behavior
(returning wrong results like [0.0, 0.0] with Inf objective).

This commit adds a clear error message when AUGLAG algorithms are used without
specifying a local_method parameter, helping users understand the correct usage.

Changes:
- Add check in __map_optimizer_args! to detect AUGLAG algorithms without local_method
- Provide helpful error message with usage example
- Add test cases to verify the error is thrown correctly

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Per review feedback, updated the AUGLAG algorithm check to directly compare
against the specific algorithm types (NLopt.LN_AUGLAG, NLopt.LD_AUGLAG,
NLopt.AUGLAG) rather than using string pattern matching.

This is cleaner and more maintainable.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@ChrisRackauckas ChrisRackauckas merged commit 07d369e into SciML:master Sep 29, 2025
45 of 71 checks passed
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.

Inconsistent Behavior Related to NLopt

2 participants