diff --git a/src/ModelAnalyzer.jl b/src/ModelAnalyzer.jl index 7f4040b..04769cc 100644 --- a/src/ModelAnalyzer.jl +++ b/src/ModelAnalyzer.jl @@ -25,7 +25,7 @@ See [`summarize`](@ref), [`list_of_issues`](@ref), and function analyze end """ - summarize([io::IO,] AbstractData; verbose = true, max_issues = typemax(Int), kwargs...) + summarize([io::IO,] AbstractData; verbose = true, max_issues = 10, kwargs...) Print a summary of the analysis results contained in `AbstractData` to the specified IO stream. If no IO stream is provided, it defaults to `stdout`. @@ -80,16 +80,26 @@ function summarize(io::IO, issue::AbstractIssue; verbose = true) end end +const DEFAULT_MAX_ISSUES = 10 + function summarize( io::IO, issues::Vector{T}; verbose = true, - max_issues = typemax(Int), + max_issues = DEFAULT_MAX_ISSUES, ) where {T<:AbstractIssue} summarize(io, T, verbose = verbose) print(io, "\n## Number of issues\n\n") print(io, "Found ", length(issues), " issues") print(io, "\n\n## List of issues\n\n") + if length(issues) > max_issues + print( + io, + "Showing first ", + max_issues, + " issues ($(length(issues) - max_issues) issues ommitted)\n\n", + ) + end for issue in first(issues, max_issues) print(io, " * ") summarize(io, issue, verbose = verbose) diff --git a/src/feasibility.jl b/src/feasibility.jl index cb38584..089eaf2 100644 --- a/src/feasibility.jl +++ b/src/feasibility.jl @@ -685,7 +685,7 @@ function ModelAnalyzer.summarize( io::IO, data::Data; verbose = true, - max_issues = typemax(Int), + max_issues = ModelAnalyzer.DEFAULT_MAX_ISSUES, configurations = true, ) print(io, "## Feasibility Analysis\n\n") diff --git a/src/infeasibility.jl b/src/infeasibility.jl index 079c8e1..bec6055 100644 --- a/src/infeasibility.jl +++ b/src/infeasibility.jl @@ -677,7 +677,7 @@ function ModelAnalyzer.summarize( io::IO, data::Data; verbose = true, - max_issues = typemax(Int), + max_issues = ModelAnalyzer.DEFAULT_MAX_ISSUES, ) print(io, "## Infeasibility Analysis\n\n") diff --git a/src/numerical.jl b/src/numerical.jl index 35d9677..89cf660 100644 --- a/src/numerical.jl +++ b/src/numerical.jl @@ -2042,7 +2042,7 @@ function ModelAnalyzer.summarize( io::IO, data::Data; verbose = true, - max_issues = typemax(Int), + max_issues = ModelAnalyzer.DEFAULT_MAX_ISSUES, configurations = true, dimensions = true, ranges = true, diff --git a/test/numerical.jl b/test/numerical.jl index 1a6e98d..4077bf7 100644 --- a/test/numerical.jl +++ b/test/numerical.jl @@ -995,6 +995,27 @@ function test_qp_range() return end +function test_more_than_max_issues() + model = Model() + @variable(model, xg[1:20] <= 2e9) + data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model) + list = ModelAnalyzer.list_of_issue_types(data) + @test length(list) >= 1 + ret = ModelAnalyzer.list_of_issues( + data, + ModelAnalyzer.Numerical.LargeBoundCoefficient, + ) + @test length(ret) == 20 + + buf = IOBuffer() + ModelAnalyzer.summarize(buf, data) + str = String(take!(buf)) + @test occursin("Showing first ", str) + @test occursin(" issues ommitted)\n\n", str) + + return +end + end # module TestNumerical.runtests()