From cf146a6129adc388b64f4c77aac0c172353b6664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Thu, 4 Jul 2024 14:05:32 +0200 Subject: [PATCH] Test variable substitution for KernelBridge (#353) * Test variable substitution for KernelBridge * Fix * Fix format * Fix * Fix format --- test/Bridges/Variable/kernel.jl | 35 +++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/test/Bridges/Variable/kernel.jl b/test/Bridges/Variable/kernel.jl index b6ed4def5..e82aa67b9 100644 --- a/test/Bridges/Variable/kernel.jl +++ b/test/Bridges/Variable/kernel.jl @@ -22,29 +22,48 @@ 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, }( 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)], ), ) + 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] + + 4.0 * q[2] + + 3.0 * (1.0q[3] + 2.0q[4]) + + 8.0 * q[5] + + 5.0 * q[6], + ]), + MOI.Zeros(1), + ) + end; + cannot_unbridge = true, ) return end