@@ -144,7 +144,7 @@ MOI.get_fallback(model::MOI.ModelLike, ::ListOfNonstandardBridges) = Type[]
144
144
145
145
include (" precompile.jl" )
146
146
147
- function _test_structural_identical (a:: MOI.ModelLike , b:: MOI.ModelLike )
147
+ function _test_structural_identical (a:: MOI.ModelLike , b:: MOI.ModelLike ; allow_constraint_function_error :: Bool = false )
148
148
# Test that the variables are the same. We make the strong assumption that
149
149
# the variables are added in the same order to both models.
150
150
a_x = MOI. get (a, MOI. ListOfVariableIndices ())
@@ -190,7 +190,15 @@ function _test_structural_identical(a::MOI.ModelLike, b::MOI.ModelLike)
190
190
Test. @test MOI. supports_constraint (b, F, S)
191
191
# Check that each function in `b` matches a function in `a`
192
192
for ci in MOI. get (b, MOI. ListOfConstraintIndices {F,S} ())
193
- f_b = MOI. get (b, MOI. ConstraintFunction (), ci)
193
+ try
194
+ f_b = MOI. get (b, MOI. ConstraintFunction (), ci)
195
+ catch err
196
+ if allow_constraint_function_error && err isa MOI. GetAttributeNotAllowed{MOI. ConstraintFunction}
197
+ continue
198
+ else
199
+ rethrow (err)
200
+ end
201
+ end
194
202
f_b = MOI. Utilities. map_indices (x_map, f_b)
195
203
s_b = MOI. get (b, MOI. ConstraintSet (), ci)
196
204
# We don't care about the order that constraints are added, only
@@ -253,6 +261,7 @@ function runtests(
253
261
constraint_start = 1.2 ,
254
262
eltype = Float64,
255
263
print_inner_model:: Bool = false ,
264
+ allow_outer_constraint_function_error:: Bool = false ,
256
265
)
257
266
# Load model and bridge it
258
267
inner = MOI. Utilities. UniversalFallback (MOI. Utilities. Model {eltype} ())
@@ -267,7 +276,7 @@ function runtests(
267
276
# Load a non-bridged input model, and check that getters are the same.
268
277
test = MOI. Utilities. UniversalFallback (MOI. Utilities. Model {eltype} ())
269
278
input_fn (test)
270
- _test_structural_identical (test, model)
279
+ _test_structural_identical (test, model; allow_constraint_function_error = allow_outer_constraint_function_error )
271
280
# Load a bridged target model, and check that getters are the same.
272
281
target = MOI. Utilities. UniversalFallback (MOI. Utilities. Model {eltype} ())
273
282
output_fn (target)
0 commit comments