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

Remove error throwing branch on FAILURE #218

Closed
wants to merge 4 commits into from

Conversation

Vaibhavdixit02
Copy link
Contributor

@Vaibhavdixit02 Vaibhavdixit02 commented Aug 12, 2024

The added test should demonstrate that it'll be useful to return the result even with FAILURE instead of throwing a very uninformative error.

@Vaibhavdixit02
Copy link
Contributor Author

I don't get the option to request reviews here, so pinging to bump it @stevengj @odow

opt.local_optimizer = Opt(:LD_LBFGS, 2)
opt.min_objective = rosenbrock
NLopt.equality_constraint!(opt, circ_cons, [1e-8])
(minf, minx, ret) = optimize(opt, [0.5, 0.5])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a test for the ret?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added it, but I am not sure why it gives failure

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean? Isn't the point of the test that it's a FAILURE?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant that given the results the FAILURE is suspicious. You are correct that the point of this test is that in such cases we shouldn't error but return the result.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cause is probably the nonlinear equality constraint (which is non convex)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but the constraint residual is below the set tolerance

julia> 1.0 -sum(abs2, minx)
6.695932697198259e-11

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure then

Copy link
Contributor Author

@Vaibhavdixit02 Vaibhavdixit02 Aug 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, but that's why this makes sense

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.57%. Comparing base (fb1e673) to head (d8d6e36).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #218      +/-   ##
==========================================
- Coverage   69.95%   66.57%   -3.38%     
==========================================
  Files           2        2              
  Lines         802      709      -93     
==========================================
- Hits          561      472      -89     
+ Misses        241      237       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Vaibhavdixit02
Copy link
Contributor Author

Can this be merged and tagged, please?

@odow
Copy link
Member

odow commented Aug 16, 2024

Why is this needed for SciML/Optimization.jl#799?

@Vaibhavdixit02
Copy link
Contributor Author

I am using the same test as the one added here, it's a pretty standard one so it shouldn't be throwing an error

@odow
Copy link
Member

odow commented Aug 16, 2024

The other option is to just relax the convergence tolerance?

opt.ftol_abs = 1e-10

@odow
Copy link
Member

odow commented Aug 16, 2024

@odow
Copy link
Member

odow commented Aug 16, 2024

I don't think this the right approach, because it avoids throwing an error for all methods that call chk.

@Vaibhavdixit02
Copy link
Contributor Author

Vaibhavdixit02 commented Aug 16, 2024

Do you have an example of what should throw an error that doesn't now since the tests seem to pass so I am curious? I think this branch may need more detailed conditions, just having a FAILURE retcode shouldn't be an error, it means the optimization wasn't successful (given the convergence criteria) but it doesn't mean there was an error?

@odow
Copy link
Member

odow commented Aug 16, 2024

chk is called after all ccalls.

I think you actually want to return from optimize regardless of the return code (not just FAILURE)?

@Vaibhavdixit02
Copy link
Contributor Author

Vaibhavdixit02 commented Aug 16, 2024

Oh I just realised what you mean in #218 (comment), I'd be happy with that it doesn't look like the error messages improve significantly over the return code right now

@odow
Copy link
Member

odow commented Aug 16, 2024

Closing in favor of #221. (I've added you as a co-author)

@odow odow closed this Aug 16, 2024
@Vaibhavdixit02
Copy link
Contributor Author

I didn't even know that's something you can do haha! Thanks for the help 🙌

@Vaibhavdixit02 Vaibhavdixit02 deleted the failurenoerror branch August 16, 2024 03:20
@odow
Copy link
Member

odow commented Aug 16, 2024

You add the line Co-authored-by: Vaibhavdixit02 <Vaibhavdixit02@users.noreply.github.com> to the bottom of the commit message

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

Successfully merging this pull request may close these issues.

3 participants