Streaming of log to buffer (instead of going through a file)
AnsweredWe wrap Gurobi in our models and deliver these in library form to internal downstream applications and their teams. There is not necessary a a file system present during execution (think kind of serverless), nor do our modelling dlls control any aspect of the execution environment. We would like to access solver logs - but can not choose any file system location, as this is an operational aspect.
Preferrably I would like to register a streaming callback in the API (some kind of StringWriter) and let the solver stream the log into a buffer under modelling library control.
A secondary option would be to buffer the whole log internally (with a flag like LogToConsole - Gurobi Optimization) ... LogToBuffer or extending LogToConsole with a third option, and retrieve the buffered log contents. This would be less realtime, but sufficient for batch processing.
-
Hi Christoph,
Maybe you could use a MESSAGE callback to retrieve the log lines programmatically and then log this into a buffer from your code.
If you are using Gurobi Instant Cloud, you could also use the REST API to query the log of an active job.
Does one of these options work for you?
Best regards,
Elisabeth
0 -
The callback way seems doable. I knew about callbacks, but only ever associated them with the solution process (not logging ...). Thanks, I will try this out.
For posteriority, here is the .NET version:
* Register a callback in the model (prior to solve): https://www.gurobi.com/documentation/current/refman/cs_model_setcb_.html#dotnetmethod:GRBModel.SetCallback
* Create a concrete subclass of https://www.gurobi.com/documentation/current/refman/cs_cb_.html
* Follow the example code in https://www.gurobi.com/documentation/current/examples/cb_cs_cs.html
0 -
Great to read that the callbacks may work. Thanks for posting the .NET references!
0 -
We have a Knowledge Base article that could be of interest here : How do I use Gurobi logging with Microsoft.Extensions.Logging?
0
Please sign in to leave a comment.
Comments
4 comments