Gurobi does not display log

I am using Convex.jl in conjuction with Gurobi in a Jupyter notebook to solve a convex programming problem. Everything works but Gurobi is not displaying its log to the console in “realtime”, but it displays everything at once only at the end of the optimization. I tried to “force” the logging (even though it should be enabled by the default options), inizializing the optimizer with
opt = MOI.OptimizerWithAttributes(() -> Gurobi.Optimizer(GUROBI_ENV), "DisplayInterval" => 1, "OutputFlag" => 1, "LogToConsole" => 1)
but it does not work.
Is there a way to do it?

PS: I tried also with Mosek and CPLEX and in those cases everything works smoothly.

I have also seen this behavior, specifically with Gurobi. I believe this occurs because Gurobi’s log is buffered before being displayed. I do not know how to control this, nor whether it’s possible to do so.

1 Like

Actually, I tried to run the same code in the REPL and it works smoothly. So it seems a problem of Gurobi and Jupyter.

1 Like

You could try using the Logging standard library, e.g.

Thank you for this suggestion. I tried, but it does not work

How long does Gurobi take? If it’s less than a 1s then it looks like as you say. For a longer running problem it looks as expected (e.g. I tried Convex.jl/docs/src/examples/general_examples/robust_approx_fitting.jl with m = 2000; n = 1000;)

1 Like

just to note that version of the example is for v0.16.0 of Convex.jl which is about to be released; the version for the latest existing release v0.15.4 is here (and in rendered form here).

So if anyone tries the example and gets an error about e.g. silent not being accepted by solve!, try that v0.15.4 version of the example instead, or ] add Convex#master to update to the not-yet-released v0.16 of Convex.jl.

It takes way more then 1s (in fact, it requires between 2 and 3 minutes)