Small utility library for printing solver traces. Based around Format.jl and Crayons.jl.
using SolverTraces
using Format
using Crayons
# Custom column type, needs to inherit TraceColumn and have a fmt
# field.
struct Random{R<:Real} <: TraceColumn
    fmt::FormatExpr
    lc::LinearColorant{R}
    header::String
end
Random(::Type{R}=Float64) where R =
    Random{R}(FormatExpr("{1:s}{2:9.3e}$(crayon"reset")"),
            LinearColorant(1.0, 0.0, SolverTraces.red_green_scale()),
            "   Random")
# Also needs to be callable with current step as argument.
function (c::Random)(i::Integer)
    n = rand()
    c.lc(n), n
end
num_steps = 1000
load = 10
trace = SolverTrace(num_steps,
                    CurrentStep(num_steps),
                    Performance(load), # How much load per second can be handled
                    Random())
print_header(trace)
for i = 1:num_steps
    sleep(0.0001rand())
    SolverTraces.next!(trace)
endOutput on Linux with 24 bit colours available:
  
Output on Windows with 16 colours available:
  
- Nested solver traces for algorithms where each step necessitates inner solves. It would be interesting to support such cases and have togglable visibility of nested traces.
 - Output to other backends than the terminal, e.g. HTML: asynchronous display of solver trace in the web browser of a computation running remotely.