From 85dca2eac029804a3203099970b135a82b944da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Fri, 10 May 2024 09:15:29 +0200 Subject: [PATCH 1/5] Test variable substitution for KernelBridge --- test/Bridges/Variable/kernel.jl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/Bridges/Variable/kernel.jl b/test/Bridges/Variable/kernel.jl index b6ed4def5..79cd54f8b 100644 --- a/test/Bridges/Variable/kernel.jl +++ b/test/Bridges/Variable/kernel.jl @@ -22,7 +22,7 @@ function test_runtests() MOI.Bridges.runtests( SumOfSquares.Bridges.Variable.KernelBridge, model -> begin - MOI.add_constrained_variables( + p, _ = MOI.add_constrained_variables( model, SumOfSquares.WeightedSOSCone{ MOI.PositiveSemidefiniteConeTriangle, @@ -38,13 +38,18 @@ function test_runtests() [MB.algebra_element(1.0 * x^0 * y^0)], ), ) + a = float.(1:length(p)) + MOI.add_constraint(model, MOI.Utilities.vectorize([a' * p]), MOI.Zeros(1)) end, model -> begin - Q, _ = MOI.add_constrained_variables( + q, _ = MOI.add_constrained_variables( model, MOI.PositiveSemidefiniteConeTriangle(3), ) - end, + a = float.(1:length(q)) + MOI.add_constraint(model, MOI.Utilities.vectorize([1.0 * q[1] + 2.0 * q[3] + 4.0 * (1.0q[4] + 1.0q[6]) + 6.0 * q[5]]), MOI.Zeros(1)) + end; + allow_outer_constraint_function_error = true, ) return end From 3dd5b767a3a1f336e67441ebbcde4557d9643b75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Thu, 4 Jul 2024 12:10:21 +0200 Subject: [PATCH 2/5] Fix --- test/Bridges/Variable/kernel.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Bridges/Variable/kernel.jl b/test/Bridges/Variable/kernel.jl index 79cd54f8b..77556d993 100644 --- a/test/Bridges/Variable/kernel.jl +++ b/test/Bridges/Variable/kernel.jl @@ -49,7 +49,7 @@ function test_runtests() a = float.(1:length(q)) MOI.add_constraint(model, MOI.Utilities.vectorize([1.0 * q[1] + 2.0 * q[3] + 4.0 * (1.0q[4] + 1.0q[6]) + 6.0 * q[5]]), MOI.Zeros(1)) end; - allow_outer_constraint_function_error = true, + cannot_unbridge = true, ) return end From ed9af6f86865c9d5f987e836fc74867838f6c5e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Thu, 4 Jul 2024 12:10:26 +0200 Subject: [PATCH 3/5] Fix format --- test/Bridges/Variable/kernel.jl | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/test/Bridges/Variable/kernel.jl b/test/Bridges/Variable/kernel.jl index 77556d993..19808fa12 100644 --- a/test/Bridges/Variable/kernel.jl +++ b/test/Bridges/Variable/kernel.jl @@ -39,7 +39,11 @@ function test_runtests() ), ) a = float.(1:length(p)) - MOI.add_constraint(model, MOI.Utilities.vectorize([a' * p]), MOI.Zeros(1)) + MOI.add_constraint( + model, + MOI.Utilities.vectorize([a' * p]), + MOI.Zeros(1), + ) end, model -> begin q, _ = MOI.add_constrained_variables( @@ -47,7 +51,16 @@ function test_runtests() MOI.PositiveSemidefiniteConeTriangle(3), ) a = float.(1:length(q)) - MOI.add_constraint(model, MOI.Utilities.vectorize([1.0 * q[1] + 2.0 * q[3] + 4.0 * (1.0q[4] + 1.0q[6]) + 6.0 * q[5]]), MOI.Zeros(1)) + MOI.add_constraint( + model, + MOI.Utilities.vectorize([ + 1.0 * q[1] + + 2.0 * q[3] + + 4.0 * (1.0q[4] + 1.0q[6]) + + 6.0 * q[5], + ]), + MOI.Zeros(1), + ) end; cannot_unbridge = true, ) From 81177e87bac342c74aa5db2f0af4965e9031fced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Thu, 4 Jul 2024 12:30:03 +0200 Subject: [PATCH 4/5] Fix --- test/Bridges/Variable/kernel.jl | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/test/Bridges/Variable/kernel.jl b/test/Bridges/Variable/kernel.jl index 19808fa12..b3bfaa39a 100644 --- a/test/Bridges/Variable/kernel.jl +++ b/test/Bridges/Variable/kernel.jl @@ -28,13 +28,13 @@ function test_runtests() MOI.PositiveSemidefiniteConeTriangle, }( MB.SubBasis{MB.Monomial}([ - x^4, - x^3 * y, - x^2 * y^2, - x * y^3, y^4, + x * y^3, + x^2 * y^2, + x^3 * y, + x^4, ]), - [MB.SubBasis{MB.Monomial}([x^2, y^2, x * y])], + [MB.SubBasis{MB.Monomial}([y^2, x * y, x^2])], [MB.algebra_element(1.0 * x^0 * y^0)], ), ) @@ -55,9 +55,10 @@ function test_runtests() model, MOI.Utilities.vectorize([ 1.0 * q[1] + - 2.0 * q[3] + - 4.0 * (1.0q[4] + 1.0q[6]) + - 6.0 * q[5], + 4.0 * q[2] + + 3.0 * (1.0q[3] + 2.0q[4]) + + 8.0 * q[5] + + 5.0 * q[6], ]), MOI.Zeros(1), ) From 1134c86454e7b06fca47349cf24352c3cc79e38b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Thu, 4 Jul 2024 13:33:56 +0200 Subject: [PATCH 5/5] Fix format --- test/Bridges/Variable/kernel.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Bridges/Variable/kernel.jl b/test/Bridges/Variable/kernel.jl index b3bfaa39a..e82aa67b9 100644 --- a/test/Bridges/Variable/kernel.jl +++ b/test/Bridges/Variable/kernel.jl @@ -55,7 +55,7 @@ function test_runtests() model, MOI.Utilities.vectorize([ 1.0 * q[1] + - 4.0 * q[2] + + 4.0 * q[2] + 3.0 * (1.0q[3] + 2.0q[4]) + 8.0 * q[5] + 5.0 * q[6],