Skip to content

Commit 8b15bac

Browse files
authored
Add file write to docs and fixes (#21)
1 parent dad3c7e commit 8b15bac

File tree

5 files changed

+31
-14
lines changed

5 files changed

+31
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ Manifest.toml
2525

2626
# other ignores
2727
.vscode/settings.json
28+
*.txt

docs/src/index.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,17 @@ data = ModelAnalyzer.analyze(
8484
model,
8585
optimizer = HiGHS.Optimizer,
8686
)
87-
# print report
87+
88+
# print report to the screen
8889
ModelAnalyzer.summarize(data)
90+
91+
# or print ehte report to a file
92+
93+
# open a file
94+
open("my_report.txt", "w") do io
95+
# print report
96+
ModelAnalyzer.summarize(io, data)
97+
end
8998
```
9099

91100
The `ModelAnalyzer.analyze(...)` function can always take the keyword arguments:
@@ -117,6 +126,6 @@ issues = ModelAnalyzer.list_of_issues(data, list[1])
117126
# the list of issues of the given type can be summarized with:
118127
ModelAnalyzer.summarize(data, issues)
119128

120-
# infdividual issues can also be summarized
129+
# individual issues can also be summarized
121130
ModelAnalyzer.summarize(data, issues[1])
122131
```

src/infeasibility.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,20 +154,18 @@ function ModelAnalyzer.analyze(
154154
for var in JuMP.all_variables(model)
155155
lb = if JuMP.has_lower_bound(var)
156156
JuMP.lower_bound(var)
157+
elseif JuMP.is_fixed(var)
158+
JuMP.fix_value(var)
157159
else
158160
-Inf
159161
end
160162
ub = if JuMP.has_upper_bound(var)
161163
JuMP.upper_bound(var)
164+
elseif JuMP.is_fixed(var)
165+
JuMP.fix_value(var)
162166
else
163167
Inf
164168
end
165-
if lb > ub
166-
push!(out.infeasible_bounds, InfeasibleBounds(var, lb, ub))
167-
bounds_consistent = false
168-
else
169-
variables[var] = Interval(lb, ub)
170-
end
171169
if JuMP.is_integer(var)
172170
if abs(ub - lb) < 1 && ceil(ub) == ceil(lb)
173171
push!(
@@ -186,6 +184,12 @@ function ModelAnalyzer.analyze(
186184
bounds_consistent = false
187185
end
188186
end
187+
if lb > ub
188+
push!(out.infeasible_bounds, InfeasibleBounds(var, lb, ub))
189+
bounds_consistent = false
190+
else
191+
variables[var] = Interval(lb, ub)
192+
end
189193
end
190194
# check PSD diagonal >= 0 ?
191195
# other cones?
@@ -371,10 +375,6 @@ function iis_elastic_filter(original_model::JuMP.GenericModel, optimizer)
371375
end
372376
end
373377

374-
# TODO: add deletion filter
375-
# otherwise this is not an IIS (it does contain an IIS)
376-
377-
# pre_iis = Set(val[1] for val in de_elastisized)
378378
pre_iis = Set(cadidates)
379379
iis = JuMP.ConstraintRef[]
380380
for con in JuMP.all_constraints(

test/infeasibility.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ function test_range_equalto()
219219
return
220220
end
221221

222-
function test_range_equalto()
222+
function test_range_equalto_2()
223223
model = Model()
224224
@variable(model, x == 1)
225225
@variable(model, y == 2)
@@ -261,7 +261,7 @@ function test_range_greaterthan()
261261
return
262262
end
263263

264-
function test_range_equalto()
264+
function test_range_equalto_3()
265265
model = Model()
266266
@variable(model, 10 <= x <= 11)
267267
@variable(model, 1 <= y <= 11)

test/numerical.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,13 @@ function test_qp_range()
992992
ModelAnalyzer.summarize(buf, data)
993993
ModelAnalyzer.summarize(buf, data, verbose = false)
994994

995+
open("my_report.txt", "w") do io
996+
return ModelAnalyzer.summarize(io, data)
997+
end
998+
999+
file_data = read("my_report.txt", String)
1000+
@test occursin("## Numerical Analysis", file_data)
1001+
9951002
return
9961003
end
9971004

0 commit comments

Comments
 (0)