-
Notifications
You must be signed in to change notification settings - Fork 43
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
Please provide more examples for the C++ NL reader #74
Comments
Thanks for the feedback.
Good catch, fixed. I've added examples you suggested (in a single executable to avoid proliferation of build targets): https://github.com/ampl/mp/blob/master/src/nl-example.cc. It consists of the following NL handlers:
I thought the problem there was not the complexity of the API but the fact that Julia code cannot consume C++ interfaces. The API is pretty standard if you are familiar with modern parser interfaces like SAX or Clang parser API. The main difference is that the C++ NL reader uses static instead of dynamic polymorphism to keep performance on the level (in fact, better) of the ASL reader implemented in C. Hopefully the new examples will make the new API more approachable. If you have any problems with using it or ideas on how to improve the API or the documentation, please let me know. I'll be happy to help. |
Great! Unfortunately, it is late night here, one hour past my bedtime. I will play with this example code tomorrow. Many thanks for the quick response! |
I have taken a quick look at this new example code; I do not have questions at the moment. Unfortunately, I have deadlines to meet and I cannot spend more time on this but I will definitely will in the not too distant future. Thanks again for your help! |
Please provide more examples for the C++ nl reader. I have already found:
http://zverovich.net/2014/09/19/reading-nl-files.html
https://ampl.github.io/nl.html
The example on the blog seems weird. The function body of
ExprCounter.OnBinary()
returns nothing. The other example, theVarCounter.OnVariableRef(int)
returnsReference()
. How am I supposed to know what to return?Please provide at least the following self-contained examples.
Note that it is trivial to get these pieces of information from the nl file header. The nl file reader API should give us a similarly trivial way to get these data.
g
,J
andH
. It is different from thegjh
"solver" in that we only need the structural sparsity pattern, hence we avoid the need for evaluating theg
,J
andH
where the evaluation can fail (we may not easily find a suitable point for that).Note that it is fairly easy to get the structural sparsity pattern of
g
andJ
from the corresponding segment of the nl file, without having to evaluate them.Also note that if we are willing to, and we are able to evaluate
g
,J
andH
, it is trivial to parse the textual output of thegjh
solver. See also gjh fails with a strange error message #73Note that it is moderately easy to write a toy stack machine to do this, and in fact, I implemented one back in 2009 exactly for this purpose. (I gave up reverse engineering the nl file format when I ran into undocumented cases with V blocks referring to other V blocks, and with the linear and nonlinear parts split.)
The complexity of the nl reader C++ API is terrifying. As I understand, Miles and Jack already gave up, see JuliaSmoothOptimizers/AmplNLReader.jl#11 and as it currently stands, I would rather roll my own „ad hoc, informally-specified, bug-ridden, slow implementation of half of“ the nl reader by parsing the nl file as text and based on the Writing .nl files report.
I apologize if that was too harsh but I guess you do not realize the difficulty those people face who are not so familiar with the ASL and the nl file format as you are as an employee of the company.
Any help is greatly appreciated.
CC @mlubin @JackDunnNZ
The text was updated successfully, but these errors were encountered: