From d5b95d90eb0543bfe585f41cfd6d06ee34448e6f Mon Sep 17 00:00:00 2001 From: odow Date: Thu, 17 Aug 2023 13:17:31 +1200 Subject: [PATCH 1/6] Fix support for MOI.TimeLimitSec --- src/MOI_wrapper.jl | 15 +++++++++++---- test/moitest.jl | 17 +++++++++++++++-- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/MOI_wrapper.jl b/src/MOI_wrapper.jl index 2597edd..3aa9cb0 100644 --- a/src/MOI_wrapper.jl +++ b/src/MOI_wrapper.jl @@ -125,12 +125,19 @@ end MOI.supports(::Optimizer, ::MOI.TimeLimitSec) = true -function MOI.set(optimizer::Optimizer, ::MOI.TimeLimitSec, value) +function MOI.set(optimizer::Optimizer, ::MOI.TimeLimitSec, value::Real) optimizer.options.time_limit = value + return +end + +function MOI.set(optimizer::Optimizer, ::MOI.TimeLimitSec, ::Nothing) + optimizer.options.time_limit = 3600_00.0 + return end function MOI.get(optimizer::Optimizer, ::MOI.TimeLimitSec) - return optimizer.options.time_limit + value = optimizer.options.time_limit + return value == 3600_00.0 ? nothing : value end MOI.supports(::Optimizer, ::MOI.NumberOfThreads) = false @@ -291,7 +298,7 @@ function _optimize!(dest::Optimizer, src::OptimizerCache) # end # timeit - #= + #= Solve modified problem =# @@ -327,7 +334,7 @@ function _optimize!(dest::Optimizer, src::OptimizerCache) close(f) end - #= + #= Fix solution =# diff --git a/test/moitest.jl b/test/moitest.jl index 7e009f1..9f891e2 100644 --- a/test/moitest.jl +++ b/test/moitest.jl @@ -113,7 +113,7 @@ end include("base_mimo.jl") include("moi_mimo.jl") for i in 2:5 - @testset "MIMO n = $(i)" begin + @testset "MIMO n = $(i)" begin moi_mimo(optimizer_bridged, 123, i, test = true) end end @@ -125,7 +125,7 @@ end # include("base_randsdp.jl") # include("moi_randsdp.jl") # for n in 10:11, m in 10:11 -# @testset "RANDSDP n=$n, m=$m" begin +# @testset "RANDSDP n=$n, m=$m" begin # moi_randsdp(optimizer, 123, n, m, test = true, atol = 1e-1) # end # end @@ -171,3 +171,16 @@ end end include("test_terminationstatus.jl") + +@testset "test_attribute_TimeLimitSec" begin + model = ProxSDP.Optimizer() + @test MOI.supports(model, MOI.TimeLimitSec()) + @test MOI.get(model, MOI.TimeLimitSec()) === nothing + MOI.set(model, MOI.TimeLimitSec(), 0.0) + @test MOI.get(model, MOI.TimeLimitSec()) == 0.0 + MOI.set(model, MOI.TimeLimitSec(), nothing) + @test MOI.get(model, MOI.TimeLimitSec()) === nothing + MOI.set(model, MOI.TimeLimitSec(), 1.0) + @test MOI.get(model, MOI.TimeLimitSec()) == 1.0 + return +end From 73a8fe4a00640049f32e1ad4621092c4bbf27e10 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 14 Sep 2023 14:44:10 +1200 Subject: [PATCH 2/6] Update moitest.jl --- test/moitest.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/moitest.jl b/test/moitest.jl index 9f891e2..1373c17 100644 --- a/test/moitest.jl +++ b/test/moitest.jl @@ -69,6 +69,8 @@ function test_runtests() # time limit hit "test_linear_INFEASIBLE", "test_solve_DualStatus_INFEASIBILITY_CERTIFICATE_VariableIndex_LessThan_max", + # TODO(odow): investigate + "test_HermitianPSDCone_basic", ], ) From b17851462635fb957d421fb3ab875f1c35586cbb Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 14 Sep 2023 15:59:49 +1200 Subject: [PATCH 3/6] Update test/moitest.jl --- test/moitest.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/moitest.jl b/test/moitest.jl index 1373c17..33f6ae9 100644 --- a/test/moitest.jl +++ b/test/moitest.jl @@ -70,7 +70,7 @@ function test_runtests() "test_linear_INFEASIBLE", "test_solve_DualStatus_INFEASIBILITY_CERTIFICATE_VariableIndex_LessThan_max", # TODO(odow): investigate - "test_HermitianPSDCone_basic", + "test_HermitianPSDCone_", ], ) From 3206d08e4434dbc37e29504505c05580d79981a6 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 14 Sep 2023 16:26:39 +1200 Subject: [PATCH 4/6] Update test/moitest.jl --- test/moitest.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/moitest.jl b/test/moitest.jl index 33f6ae9..24ba9f3 100644 --- a/test/moitest.jl +++ b/test/moitest.jl @@ -71,6 +71,7 @@ function test_runtests() "test_solve_DualStatus_INFEASIBILITY_CERTIFICATE_VariableIndex_LessThan_max", # TODO(odow): investigate "test_HermitianPSDCone_", + "test_NormNuclearCone_VectorAffineFunction_with_transform", ], ) From 10bdf8e7af016b6f7fb6164079f570b89b1c3491 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 14 Sep 2023 16:29:11 +1200 Subject: [PATCH 5/6] Update moitest.jl --- test/moitest.jl | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/moitest.jl b/test/moitest.jl index 24ba9f3..530534b 100644 --- a/test/moitest.jl +++ b/test/moitest.jl @@ -49,7 +49,7 @@ function test_runtests() opt = ProxSDP.Optimizer( tol_gap = 1e-6, tol_feasibility= 1e-6, # max_iter = 100_000, - time_limit = 1.0, #seconds FAST + time_limit = 5.0, #seconds FAST warn_on_limit = true, # log_verbose = true, log_freq = 100000 ) @@ -69,9 +69,6 @@ function test_runtests() # time limit hit "test_linear_INFEASIBLE", "test_solve_DualStatus_INFEASIBILITY_CERTIFICATE_VariableIndex_LessThan_max", - # TODO(odow): investigate - "test_HermitianPSDCone_", - "test_NormNuclearCone_VectorAffineFunction_with_transform", ], ) From f5508b64460759b093fe5e1209e1bd9696b0d515 Mon Sep 17 00:00:00 2001 From: odow Date: Thu, 14 Sep 2023 19:08:11 +1200 Subject: [PATCH 6/6] Update --- test/moitest.jl | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/test/moitest.jl b/test/moitest.jl index 530534b..cf35644 100644 --- a/test/moitest.jl +++ b/test/moitest.jl @@ -16,7 +16,7 @@ const optimizer_bridged = MOI.instantiate( ()->ProxSDP.Optimizer( tol_gap = 1e-6, tol_feasibility= 1e-6, # max_iter = 100_000, - time_limit = 3., #seconds FAST + time_limit = 30.0, #seconds FAST warn_on_limit = true, # log_verbose = true, log_freq = 100000 ), @@ -66,24 +66,9 @@ function test_runtests() "test_model_LowerBoundAlreadySet", # poorly scaled problem (solved bellow with higher accuracy) "test_linear_add_constraints", - # time limit hit - "test_linear_INFEASIBLE", - "test_solve_DualStatus_INFEASIBILITY_CERTIFICATE_VariableIndex_LessThan_max", ], ) - MOI.set(model, MOI.RawOptimizerAttribute("time_limit"), 5.0) - MOI.empty!(model) - MOI.Test.test_solve_DualStatus_INFEASIBILITY_CERTIFICATE_VariableIndex_LessThan_max( - model, - config, - ) - MOI.empty!(model) - MOI.Test.test_linear_INFEASIBLE( - model, - config, - ) - MOI.set(model, MOI.RawOptimizerAttribute("tol_primal"), 1e-7) MOI.set(model, MOI.RawOptimizerAttribute("tol_dual"), 1e-7) MOI.set(model, MOI.RawOptimizerAttribute("tol_gap"), 1e-7)