From cab4fb4956fc2168caba189833ead9258814022e Mon Sep 17 00:00:00 2001 From: Alexis Montoison Date: Wed, 29 Nov 2023 22:26:32 -0600 Subject: [PATCH 1/5] Add a test for HSL solvers --- Project.toml | 3 ++- test/MOI_wrapper.jl | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 33e01be..8465de9 100644 --- a/Project.toml +++ b/Project.toml @@ -19,6 +19,7 @@ julia = "1.6" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +HSL_jll = "017b0a0e-03f4-516a-9b91-836bbd1904dd" [targets] -test = ["Test"] +test = ["Test", "HSL_jll"] diff --git a/test/MOI_wrapper.jl b/test/MOI_wrapper.jl index 12095ff..30c73e3 100644 --- a/test/MOI_wrapper.jl +++ b/test/MOI_wrapper.jl @@ -7,6 +7,7 @@ module TestMOIWrapper using Ipopt using Test +using HSL_jll const MOI = Ipopt.MOI @@ -491,7 +492,7 @@ function test_ListOfSupportedNonlinearOperators() end function test_SPRAL() - if VERSION < v"1.9" || !haskey(ENV, "OMP_CANCELLATION") + if VERSION < v"1.9" || !haskey(ENV, "OMP_CANCELLATION") || !haskey(ENV, "OMP_PROC_BIND") return end model = Ipopt.Optimizer() @@ -506,6 +507,23 @@ function test_SPRAL() return end +function test_HSL() + bool = @ccall libhsl.LIBHSL_isfunctional()::Bool + !bool && return + for hsl_solver in ("ma27", "ma57", "ma77", "ma86", "ma97") + model = Ipopt.Optimizer() + MOI.set(model, MOI.RawOptimizerAttribute("linear_solver"), hsl_solver) + MOI.set(model, MOI.Silent(), true) + x = MOI.add_variable(model) + MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE) + f = 1.0 * x * x - 4.0 * x + 4.0 + MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f) + MOI.optimize!(model) + @test ≈(MOI.get(model, MOI.VariablePrimal(), x), 2.0; atol = 1e-6) + end + return +end + end # module TestMOIWrapper TestMOIWrapper.runtests() From c3dd93df96b8e5f36645edd3b9f13a48c6c66106 Mon Sep 17 00:00:00 2001 From: Alexis Montoison Date: Wed, 29 Nov 2023 22:33:52 -0600 Subject: [PATCH 2/5] Fix format-check --- test/MOI_wrapper.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/MOI_wrapper.jl b/test/MOI_wrapper.jl index 30c73e3..b8bace6 100644 --- a/test/MOI_wrapper.jl +++ b/test/MOI_wrapper.jl @@ -492,7 +492,9 @@ function test_ListOfSupportedNonlinearOperators() end function test_SPRAL() - if VERSION < v"1.9" || !haskey(ENV, "OMP_CANCELLATION") || !haskey(ENV, "OMP_PROC_BIND") + if VERSION < v"1.9" || + !haskey(ENV, "OMP_CANCELLATION") || + !haskey(ENV, "OMP_PROC_BIND") return end model = Ipopt.Optimizer() From 352da93713c7307466f1257736124096a1885bbd Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Mon, 4 Dec 2023 10:22:21 +1300 Subject: [PATCH 3/5] Update MOI_wrapper.jl --- test/MOI_wrapper.jl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/MOI_wrapper.jl b/test/MOI_wrapper.jl index b8bace6..c9740b7 100644 --- a/test/MOI_wrapper.jl +++ b/test/MOI_wrapper.jl @@ -5,9 +5,10 @@ module TestMOIWrapper -using Ipopt using Test -using HSL_jll + +import HSL_jll +import Ipopt const MOI = Ipopt.MOI @@ -510,8 +511,9 @@ function test_SPRAL() end function test_HSL() - bool = @ccall libhsl.LIBHSL_isfunctional()::Bool - !bool && return + if !(@ccall libhsl.LIBHSL_isfunctional()::Bool) + return + end for hsl_solver in ("ma27", "ma57", "ma77", "ma86", "ma97") model = Ipopt.Optimizer() MOI.set(model, MOI.RawOptimizerAttribute("linear_solver"), hsl_solver) From 3c641f9b387527ee119def73602346cfee4ff1a0 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Mon, 4 Dec 2023 10:24:34 +1300 Subject: [PATCH 4/5] Update Project.toml --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index 8465de9..1204d14 100644 --- a/Project.toml +++ b/Project.toml @@ -11,6 +11,7 @@ OpenBLAS32_jll = "656ef2d0-ae68-5445-9ca0-591084a874a2" PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" [compat] +HSL_jll = "2" Ipopt_jll = "=300.1400.400, =300.1400.1303" MathOptInterface = "1.17" OpenBLAS32_jll = "0.3.10" From 7a66e3e3abd465e2381e8dbcb85732be771b178f Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Mon, 4 Dec 2023 10:32:15 +1300 Subject: [PATCH 5/5] Apply suggestions from code review Co-authored-by: Alexis Montoison <35051714+amontoison@users.noreply.github.com> --- Project.toml | 2 +- test/MOI_wrapper.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 1204d14..13174de 100644 --- a/Project.toml +++ b/Project.toml @@ -11,7 +11,7 @@ OpenBLAS32_jll = "656ef2d0-ae68-5445-9ca0-591084a874a2" PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" [compat] -HSL_jll = "2" +HSL_jll = "2, 2023" Ipopt_jll = "=300.1400.400, =300.1400.1303" MathOptInterface = "1.17" OpenBLAS32_jll = "0.3.10" diff --git a/test/MOI_wrapper.jl b/test/MOI_wrapper.jl index c9740b7..aff2178 100644 --- a/test/MOI_wrapper.jl +++ b/test/MOI_wrapper.jl @@ -511,7 +511,7 @@ function test_SPRAL() end function test_HSL() - if !(@ccall libhsl.LIBHSL_isfunctional()::Bool) + if !(@ccall HSL_jll.libhsl.LIBHSL_isfunctional()::Bool) return end for hsl_solver in ("ma27", "ma57", "ma77", "ma86", "ma97")