-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Model file export #4305
base: main
Are you sure you want to change the base?
Model file export #4305
Conversation
this is interesting. I cannot use it as is. We cannot use iostream. The complex path is to implement gzip reading/writing in the File interface, which is a pain. |
Thanks @lperron . My first attempt was to not use iostream. I had to duplicate |
So, the best way to integrate it to add a field in the File class (ortools/base/file.h) that indicates if the file is a gzip one. For instance, the MPS reader uses the FileLine class, which is turns call File::Read() raw API. On the MPS writer, I would make sure that we flush the output string to file regularly, and that this flush is done by the File API, which internally would use the gzip API. Am I clear ? |
Yes, thanks again! I'll try my best to work on those parts. |
Please sync with main. You will have a conflict. The only missing is gzip support in File (and hooking to linear_solver C# if you want it). |
247818b
to
5b325e2
Compare
@lperron Thank you so much. I resolved the conflicts and called your function from linear_solver. Made it optional to export to gzip with a bool parameter. |
Write models to .mps files
We can export linear solver models and get a string as a result. However, when working with very large models, the process (.NET in my case) fails when the export method is called, due to string type's size limitation. In our use case, we don't actually need the exported model in memory, we write the string to a file. A method that directly writes to a file helps us overcome the limitation.
The file write method has been added by @lperron, which simplifies this PR.