Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/ModelAnalyzer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/feasibility.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion src/infeasibility.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion src/numerical.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
21 changes: 21 additions & 0 deletions test/numerical.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Loading