Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix support for MOI.TimeLimitSec #101

Merged
merged 6 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -291,7 +298,7 @@ function _optimize!(dest::Optimizer, src::OptimizerCache)
#
end # timeit

#=
#=
Solve modified problem
=#

Expand Down Expand Up @@ -327,7 +334,7 @@ function _optimize!(dest::Optimizer, src::OptimizerCache)
close(f)
end

#=
#=
Fix solution
=#

Expand Down
19 changes: 17 additions & 2 deletions test/moitest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
odow marked this conversation as resolved.
Show resolved Hide resolved
],
)

Expand Down Expand Up @@ -113,7 +115,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
Expand All @@ -125,7 +127,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
Expand Down Expand Up @@ -171,3 +173,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
Loading