Optim.jl + adding constraints

I want to add equality constraints to Optim.jl (not just a box-constrained optimization). My understanding is that there were plans to add this feature. Does anybody know if this stalled? This package I see was intended to be merged with Optim.jl but I cannot presently find this feature in Optim.

If the feature is not yet added to Optim, does anyone know of any package that could give this “optimization with functional constraints” functionality? I am looking for something that does more or less what scipy.optimize in python does.

PS. I can easily add the constraint within JuMP but this is not an option right now.

1 Like

A lot depends on what your constraints look like (eg linear, nonlinear), so an MWE for at least the objective and the constraints could help.

Hi @Tamas_Papp. Thanks. It’s a relatively large decentralized dynamic growth model–I know you are an economist too–so it will take sometime to curve out a MWE. But will post it here when ready.

I decided to use scipy.optimize through PyCall. If any body is interested in the details. I can devote time to making a MWE and post the code here. It took some hours of googling and stackoverflow to figure out how I should parse arguments. Would not want others to go through the same pain.

FYI @Tamas_Papp, the model features non-linear constraints.

Maybe give GitHub - JuliaOpt/NLopt.jl: Package to call the NLopt nonlinear-optimization library from the Julia language a try?

Some of the optimizers in Optim support optimization on manifolds. All you need to do is implement a function that maps any point in Euclidean space to a nearby one on the manifold. Of course, it should be the identity on the manifold.

I extended Nelder-Mead to do this, too (it’s very simple). So, if you want to use that optimizer, look at https://github.com/danspielman/Optim.jl. It will probably be included in the main Optim.jl soon.

For the gradient based algorithms, you also need to code the gradient of the map.

2 Likes

Hi @jovansam – curious if you ever did this or found another MWE for scipy optimization from julia base code?

Check out this tutorial for using Optimization.jl with equality and inequality constraints:

https://docs.sciml.ai/Optimization/stable/tutorials/constraints/

3 Likes