@@ -192,42 +192,84 @@ function test_constraint_bounds_quad()
192192 return
193193end
194194
195- function test_variable_not_in_constraints ()
195+ function test_no_names ()
196196 model = Model ()
197+ set_string_names_on_creation (model, false )
197198 @variable (model, x)
198199 @variable (model, y)
199200 @constraint (model, 7 y >= 3 )
201+ @constraint (model, z, 0.0 * y == 3 )
200202 data = ModelAnalyzer. analyze (ModelAnalyzer. Numerical. Analyzer (), model)
201203 list = ModelAnalyzer. list_of_issue_types (data)
202- @test length (list) == 1
204+ @test length (list) == 2
203205 ret = ModelAnalyzer. list_of_issues (
204206 data,
205207 ModelAnalyzer. Numerical. VariableNotInConstraints,
206208 )
207209 @test length (ret) == 1
208- @test ModelAnalyzer. variable (ret[]) == JuMP. index (x)
209- @test ModelAnalyzer. variable (ret[], model) == x
210210 #
211211 buf = IOBuffer ()
212- ModelAnalyzer. summarize (
213- buf,
214- ModelAnalyzer. Numerical. VariableNotInConstraints,
212+ ModelAnalyzer. summarize (buf, ret[1 ], verbose = true )
213+ str = String (take! (buf))
214+ @test startswith (str, " Variable: " )
215+ ModelAnalyzer. summarize (buf, ret[1 ], verbose = false )
216+ str = String (take! (buf))
217+ #
218+ ModelAnalyzer. summarize (buf, ret[1 ], verbose = true , model = model)
219+ str = String (take! (buf))
220+ @test startswith (str, " Variable: " )
221+ ModelAnalyzer. summarize (buf, ret[1 ], verbose = false , model = model)
222+ str = String (take! (buf))
223+ #
224+ #
225+ ret = ModelAnalyzer. list_of_issues (
226+ data,
227+ ModelAnalyzer. Numerical. EmptyConstraint,
215228 )
229+ @test length (ret) == 1
230+ #
231+ ModelAnalyzer. summarize (buf, ret[1 ], verbose = true )
216232 str = String (take! (buf))
217- @test startswith (str, " # `VariableNotInConstraints`" )
218- ModelAnalyzer. summarize (
219- buf,
233+ @test startswith (str, " Constraint: " )
234+ ModelAnalyzer. summarize (buf, ret[1 ], verbose = false )
235+ str = String (take! (buf))
236+ #
237+ ModelAnalyzer. summarize (buf, ret[1 ], verbose = true , model = model)
238+ str = String (take! (buf))
239+ @test startswith (str, " Constraint: " )
240+ ModelAnalyzer. summarize (buf, ret[1 ], verbose = false , model = model)
241+ str = String (take! (buf))
242+ return
243+ end
244+
245+ function test_variable_not_in_constraints ()
246+ model = Model ()
247+ @variable (model, x)
248+ @variable (model, y)
249+ @constraint (model, 7 y >= 3 )
250+ data = ModelAnalyzer. analyze (ModelAnalyzer. Numerical. Analyzer (), model)
251+ list = ModelAnalyzer. list_of_issue_types (data)
252+ @test length (list) == 1
253+ ret = ModelAnalyzer. list_of_issues (
254+ data,
220255 ModelAnalyzer. Numerical. VariableNotInConstraints,
221- verbose = false ,
222256 )
223- str = String (take! (buf))
224- @test str == " # VariableNotInConstraints"
257+ @test length (ret) == 1
258+ @test ModelAnalyzer. variable (ret[]) == JuMP. index (x)
259+ @test ModelAnalyzer. variable (ret[], model) == x
225260 #
261+ buf = IOBuffer ()
226262 ModelAnalyzer. summarize (buf, ret[1 ], verbose = true )
227263 str = String (take! (buf))
228264 @test startswith (str, " Variable: " )
229265 ModelAnalyzer. summarize (buf, ret[1 ], verbose = false )
230266 str = String (take! (buf))
267+ #
268+ ModelAnalyzer. summarize (buf, ret[1 ], verbose = true , model = model)
269+ str = String (take! (buf))
270+ @test startswith (str, " Variable: " )
271+ ModelAnalyzer. summarize (buf, ret[1 ], verbose = false , model = model)
272+ str = String (take! (buf))
231273 return
232274end
233275
@@ -264,6 +306,12 @@ function test_empty_constraint_model()
264306 @test startswith (str, " Constraint: " )
265307 ModelAnalyzer. summarize (buf, ret[1 ], verbose = false )
266308 str = String (take! (buf))
309+ #
310+ ModelAnalyzer. summarize (buf, ret[1 ], verbose = true , model = model)
311+ str = String (take! (buf))
312+ @test startswith (str, " Constraint: " )
313+ ModelAnalyzer. summarize (buf, ret[1 ], verbose = false , model = model)
314+ str = String (take! (buf))
267315 return
268316end
269317
0 commit comments