From 2a0c0496111df1fbc25ab6dfe2bc18c6aad455fc Mon Sep 17 00:00:00 2001 From: guilhermebodin Date: Wed, 18 Dec 2024 00:03:12 -0300 Subject: [PATCH 1/7] add new kwarg to dual_optimizer --- src/MOI_wrapper.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MOI_wrapper.jl b/src/MOI_wrapper.jl index 1b0a763..37099d9 100644 --- a/src/MOI_wrapper.jl +++ b/src/MOI_wrapper.jl @@ -5,8 +5,8 @@ export DualOptimizer, dual_optimizer -function dual_optimizer(optimizer_constructor) - return () -> DualOptimizer(MOI.instantiate(optimizer_constructor)) +function dual_optimizer(optimizer_constructor; coefficients_type::Type{T} = Float64) where {T <: Number} + return () -> DualOptimizer{T}(MOI.instantiate(optimizer_constructor)) end struct DualOptimizer{T,OT<:MOI.ModelLike} <: MOI.AbstractOptimizer From 73e101ced06a6133d18e7375b1e3b3a76faeaa08 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 19 Dec 2024 09:03:05 +1300 Subject: [PATCH 2/7] Update src/MOI_wrapper.jl --- src/MOI_wrapper.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/MOI_wrapper.jl b/src/MOI_wrapper.jl index 37099d9..9064755 100644 --- a/src/MOI_wrapper.jl +++ b/src/MOI_wrapper.jl @@ -5,7 +5,10 @@ export DualOptimizer, dual_optimizer -function dual_optimizer(optimizer_constructor; coefficients_type::Type{T} = Float64) where {T <: Number} +function dual_optimizer( + optimizer_constructor; + coefficients_type::Type{T} = Float64, +) where {T<:Number} return () -> DualOptimizer{T}(MOI.instantiate(optimizer_constructor)) end From f059862ca9db19c48181760930ec410f7e91cf48 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 19 Dec 2024 14:32:39 +1300 Subject: [PATCH 3/7] Update src/MOI_wrapper.jl --- src/MOI_wrapper.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MOI_wrapper.jl b/src/MOI_wrapper.jl index 9064755..2d1d813 100644 --- a/src/MOI_wrapper.jl +++ b/src/MOI_wrapper.jl @@ -7,7 +7,7 @@ export DualOptimizer, dual_optimizer function dual_optimizer( optimizer_constructor; - coefficients_type::Type{T} = Float64, + coefficient_type::Type{T} = Float64, ) where {T<:Number} return () -> DualOptimizer{T}(MOI.instantiate(optimizer_constructor)) end From 7930590a22767c530e53dda3b5bc90137c9b472f Mon Sep 17 00:00:00 2001 From: guilhermebodin Date: Fri, 20 Dec 2024 20:11:00 -0300 Subject: [PATCH 4/7] add tests --- test/Project.toml | 3 ++- test/Solvers/hypatia_test.jl | 23 +++++++++++++++++++++++ test/runtests.jl | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 test/Solvers/hypatia_test.jl diff --git a/test/Project.toml b/test/Project.toml index 8cde073..ebc8511 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,6 +1,7 @@ [deps] CSDP = "0a46da34-8e4b-519e-b418-48813639ff34" HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b" +Hypatia = "b99e6be6-89ff-11e8-14f8-45c827f4f8f2" JuMP = "4076af6c-e467-56ae-b986-b466b2749572" MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" SCS = "c946c3f1-0d1f-5ce8-9dea-7daa1f7e2d13" @@ -9,4 +10,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] CSDP = "1.0.0" HiGHS = "1.1.0" -SCS = "1.0.1" \ No newline at end of file +SCS = "1.0.1" diff --git a/test/Solvers/hypatia_test.jl b/test/Solvers/hypatia_test.jl new file mode 100644 index 0000000..bdad091 --- /dev/null +++ b/test/Solvers/hypatia_test.jl @@ -0,0 +1,23 @@ +# Copyright (c) 2017: Guilherme Bodin, and contributors +# +# Use of this source code is governed by an MIT-style license that can be found +# in the LICENSE.md file or at https://opensource.org/licenses/MIT. + +using Hypatia +using LinearAlgebra + +@testset "Solve problems with differetn coefficient type" begin + function mineig(::Type{T}) where {T} + model = GenericModel{T}() + d = 3 + @variable(model, x[1:d,1:d] in PSDCone()) + @constraint(model, tr(x) == 1) + @objective(model, Min, real(dot(I,x))) + set_optimizer(model, Dualization.dual_optimizer(Hypatia.Optimizer{T}; coefficient_type = T)) + JuMP.set_silent(model) + optimize!(model) + return objective_value(model) + end + + @test mineig(Float64) ≈ mineig(Float32) +end \ No newline at end of file diff --git a/test/runtests.jl b/test/runtests.jl index e0e4e51..dd32691 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,6 +5,7 @@ using Dualization using JuMP +using LinearAlgebra using Test MOI.Utilities.@model( @@ -102,6 +103,7 @@ primal_power_cone_optimizer = [] include("Solvers/highs_test.jl") include("Solvers/csdp_test.jl") include("Solvers/scs_test.jl") +include("Solvers/hypatia_test.jl") include("Tests/test_JuMP_dualize.jl") include("Tests/test_MOI_wrapper.jl") From 6d0523b82814ac1394df9fcbcd373d320f2ebad3 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Sat, 21 Dec 2024 12:52:58 +1300 Subject: [PATCH 5/7] Update hypatia_test.jl --- test/Solvers/hypatia_test.jl | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/test/Solvers/hypatia_test.jl b/test/Solvers/hypatia_test.jl index bdad091..77e343c 100644 --- a/test/Solvers/hypatia_test.jl +++ b/test/Solvers/hypatia_test.jl @@ -3,21 +3,22 @@ # Use of this source code is governed by an MIT-style license that can be found # in the LICENSE.md file or at https://opensource.org/licenses/MIT. -using Hypatia -using LinearAlgebra +import Hypatia -@testset "Solve problems with differetn coefficient type" begin +@testset "Solve problems with different coefficient_type" begin function mineig(::Type{T}) where {T} - model = GenericModel{T}() - d = 3 - @variable(model, x[1:d,1:d] in PSDCone()) - @constraint(model, tr(x) == 1) - @objective(model, Min, real(dot(I,x))) - set_optimizer(model, Dualization.dual_optimizer(Hypatia.Optimizer{T}; coefficient_type = T)) + model = GenericModel{T}( + Dualization.dual_optimizer( + Hypatia.Optimizer{T}; + coefficient_type = T, + ), + ) JuMP.set_silent(model) + @variable(model, x[1:3, 1:3] in PSDCone()) + @constraint(model, sum(x[i, i] for i in 1:3) == 1) + @objective(model, Min, sum(x[i, i] for i in 1:3)) optimize!(model) return objective_value(model) end - @test mineig(Float64) ≈ mineig(Float32) -end \ No newline at end of file +end From e0d0b8361235df67458e87c0a3607caec5b817f0 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Sat, 21 Dec 2024 12:53:22 +1300 Subject: [PATCH 6/7] Update test/runtests.jl --- test/runtests.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index dd32691..8c923ab 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,7 +5,6 @@ using Dualization using JuMP -using LinearAlgebra using Test MOI.Utilities.@model( From eface43089c9602aef282fc80a93b1db1268a832 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Sat, 21 Dec 2024 12:54:08 +1300 Subject: [PATCH 7/7] Update test/Project.toml --- test/Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Project.toml b/test/Project.toml index ebc8511..419f0f6 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -10,4 +10,5 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] CSDP = "1.0.0" HiGHS = "1.1.0" +Hypatia = "0.8.1" SCS = "1.0.1"