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

Warm Start in NLP Solve #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Warm Start in NLP Solve #27

wants to merge 2 commits into from

Conversation

andrewcron
Copy link

Hi Everyone,

I've added a new feature to allow the appropriate parameters to be passed to solve to perform warm start optimization. (See http://www.coin-or.org/Ipopt/documentation/node49.html.) I've also included a new example variant of hs071_PY3.py to demonstrate the process.

The primary change is the option to pass the various bound multipliers returned from a previous optimization to the solve function as keyword only arguments along with some error checking. If they are passed mL, mU, and lambda in solve are initialized instead of passed as empty arrays. When the nlp.str_option('warm_start_init_point', 'yes') option is set, these arrays will be read and the optimization will pretty much pick up where it left off.

This helps solve a very common problem where the objective only changes slightly between runs of the optimizer, so we don't want to completely reinitialize if the optimization is expensive.

Thoughts?

Thanks!

@xuy
Copy link
Owner

xuy commented May 3, 2016

Nice. Let me take a closer look. Definitely in love with this patch/PR!!!

@tarun018 tarun018 mentioned this pull request Apr 16, 2017
Copy link

@Rlahuerta Rlahuerta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was testing and using python 2.7 is giving the following error:

Starting at previous solution and solving again
Traceback (most recent call last):
File "hs071_PY3_warm.py", line 147, in
mult_x_L=zl, mult_x_U=zu)
TypeError: argument 3 (impossible)

@andrewcron
Copy link
Author

It's been a year since I did this, but I'm pretty sure this is why I put "PY3" in the script name. I imagine someone could modify to support Python 2.

@economoser
Copy link

Has this already been merged into the master branch, @xuy ? Thank you very much!



nlp = pyipopt.create(nvar, x_L, x_U, ncon, g_L, g_U, nnzj, nnzh, eval_f, eval_grad_f, eval_g, eval_jac_g)
nlp.str_option('warm_start_init_point', 'yes')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I apologize for getting back to this PR after, hmm, two years. 😞

Just merged another PR of python3 support, so we have one version of hs071 as example. I wonder if the following 5 lines can be added to example with an if toggle.

@@ -551,8 +555,39 @@ PyObject *set_intermediate_callback(PyObject * self, PyObject * args)
}
}

PyObject *solve(PyObject * self, PyObject * args)
// too much cut and paste ...
#define SOLVE_CLEANUP() { \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for making it a macro!

{
static char *kwlist[] = {"x0", "userdata", "mult_g", "mult_x_L", "mult_x_U", NULL};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. there is a subtle API change here (from args to kwargs), let me actually play with it a bit before saying it is good or bad.

@g-braeunlich
Copy link

@andrewcron
I merged your pull request (with some changes) into my fork g-braeunlich/pyipopt

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

Successfully merging this pull request may close these issues.

5 participants