diff --git a/.gitignore b/.gitignore index 887b851..964de8f 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ Manifest.toml # other ignores .vscode/settings.json +*.txt diff --git a/docs/src/index.md b/docs/src/index.md index 780a434..e60ae8b 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -84,8 +84,17 @@ data = ModelAnalyzer.analyze( model, optimizer = HiGHS.Optimizer, ) -# print report + +# print report to the screen ModelAnalyzer.summarize(data) + +# or print ehte report to a file + +# open a file +open("my_report.txt", "w") do io + # print report + ModelAnalyzer.summarize(io, data) +end ``` The `ModelAnalyzer.analyze(...)` function can always take the keyword arguments: @@ -117,6 +126,6 @@ issues = ModelAnalyzer.list_of_issues(data, list[1]) # the list of issues of the given type can be summarized with: ModelAnalyzer.summarize(data, issues) -# infdividual issues can also be summarized +# individual issues can also be summarized ModelAnalyzer.summarize(data, issues[1]) ``` diff --git a/src/infeasibility.jl b/src/infeasibility.jl index 079c8e1..7e1795b 100644 --- a/src/infeasibility.jl +++ b/src/infeasibility.jl @@ -154,20 +154,18 @@ function ModelAnalyzer.analyze( for var in JuMP.all_variables(model) lb = if JuMP.has_lower_bound(var) JuMP.lower_bound(var) + elseif JuMP.is_fixed(var) + JuMP.fix_value(var) else -Inf end ub = if JuMP.has_upper_bound(var) JuMP.upper_bound(var) + elseif JuMP.is_fixed(var) + JuMP.fix_value(var) else Inf end - if lb > ub - push!(out.infeasible_bounds, InfeasibleBounds(var, lb, ub)) - bounds_consistent = false - else - variables[var] = Interval(lb, ub) - end if JuMP.is_integer(var) if abs(ub - lb) < 1 && ceil(ub) == ceil(lb) push!( @@ -186,6 +184,12 @@ function ModelAnalyzer.analyze( bounds_consistent = false end end + if lb > ub + push!(out.infeasible_bounds, InfeasibleBounds(var, lb, ub)) + bounds_consistent = false + else + variables[var] = Interval(lb, ub) + end end # check PSD diagonal >= 0 ? # other cones? @@ -371,10 +375,6 @@ function iis_elastic_filter(original_model::JuMP.GenericModel, optimizer) end end - # TODO: add deletion filter - # otherwise this is not an IIS (it does contain an IIS) - - # pre_iis = Set(val[1] for val in de_elastisized) pre_iis = Set(cadidates) iis = JuMP.ConstraintRef[] for con in JuMP.all_constraints( diff --git a/test/infeasibility.jl b/test/infeasibility.jl index 1d1ce2c..a50fee6 100644 --- a/test/infeasibility.jl +++ b/test/infeasibility.jl @@ -219,7 +219,7 @@ function test_range_equalto() return end -function test_range_equalto() +function test_range_equalto_2() model = Model() @variable(model, x == 1) @variable(model, y == 2) @@ -261,7 +261,7 @@ function test_range_greaterthan() return end -function test_range_equalto() +function test_range_equalto_3() model = Model() @variable(model, 10 <= x <= 11) @variable(model, 1 <= y <= 11) diff --git a/test/numerical.jl b/test/numerical.jl index 1a6e98d..c12d761 100644 --- a/test/numerical.jl +++ b/test/numerical.jl @@ -992,6 +992,13 @@ function test_qp_range() ModelAnalyzer.summarize(buf, data) ModelAnalyzer.summarize(buf, data, verbose = false) + open("my_report.txt", "w") do io + return ModelAnalyzer.summarize(io, data) + end + + file_data = read("my_report.txt", String) + @test occursin("## Numerical Analysis", file_data) + return end