diff --git a/src/MOI_wrapper.jl b/src/MOI_wrapper.jl index 1b0a763..2d1d813 100644 --- a/src/MOI_wrapper.jl +++ b/src/MOI_wrapper.jl @@ -5,8 +5,11 @@ export DualOptimizer, dual_optimizer -function dual_optimizer(optimizer_constructor) - return () -> DualOptimizer(MOI.instantiate(optimizer_constructor)) +function dual_optimizer( + optimizer_constructor; + coefficient_type::Type{T} = Float64, +) where {T<:Number} + return () -> DualOptimizer{T}(MOI.instantiate(optimizer_constructor)) end struct DualOptimizer{T,OT<:MOI.ModelLike} <: MOI.AbstractOptimizer diff --git a/test/Project.toml b/test/Project.toml index 8cde073..419f0f6 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,5 @@ 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 +Hypatia = "0.8.1" +SCS = "1.0.1" diff --git a/test/Solvers/hypatia_test.jl b/test/Solvers/hypatia_test.jl new file mode 100644 index 0000000..77e343c --- /dev/null +++ b/test/Solvers/hypatia_test.jl @@ -0,0 +1,24 @@ +# 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. + +import Hypatia + +@testset "Solve problems with different coefficient_type" begin + function mineig(::Type{T}) where {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 diff --git a/test/runtests.jl b/test/runtests.jl index e0e4e51..8c923ab 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -102,6 +102,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")