nlopt
nlopt copied to clipboard
Provide API to compute Lagrange multipliers
I am using the package mainly via python API, I am wondering if there is a way I could get the Lagrangian multiplier from the auglag().
No, the C API doesn't provide this.
Note that, given a local optimum (i.e. the NLopt result), you can easily compute Lagrange multipliers simply by solving a small least-squares problem. See e.g. https://discourse.julialang.org/t/lagrangian-function/38287/19?u=stevengj
@stevengj Thank you for your answer!
When you mentioned local optimum, does the type of solver relevant here? Can it be a local optimum found by solvers (say MMA) other than the AUGLAG solver?
The type of solver doesn't matter. For any solver that returns a local optimum, the KKT equations tell you how to compute Lagrange multipliers.
I've renamed this issue and marked it as an "enhancement", as it would be nice to have a built-in API for this.
@stevengj Thanks for marking this as an "enhancement".
I have a quick question on lagrangian optimisation and hope you could share some insights.
Let's say we have a maximisation problem with one inequality constraint.
Instead of solving it as a constraint problem, is there any problem of solving this as a non-constraint problem (i.e. max objective_function + lambda * constraint_function)? We solve this multiple times with different lambda values and at the end pick a lambda that suits our needs?
The reason I asked this is because solving a non-constraint problem is usually much faster than a constraint problem.