Skip to content

Commit 8b00bbf

Browse files
committed
Fix show tests
1 parent 408a5ff commit 8b00bbf

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

src/Bridges/graph.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ end
5858
function Base.show(io::IO, graph::Graph)
5959
print(io, "Bridge graph with ")
6060
print(io, length(graph.variable_best), " variable nodes, ")
61-
print(io, length(graph.constraint_best), " variable nodes and ")
61+
print(io, length(graph.constraint_best), " constraint nodes and ")
6262
print(io, length(graph.objective_best), " objective nodes.")
6363
end
6464
function variable_nodes(graph::Graph)

test/Bridges/bridge_optimizer.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ bridged_mock = MOIB.Constraint.LessToGreater{Float64}(MOIB.Constraint.SplitInter
143143
@testset "Unsupported constraint attribute" begin
144144
attr = MOIT.UnknownConstraintAttribute()
145145
err = ArgumentError(
146-
"Bridge of type `MathOptInterface.Bridges.Constraint.SplitIntervalBridge{Float64,MathOptInterface.SingleVariable}` " *
146+
"Bridge of type `$MOI.Bridges.Constraint.SplitIntervalBridge{Float64,$MOI.SingleVariable,$MOI.Interval{Float64},$MOI.GreaterThan{Float64},$MOI.LessThan{Float64}}` " *
147147
"does not support accessing the attribute `$attr`.")
148148
x = MOI.add_variable(bridged_mock)
149149
ci = MOI.add_constraint(bridged_mock, MOI.SingleVariable(x),
@@ -228,9 +228,9 @@ end
228228

229229
@testset "Show" begin
230230
@test sprint(show, bridged_mock) == raw"""
231-
MOIB.Constraint.SingleBridgeOptimizer{MOIB.Constraint.LessToGreaterBridge{Float64,F,G} where G<:MOI.AbstractScalarFunction where F<:MOI.AbstractScalarFunction,MOIB.Constraint.SingleBridgeOptimizer{MOIB.Constraint.SplitIntervalBridge{Float64,F} where F<:MOI.AbstractScalarFunction,MOIU.MockOptimizer{NoIntervalModel{Float64}}}}
231+
MOIB.Constraint.SingleBridgeOptimizer{MOIB.Constraint.LessToGreaterBridge{Float64,F,G} where G<:MOI.AbstractScalarFunction where F<:MOI.AbstractScalarFunction,MOIB.Constraint.SingleBridgeOptimizer{MOIB.Constraint.SplitIntervalBridge{Float64,F,S,LS,US} where US<:MOI.AbstractSet where LS<:MOI.AbstractSet where S<:MOI.AbstractSet where F<:MOI.AbstractFunction,MOIU.MockOptimizer{NoIntervalModel{Float64}}}}
232232
with 1 constraint bridge
233-
with inner model MOIB.Constraint.SingleBridgeOptimizer{MOIB.Constraint.SplitIntervalBridge{Float64,F} where F<:MOI.AbstractScalarFunction,MOIU.MockOptimizer{NoIntervalModel{Float64}}}
233+
with inner model MOIB.Constraint.SingleBridgeOptimizer{MOIB.Constraint.SplitIntervalBridge{Float64,F,S,LS,US} where US<:MOI.AbstractSet where LS<:MOI.AbstractSet where S<:MOI.AbstractSet where F<:MOI.AbstractFunction,MOIU.MockOptimizer{NoIntervalModel{Float64}}}
234234
with 0 constraint bridges
235235
with inner model MOIU.MockOptimizer{NoIntervalModel{Float64}}"""
236236
end

test/Bridges/lazy_bridge_optimizer.jl

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -330,20 +330,20 @@ end
330330
@test_throws MOI.UnsupportedConstraint{MOI.VectorOfVariables, MOI.PositiveSemidefiniteConeSquare} MOIB.bridge_type(bridged, MOI.PositiveSemidefiniteConeSquare)
331331
@test MOIB._dist(bridged.graph, MOIB.node(bridged, MOI.PositiveSemidefiniteConeSquare)) == MOIB.INFINITY
332332
@test sprint(MOIB.print_graph, bridged) == """
333-
Bridge graph with 1 variable nodes, 0 variable nodes and 0 objective nodes.
333+
Bridge graph with 1 variable nodes, 0 constraint nodes and 0 objective nodes.
334334
[1] constrained variables in `MOI.PositiveSemidefiniteConeSquare` are not supported
335335
"""
336336
@test MOI.supports_constraint(bridged, MOI.VectorOfVariables, MOI.PositiveSemidefiniteConeSquare)
337337
@test sprint(MOIB.print_graph, bridged) == """
338-
Bridge graph with 1 variable nodes, 1 variable nodes and 0 objective nodes.
338+
Bridge graph with 1 variable nodes, 1 constraint nodes and 0 objective nodes.
339339
[1] constrained variables in `MOI.PositiveSemidefiniteConeSquare` are not supported
340340
(1) `MOI.VectorOfVariables`-in-`MOI.PositiveSemidefiniteConeSquare` constraints are bridged (distance 1) by MOIB.Constraint.SquareBridge{$T,MOI.VectorOfVariables,MOI.ScalarAffineFunction{$T},MOI.PositiveSemidefiniteConeTriangle,MOI.PositiveSemidefiniteConeSquare}.
341341
"""
342342
MOIB.add_bridge(bridged, MOIB.Constraint.VectorFunctionizeBridge{T})
343343
@test_throws MOI.UnsupportedConstraint{MOI.VectorOfVariables, MOI.PositiveSemidefiniteConeSquare} MOIB.bridge_type(bridged, MOI.PositiveSemidefiniteConeSquare)
344344
@test MOIB._dist(bridged.graph, MOIB.node(bridged, MOI.PositiveSemidefiniteConeSquare)) == 6
345345
@test sprint(MOIB.print_graph, bridged) == """
346-
Bridge graph with 1 variable nodes, 3 variable nodes and 0 objective nodes.
346+
Bridge graph with 1 variable nodes, 3 constraint nodes and 0 objective nodes.
347347
[1] constrained variables in `MOI.PositiveSemidefiniteConeSquare` are supported (distance 6) by adding free variables and then constrain them, see (1).
348348
(1) `MOI.VectorAffineFunction{$T}`-in-`MOI.PositiveSemidefiniteConeSquare` constraints are bridged (distance 3) by MOIB.Constraint.SquareBridge{$T,MOI.VectorAffineFunction{$T},MOI.ScalarAffineFunction{$T},MOI.PositiveSemidefiniteConeTriangle,MOI.PositiveSemidefiniteConeSquare}.
349349
(2) `MOI.VectorAffineFunction{$T}`-in-`MOI.Zeros` constraints are bridged (distance 1) by MOIB.Constraint.ScalarizeBridge{$T,MOI.ScalarAffineFunction{$T},MOI.EqualTo{$T}}.
@@ -409,7 +409,7 @@ Constrained variables in `MOI.LessThan{$T}` are not supported and cannot be brid
409409
Cannot add free variables and then constrain them because free variables are bridged but no functionize bridge was added.
410410
"""
411411
@test sprint(MOIB.print_graph, bridged) == """
412-
Bridge graph with 1 variable nodes, 1 variable nodes and 0 objective nodes.
412+
Bridge graph with 1 variable nodes, 1 constraint nodes and 0 objective nodes.
413413
[1] constrained variables in `MOI.LessThan{$T}` are not supported
414414
(1) `MOI.SingleVariable`-in-`MOI.LessThan{$T}` constraints are not supported
415415
"""
@@ -426,7 +426,7 @@ Constrained variables in `MOI.LessThan{$T}` are not supported and cannot be brid
426426
MOIB.add_bridge(bridged, MOIB.Variable.NonposToNonnegBridge{T})
427427
@test debug_string(MOIB.debug_supports_constraint, F, S) == "Constrained variables in `MOI.LessThan{$T}` are supported.\n"
428428
@test sprint(MOIB.print_graph, bridged) == """
429-
Bridge graph with 2 variable nodes, 0 variable nodes and 0 objective nodes.
429+
Bridge graph with 2 variable nodes, 0 constraint nodes and 0 objective nodes.
430430
[1] constrained variables in `MOI.LessThan{$T}` are bridged (distance 2) by MOIB.Variable.VectorizeBridge{$T,MOI.Nonpositives}.
431431
[2] constrained variables in `MOI.Nonpositives` are bridged (distance 1) by MOIB.Variable.NonposToNonnegBridge{$T}.
432432
"""
@@ -444,7 +444,7 @@ Constrained variables in `MOI.LessThan{$T}` are not supported and cannot be brid
444444
(1) `MOI.ScalarAffineFunction{$T}`-in-`MOI.LessThan{$T}` constraints are not supported because no added bridge supports bridging it.
445445
"""
446446
@test sprint(MOIB.print_graph, bridged) == """
447-
Bridge graph with 1 variable nodes, 2 variable nodes and 0 objective nodes.
447+
Bridge graph with 1 variable nodes, 2 constraint nodes and 0 objective nodes.
448448
[1] constrained variables in `MOI.LessThan{$T}` are not supported
449449
(1) `MOI.ScalarAffineFunction{$T}`-in-`MOI.LessThan{$T}` constraints are not supported
450450
(2) `MOI.SingleVariable`-in-`MOI.LessThan{$T}` constraints are not supported
@@ -464,7 +464,7 @@ Constrained variables in `MOI.LessThan{$T}` are not supported and cannot be brid
464464
MOIB.add_bridge(bridged, MOIB.Variable.NonposToNonnegBridge{T})
465465
@test debug_string(MOIB.debug_supports_constraint, F, S) == "Constrained variables in `MOI.LessThan{$T}` are supported.\n"
466466
@test sprint(MOIB.print_graph, bridged) == """
467-
Bridge graph with 2 variable nodes, 1 variable nodes and 0 objective nodes.
467+
Bridge graph with 2 variable nodes, 1 constraint nodes and 0 objective nodes.
468468
[1] constrained variables in `MOI.LessThan{$T}` are bridged (distance 2) by MOIB.Variable.VectorizeBridge{$T,MOI.Nonpositives}.
469469
[2] constrained variables in `MOI.Nonpositives` are bridged (distance 1) by MOIB.Variable.NonposToNonnegBridge{$T}.
470470
(1) `MOI.ScalarAffineFunction{$T}`-in-`MOI.LessThan{$T}` constraints are not supported
@@ -482,7 +482,7 @@ Bridge graph with 2 variable nodes, 1 variable nodes and 0 objective nodes.
482482
@test debug_string(MOIB.debug_supports_constraint, F, S) == """
483483
`MOI.ScalarAffineFunction{$T}`-in-`MOI.Interval{$T}` constraints are not supported and cannot be bridged into supported constrained variables and constraints. See details below:
484484
(1) `MOI.ScalarAffineFunction{$T}`-in-`MOI.Interval{$T}` constraints are not supported because:
485-
Cannot use `MOIB.Constraint.SplitIntervalBridge{$T,MOI.ScalarAffineFunction{$T}}` because:
485+
Cannot use `MOIB.Constraint.SplitIntervalBridge{$T,MOI.ScalarAffineFunction{$T},MOI.Interval{$T},MOI.GreaterThan{$T},MOI.LessThan{$T}}` because:
486486
(2) `MOI.ScalarAffineFunction{$T}`-in-`MOI.GreaterThan{$T}` constraints are not supported
487487
(3) `MOI.ScalarAffineFunction{$T}`-in-`MOI.LessThan{$T}` constraints are not supported
488488
(2) `MOI.ScalarAffineFunction{$T}`-in-`MOI.GreaterThan{$T}` constraints are not supported because no added bridge supports bridging it.
@@ -498,7 +498,7 @@ Bridge graph with 2 variable nodes, 1 variable nodes and 0 objective nodes.
498498
[3] constrained variables in `MOI.Interval{$T}` are not supported because no added bridge supports bridging it.
499499
Cannot add free variables and then constrain them because free variables are bridged but no functionize bridge was added.
500500
(1) `MOI.ScalarAffineFunction{$T}`-in-`MOI.Interval{$T}` constraints are not supported because:
501-
Cannot use `MOIB.Constraint.SplitIntervalBridge{$T,MOI.ScalarAffineFunction{$T}}` because:
501+
Cannot use `MOIB.Constraint.SplitIntervalBridge{$T,MOI.ScalarAffineFunction{$T},MOI.Interval{$T},MOI.GreaterThan{$T},MOI.LessThan{$T}}` because:
502502
(2) `MOI.ScalarAffineFunction{$T}`-in-`MOI.GreaterThan{$T}` constraints are not supported
503503
(3) `MOI.ScalarAffineFunction{$T}`-in-`MOI.LessThan{$T}` constraints are not supported
504504
Cannot use `MOIB.Constraint.ScalarSlackBridge{$T,MOI.ScalarAffineFunction{$T},MOI.Interval{$T}}` because:
@@ -522,7 +522,7 @@ Bridge graph with 2 variable nodes, 1 variable nodes and 0 objective nodes.
522522
[4] constrained variables in `MOI.Interval{$T}` are not supported because no added bridge supports bridging it.
523523
Cannot add free variables and then constrain them because free variables are bridged but no functionize bridge was added.
524524
(1) `MOI.ScalarAffineFunction{$T}`-in-`MOI.Interval{$T}` constraints are not supported because:
525-
Cannot use `MOIB.Constraint.SplitIntervalBridge{$T,MOI.ScalarAffineFunction{$T}}` because:
525+
Cannot use `MOIB.Constraint.SplitIntervalBridge{$T,MOI.ScalarAffineFunction{$T},MOI.Interval{$T},MOI.GreaterThan{$T},MOI.LessThan{$T}}` because:
526526
(3) `MOI.ScalarAffineFunction{$T}`-in-`MOI.LessThan{$T}` constraints are not supported
527527
Cannot use `MOIB.Constraint.ScalarSlackBridge{$T,MOI.ScalarAffineFunction{$T},MOI.Interval{$T}}` because:
528528
[4] constrained variables in `MOI.Interval{$T}` are not supported
@@ -612,7 +612,7 @@ Objective function of type `MOI.ScalarQuadraticFunction{$T}` is not supported an
612612
MOIB.add_bridge(bridged, MOIB.Constraint.ScalarizeBridge{T})
613613
@test debug_string(MOIB.debug_supports, attr) == "Objective function of type `MOI.ScalarQuadraticFunction{$T}` is supported.\n"
614614
@test sprint(MOIB.print_graph, bridged) == """
615-
Bridge graph with 1 variable nodes, 5 variable nodes and 2 objective nodes.
615+
Bridge graph with 1 variable nodes, 5 constraint nodes and 2 objective nodes.
616616
[1] constrained variables in `MOI.RotatedSecondOrderCone` are bridged (distance 2) by MOIB.Variable.RSOCtoPSDBridge{$T}.
617617
(1) `MOI.ScalarQuadraticFunction{$T}`-in-`MOI.GreaterThan{$T}` constraints are bridged (distance 5) by MOIB.Constraint.QuadtoSOCBridge{$T}.
618618
(2) `MOI.VectorAffineFunction{$T}`-in-`MOI.RotatedSecondOrderCone` constraints are bridged (distance 4) by MOIB.Constraint.VectorSlackBridge{$T,MOI.VectorAffineFunction{$T},MOI.RotatedSecondOrderCone}.
@@ -712,7 +712,7 @@ end
712712
@test !MOIB.is_variable_bridged(bridged, cy)
713713
@test MOIB.bridge(bridged, cy) isa MOIB.Constraint.RSOCBridge{T}
714714
@test sprint(MOIB.print_graph, bridged) == """
715-
Bridge graph with 4 variable nodes, 8 variable nodes and 0 objective nodes.
715+
Bridge graph with 4 variable nodes, 9 constraint nodes and 0 objective nodes.
716716
[1] constrained variables in `MOI.SecondOrderCone` are supported (distance 2) by adding free variables and then constrain them, see (1).
717717
[2] constrained variables in `MOI.RotatedSecondOrderCone` are supported (distance 2) by adding free variables and then constrain them, see (3).
718718
[3] constrained variables in `MOI.PositiveSemidefiniteConeTriangle` are not supported
@@ -725,6 +725,7 @@ Bridge graph with 4 variable nodes, 8 variable nodes and 0 objective nodes.
725725
(6) `MOI.VectorOfVariables`-in-`MOI.Nonnegatives` constraints are bridged (distance 1) by MOIB.Constraint.NonnegToNonposBridge{$T,MOI.VectorAffineFunction{$T},MOI.VectorOfVariables}.
726726
(7) `MOI.SingleVariable`-in-`MOI.GreaterThan{$T}` constraints are bridged (distance 1) by MOIB.Constraint.GreaterToLessBridge{$T,MOI.ScalarAffineFunction{$T},MOI.SingleVariable}.
727727
(8) `MOI.SingleVariable`-in-`MOI.EqualTo{$T}` constraints are bridged (distance 1) by MOIB.Constraint.VectorizeBridge{$T,MOI.VectorAffineFunction{$T},MOI.Zeros,MOI.SingleVariable}.
728+
(9) `MOI.SingleVariable`-in-`MOI.LessThan{$T}` constraints are bridged (distance 1) by MOIB.Constraint.LessToGreaterBridge{$T,MOI.ScalarAffineFunction{$T},MOI.SingleVariable}.
728729
"""
729730
end
730731

0 commit comments

Comments
 (0)