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

FORCED_STOP from OptimizationNLopt callback returns best point PRIOR to callback, making it unuseful for custom stopping criteria. Is that intended? #767

Open
donboyd5 opened this issue May 29, 2024 · 2 comments
Labels
question Further information is requested

Comments

@donboyd5
Copy link

Question❓

An OptimizationNLopt solve that results in FORCED_STOP from a callback will return not the point that generated the stop, but the previous best point. Perhaps this is intended, but it means defining stopping criteria in the callback will not be useful. (For related background see this issue).

For example, suppose the callback function defines complex stopping criteria, and those criteria are met on iteration 4, at which point the callback function returns true. Suppose the objective function values on iterations 1 through 4 are 1000, 10, 100, and 1. The callback will return the sol.u values from iteration 2, when the objective value was 10, not the sol.u values from iteration 4 when the objective value was 1.

This means we do not recover the point at which the complex stopping criteria were met - a point we likely want.

The test code lines 75-84, copied below, seems to recognize this and suggest that this behavior results from NLopt rather than Optimization.NLopt -- see the comment "#nlopt gives the last best not the one where callback stops" on line 82, copied below. (Incidentally, the test does not appear to call the callback.)

Is this desirable, and if not, is there a way to work around it? At least in my case, it is not desired - I'd like to be able to get the point that generated the FORCED_STOP, because it met my stoppping criteria.

Many thanks.

    @testset "callback" begin
        cbstopping = function(state, loss)
            println(state.iter, " ", state.u, " ", state.objective)
            return state.objective < 0.7
        end

        sol = solve(prob, NLopt.LD_LBFGS())
        #nlopt gives the last best not the one where callback stops
        @test sol.objective < 0.8
    end
@donboyd5 donboyd5 added the question Further information is requested label May 29, 2024
@Vaibhavdixit02
Copy link
Member

This is an upstream issue I am not sure if we can handle it here unfortunately. I'll try to ask if someone knows how to make NLopt not do this 😅

@donboyd5
Copy link
Author

donboyd5 commented May 29, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants