-
Notifications
You must be signed in to change notification settings - Fork 20
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
WIP: eliminate global cutest_lib #97
WIP: eliminate global cutest_lib #97
Conversation
Each nlp stores its own lib pointer, and calls pass this pointer to wrappers of the library routines Fixes some classes of bugs and removes the need to call finalize.
Thanks @timholy! The initial version of this package used to do just that: store the lib pointer inside the NLP. We ran into troubles that I can't recall, and it was changed to a global variable. It would be great if we could solve the multiple problem conundrum. Perhaps @abelsiqueira remembers better than I do. |
Wherever I go I see @timholy gets there first. I was also looking a CUTESt in a loop and run into the same issue. I support this PR or any other change that allows this. |
If it turns out there is some problem with this strategy (e.g., if there's some library that stores global state for the most recently-loaded problem), then a simpler approach will be to change that error message to direct users to call |
Hello @timholy . Thanks for this. I didn't realize I don't really remember if there were a main reason to not use On the other hand, the global |
Closing due to #51 (comment) |
I'll leave the branch around just in case someone comes up with a workaround, but feel free to delete it whenever you feel like it. |
I was writing code to test different models in a loop, and got the error "CUTEst: call cutest_finalize on current model first". I followed that advice, and encountered a nasty problem:
CUTEst.cutest_finalize(nlp)
cutest_lib
toNULL
right in the middle of an optimization. Boom.I didn't think to just try
finalize
, which would have worked much better. Instead, I reworked this package so thatnlp
object stores its own lib pointerThis eliminates the need to manually call
finalize
. As a side benefit, it also lets you have multiple problems loaded at once. It's a fairly big change, so I'll understand if you don't want it.The WIP is because the documentation needs to be updated, too.