Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jagot/solvertraces.jl


https://github.com/jagot/solvertraces.jl

Last synced: 6 days ago
JSON representation

Awesome Lists containing this project

README

        

#+TITLE: SolverTraces.jl
#+AUTHOR: Stefanos Carlström
#+EMAIL: [email protected]

[[https://jagot.github.io/SolverTraces.jl/stable][https://img.shields.io/badge/docs-stable-blue.svg]]
[[https://jagot.github.io/SolverTraces.jl/dev][https://img.shields.io/badge/docs-dev-blue.svg]]
[[https://github.com/jagot/SolverTraces.jl/actions][https://github.com/jagot/SolverTraces.jl/workflows/CI/badge.svg]]
[[https://codecov.io/gh/jagot/SolverTraces.jl][https://codecov.io/gh/jagot/SolverTraces.jl/branch/master/graph/badge.svg]]

Small utility library for printing solver traces. Based around
[[https://github.com/JuliaString/Format.jl][Format.jl]] and [[https://github.com/KristofferC/Crayons.jl][Crayons.jl]].

* Usage example

#+BEGIN_SRC julia
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)
end
#+END_SRC

Output on Linux with 24 bit colours available:
[[file:figures/linux.png]]

Output on Windows with 16 colours available:
[[file:figures/windows.png]]

* Future ideas
- 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.