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

experiment with converting quadratic functions to nonlinear, to simplify/streamline code #67

Open
chriscoey opened this issue Jan 15, 2023 · 10 comments
Assignees

Comments

@chriscoey
Copy link
Contributor

Pavito is harder to maintain, debug, and read/understand while the quadratic functions are handled separately from the more general nonlinear functions.

after ScalarNonlinearFunction is finalized and jump-dev/MathOptInterface.jl#2059 is in, I think we should think about perhaps a bridge from ScalarQuadraticFunction to ScalarNonlinearFunction in MOI, or if not a bridge then a more manual conversion inside Pavito.

@odow any thoughts? I'd like to have a shot at this when the time is right.

@chriscoey chriscoey self-assigned this Jan 15, 2023
@chriscoey
Copy link
Contributor Author

Hmm I wonder if jump-dev/Ipopt.jl#320 slash jump-dev/MathOptInterface.jl#1397 may help here.

@blegat
Copy link
Member

blegat commented Jan 16, 2023

Yes, I agree that having a bridge from ScalarQuadraticFunction to ScalarNonlinearFunction would be ideal and would simplify Pavito but it seems to be hard to handle constraints one by one, see jump-dev/MathOptInterface.jl#2059 (comment)

@chriscoey
Copy link
Contributor Author

I'm a little confused about that point. if our problem has a bunch of ScalarQuadraticFunctions constraints and ScalarNonlinearFunction constraints, and we bridge the SQFs to SNFs, then we have a problem with all SNFs. and that pure nonlinear model can be handled with a single NLP block - so all grad, Hess etc oracles can be done in one go

@blegat
Copy link
Member

blegat commented Jan 16, 2023

Yes but it might be more efficient to create the grad/Hess oracles directly from the SQF and not from the SNF where we have lost the special quadratic structure. Otherwise, it could be bridged indeed, @odow is more familiar with the AD internals.

@chriscoey
Copy link
Contributor Author

Ok, I'd be surprised if it made much difference in practice, but yeah @odow would have a better idea than me of course.

@ccoffrin
Copy link
Collaborator

ccoffrin commented Jan 18, 2023 via email

@chriscoey
Copy link
Contributor Author

This would be an issue for the nonlinear solver, so we would want to preserve quadraticness there. but for deriving cuts from gradients for the OA mip solver, it shouldn't matter because the costs would surely be dwarfed.

@odow
Copy link
Member

odow commented Jan 19, 2023

I think we should think about perhaps a bridge from ScalarQuadraticFunction to ScalarNonlinearFunction in MOI

Yes. That's reasonable once we have an ScalarNonlinearExpression in MOI.

Jacobian and Hessian computations can be much faster for the subset of linear and quadratic expressions than general nonlinear expressions.

The default JuMP AD has support for detecting linear expressions, but not quadratic.

but for deriving cuts from gradients for the OA mip solver, it shouldn't matter because the costs would surely be dwarfed.

Yeah. For the trade-off, the overhead of Pavito going back and forward to the MIP solver, etc, is probably larger than the AD cost of explicit quadratic versus an NLP version of quadratic.

@odow
Copy link
Member

odow commented Sep 15, 2023

8 months later... we should take another look at this

@chriscoey
Copy link
Contributor Author

Yeah! I won't have time in the next few months I think, but happy if anyone else wants to try it

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

No branches or pull requests

4 participants