@@ -142,7 +142,7 @@ MOI.attribute_value_type(::ListOfNonstandardBridges) = Vector
142142
143143MOI. is_copyable (:: ListOfNonstandardBridges ) = false
144144
145- MOI. get_fallback (model :: MOI.ModelLike , :: ListOfNonstandardBridges ) = Type[]
145+ MOI. get_fallback (:: MOI.ModelLike , :: ListOfNonstandardBridges ) = Type[]
146146
147147function _test_structural_identical (
148148 a:: MOI.ModelLike ,
@@ -191,12 +191,8 @@ function _test_structural_identical(
191191 f_b = try
192192 MOI. get (b, MOI. ConstraintFunction (), ci)
193193 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
200196 end
201197 f_b = MOI. Utilities. map_indices (x_map, f_b)
202198 s_b = MOI. get (b, MOI. ConstraintSet (), ci)
227223_runtests_error_handler (err, :: Bool ) = rethrow (err)
228224
229225function _runtests_error_handler (
230- err:: MOI.GetAttributeNotAllowed{MOI.ConstraintFunction} ,
226+ err:: Union {
227+ MOI. GetAttributeNotAllowed{MOI. ConstraintFunction},
228+ MOI. GetAttributeNotAllowed{MOI. ConstraintPrimalStart},
229+ },
231230 cannot_unbridge:: Bool ,
232231)
233232 if cannot_unbridge
@@ -252,9 +251,11 @@ Run a series of tests that check the correctness of `Bridge`.
252251`input_fn` and `output_fn` are functions such that `input_fn(model)`
253252and `output_fn(model)` load the corresponding model into `model`.
254253
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).
258259
259260## Example
260261
@@ -328,7 +329,19 @@ function runtests(
328329 Test. @test MOI. get (model, attr, ci) === nothing
329330 start = _fake_start (constraint_start, set)
330331 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
332345 end
333346 end
334347 end
@@ -416,7 +429,7 @@ _fake_start(value, ::MOI.AbstractScalarSet) = value
416429
417430_fake_start (value, set:: MOI.AbstractVectorSet ) = fill (value, MOI. dimension (set))
418431
419- _fake_start (value:: AbstractVector , set :: MOI.AbstractVectorSet ) = value
432+ _fake_start (value:: AbstractVector , :: MOI.AbstractVectorSet ) = value
420433
421434function _bridged_model (Bridge:: Type{<:Constraint.AbstractBridge} , inner)
422435 return Constraint. SingleBridgeOptimizer {Bridge} (inner)
0 commit comments