@@ -142,7 +142,7 @@ MOI.attribute_value_type(::ListOfNonstandardBridges) = Vector
142
142
143
143
MOI. is_copyable (:: ListOfNonstandardBridges ) = false
144
144
145
- MOI. get_fallback (model :: MOI.ModelLike , :: ListOfNonstandardBridges ) = Type[]
145
+ MOI. get_fallback (:: MOI.ModelLike , :: ListOfNonstandardBridges ) = Type[]
146
146
147
147
function _test_structural_identical (
148
148
a:: MOI.ModelLike ,
@@ -191,12 +191,8 @@ function _test_structural_identical(
191
191
f_b = try
192
192
MOI. get (b, MOI. ConstraintFunction (), ci)
193
193
catch err
194
- if cannot_unbridge &&
195
- err isa MOI. GetAttributeNotAllowed{MOI. ConstraintFunction}
196
- continue
197
- else
198
- rethrow (err)
199
- end
194
+ _runtests_error_handler (err, cannot_unbridge)
195
+ continue
200
196
end
201
197
f_b = MOI. Utilities. map_indices (x_map, f_b)
202
198
s_b = MOI. get (b, MOI. ConstraintSet (), ci)
227
223
_runtests_error_handler (err, :: Bool ) = rethrow (err)
228
224
229
225
function _runtests_error_handler (
230
- err:: MOI.GetAttributeNotAllowed{MOI.ConstraintFunction} ,
226
+ err:: Union {
227
+ MOI. GetAttributeNotAllowed{MOI. ConstraintFunction},
228
+ MOI. GetAttributeNotAllowed{MOI. ConstraintPrimalStart},
229
+ },
231
230
cannot_unbridge:: Bool ,
232
231
)
233
232
if cannot_unbridge
@@ -252,9 +251,11 @@ Run a series of tests that check the correctness of `Bridge`.
252
251
`input_fn` and `output_fn` are functions such that `input_fn(model)`
253
252
and `output_fn(model)` load the corresponding model into `model`.
254
253
255
- Set `cannot_unbridge` to `true` if the bridge is a variable bridge
256
- for which [`Variable.unbridged_map`](@ref) returns `nothing` so that
257
- the tests allow errors that can be raised due to this.
254
+ Set `cannot_unbridge` to `true` if the bridge transformation is not invertible.
255
+ If `Bridge` is a variable bridge this allows [`Variable.unbridged_map`](@ref)
256
+ to returns `nothing` so that the tests allow errors that can be raised due to this.
257
+ If `Bridge` is a constraint bridge this allows the getter of [`MOI.ConstraintFunction`](@ref)
258
+ and [`MOI.ConstraintPrimalStart`](@ref) to throw [`MOI.GetAttributeNotAllowed`](@ref).
258
259
259
260
## Example
260
261
@@ -328,7 +329,19 @@ function runtests(
328
329
Test. @test MOI. get (model, attr, ci) === nothing
329
330
start = _fake_start (constraint_start, set)
330
331
MOI. set (model, attr, ci, start)
331
- Test. @test MOI. get (model, attr, ci) ≈ start
332
+ returned_start = try
333
+ MOI. get (model, attr, ci)
334
+ catch err
335
+ # For a Constraint bridge for which the map is not invertible, the constraint primal cannot
336
+ # be inverted
337
+ _runtests_error_handler (
338
+ err,
339
+ Bridge <: MOI.Bridges.Constraint.AbstractBridge &&
340
+ cannot_unbridge,
341
+ )
342
+ continue
343
+ end
344
+ Test. @test returned_start ≈ start
332
345
end
333
346
end
334
347
end
@@ -416,7 +429,7 @@ _fake_start(value, ::MOI.AbstractScalarSet) = value
416
429
417
430
_fake_start (value, set:: MOI.AbstractVectorSet ) = fill (value, MOI. dimension (set))
418
431
419
- _fake_start (value:: AbstractVector , set :: MOI.AbstractVectorSet ) = value
432
+ _fake_start (value:: AbstractVector , :: MOI.AbstractVectorSet ) = value
420
433
421
434
function _bridged_model (Bridge:: Type{<:Constraint.AbstractBridge} , inner)
422
435
return Constraint. SingleBridgeOptimizer {Bridge} (inner)
0 commit comments