-
Notifications
You must be signed in to change notification settings - Fork 73
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
base: master
Are you sure you want to change the base?
Conversation
Nice. Let me take a closer look. Definitely in love with this patch/PR!!! |
There was a problem hiding this 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)
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. |
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') |
There was a problem hiding this comment.
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() { \ |
There was a problem hiding this comment.
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}; |
There was a problem hiding this comment.
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.
@andrewcron |
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 ofhs071_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 passedmL
,mU
, andlambda
insolve
are initialized instead of passed as empty arrays. When thenlp.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!