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

Reuse existing MadNLPSolver #213

Open
baggepinnen opened this issue Aug 31, 2022 · 4 comments
Open

Reuse existing MadNLPSolver #213

baggepinnen opened this issue Aug 31, 2022 · 4 comments

Comments

@baggepinnen
Copy link
Contributor

The construction of an MadNLPSolver allocates a lot of memory, and repeatedly solving similar optimization problems by defining a new MadNLPSolver for each problem is thus associated with a lot of overhead.

Would it be possible to come up with either

  1. An interface to update things like the initial guess (warm start), upper and lower bounds etc.
  2. A constructor of MadNLPSolver that takes an existing MadNLPSolver to re-use the allocated memory

My motivation is solving MPC problems where each consecutive differs from the last only in numerical values of bounds, the structure remains the same.

@sshin23
Copy link
Member

sshin23 commented Aug 31, 2022

Can't this be achieved with the current solve! function (of course, after your PR #215 is merged 😅)?

@baggepinnen
Copy link
Contributor Author

baggepinnen commented Aug 31, 2022

Maybe, I haven't fully understood everything that's going on yet 😃 The problem I'm having is that I'm not sure how to update the constraint bounds, the solve! function accepts zl, zu which are the dual variables after reformulation as well as y which is the dual before reformulation? It does not accept new constraint bounds, which is what I'd need to provide. Looking at reinitialize!, it does not appear to manipulate any constraint bounds either.

Also, shouldn't the counters

cnt = MadNLPCounters(start_time=time())

be reset in reinitialize!? Otherwise the solver will eventually stop immediately due to the maximum count/time etc. having been reached already before the call to solve!.

@sshin23
Copy link
Member

sshin23 commented Aug 31, 2022

ah, I see your point. Currently, in MadNLP we don't support updating ips.xl and ips.xu (the upper and lower bounds), and only support updating ips.x, ips.y, ips.zl, ips.zu. Indeed adding the capability to reset bounds might be a good improvement.

For the counter, it might be necessary to separately keep the cumulate solution time and the last solution time

cc: @frapac

@frapac
Copy link
Collaborator

frapac commented Aug 31, 2022

I think supporting reusing the MadNLP solver would be a net improvement (even compared to Ipopt). It should not be difficult to implement, but we have to do that with care.

One issue I am seeing is that we are duplicating the info between the NLPModels nonlinear model and the solvers. The questions I have are:

  • do we have functions in the NLPModels' API to update the upper and lower bounds?
  • how to specify to MadNLP that the nonlinear model has been updated?

They did some work recently in JuMP that may be related:
jump-dev/Ipopt.jl#321
jump-dev/JuMP.jl#3018

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

No branches or pull requests

3 participants