Consistent way to suppress solver output


Is there a consistent way to suppress the solver output in JuMP v0.19 or MOI? It isn’t clear to me if there is.


Not really; it’s all handled through each individual solver’s options API. As a hack, I suppose you could use

redirect_stdout(devnull) do
    # code here

but that doesn’t remove the overhead of the solver printing status info (which may or may not be a problem).


devnull is of type IO not IOStream:

ERROR: MethodError: no method matching redirect_stderr(::Base.DevNull)
Closest candidates are:
  redirect_stderr() at stream.jl:1001
  redirect_stderr(::Union{IOStream, Base.LibuvStream}) at stream.jl:995
  redirect_stderr(::Function, ::Any) at stream.jl:1051

What’s the best way to convert from IO to IOStream?


The solution I ended up with was:
redirect_stdout((()->optimize!(model)),open("/dev/null", "w"))


Yep. Sorry, should have tested my code. Related issue: