-
Notifications
You must be signed in to change notification settings - Fork 224
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
optim-julep: define AbstractProblem and make use of it in optimizers #163
Comments
OOQP was designed to handle cases like this. Definitely a useful idea to abstract over the linear algebra to the extent possible. |
Personally, I would also prefer the route of optimizing types instead of functions (which is what you mean, I think?). This would allow for neat tricks when it comes to Machine Learning. But as far as I was able to tell there was a strong preference towards optimizing Julia functions directly (#128 (comment)), so I abandoned that branch. Has this changed? I remember there was a lot of code to go through to abstract the |
I like #128, thanks for pointing me to it. Very much in line with this proposal. |
Hard to say now because AFAIK 0.5 brings new goodies to functions (i.e. the Anyhow the idea was to replace the concrete call sites like https://github.com/JuliaOpt/Optim.jl/blob/master/src/bfgs.jl#L71 , with custom functions like In machine learning this would be especially nice since the optimization problems there usually depend on constant parameters (i.e. the data). Right now solving such problems require boilerplate and closures like this https://github.com/JuliaOpt/Optim.jl#optimizing-functions-that-depend-on-constant-parameters . Allowing custom types could hide this complexity, enable compile time dispatch, and allow for inlining. So was my thinking at least. |
i think this is pretty much possible now. Just create your differentiable using the full constructor. Please reopen or open another issue if you have a specific problem (or you can share the original one) |
Today I encountered an optimization problem with special structure: the Hessian (which I believe I can calculate analytically) is, say, typically around 20k-by-20k (ranging from 2k-by-2k to 200k-by-200k), and essentially every entry is nonzero---so it is not sparse. However, it can be parametrized as a rank-4 modification of a block-diagonal matrix (with 3x3 blocks), and in this representation it is amenable to very efficient solution by the Woodbury matrix identity.
Assuming one can't coax Ipopt or similar packages to make use of such special structure, this reminds me yet again of the advantages of being able to perform optimization using purely julia code.
However, it looks like Optim may need some work to support this kind of thing. In particular, statements like this one will wreak havoc. I'm guessing the best approach would be to have problems specified as subtypes of an
AbstractProblem
type, and the user callsoptimize(problem, x, options...)
. This could contain theTwiceDifferentiableFunction
, but might also allow specialization of a method likeH = allocate_hessian(problem)
. Does this seem reasonable?I could just add this to #50 (which is the branch I use for all my own work anyway), but obviously I should eventually get around to putting that in shape for merging, so it would be best to get some consensus about any other APIs I introduce. This looks like a relatively independent refactoring from the very nice #149, and we might want to get that finished off before undertaking this.
The text was updated successfully, but these errors were encountered: