From 8701a13f160594391a4d9ffcd70812cac3daaeb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20Besan=C3=A7on?= Date: Thu, 12 Dec 2024 21:02:50 +0100 Subject: [PATCH 1/4] added node limit --- src/MOI_wrapper.jl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/MOI_wrapper.jl b/src/MOI_wrapper.jl index 17dd080..1fafb18 100644 --- a/src/MOI_wrapper.jl +++ b/src/MOI_wrapper.jl @@ -620,6 +620,29 @@ function MOI.get(model::Optimizer, ::MOI.TimeLimitSec) return value == Inf ? nothing : value end +### +### MOI.NodeLimit +### + +MOI.supports(::Optimizer, ::MOI.NodeLimit) = true + +function MOI.set(model::Optimizer, ::MOI.NodeLimit, ::Nothing) + return MOI.set(model, MOI.RawOptimizerAttribute("mip_max_nodes"), typemax(Int32)) +end + +function MOI.set(model::Optimizer, ::MOI.NodeLimit, limit::Real) + return MOI.set( + model, + MOI.RawOptimizerAttribute("mip_max_nodes"), + Int(limit), + ) +end + +function MOI.get(model::Optimizer, ::MOI.NodeLimit) + value = MOI.get(model, MOI.RawOptimizerAttribute("mip_max_nodes")) + return value == typemax(Int32) ? nothing : Float64(value) +end + ### ### MOI.AbsoluteGapTolerance ### From ab0421a92bc616341dec248ea4392b8e101988ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20Besan=C3=A7on?= Date: Thu, 12 Dec 2024 23:06:48 +0100 Subject: [PATCH 2/4] format --- src/MOI_wrapper.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/MOI_wrapper.jl b/src/MOI_wrapper.jl index 1fafb18..3ee4928 100644 --- a/src/MOI_wrapper.jl +++ b/src/MOI_wrapper.jl @@ -627,7 +627,11 @@ end MOI.supports(::Optimizer, ::MOI.NodeLimit) = true function MOI.set(model::Optimizer, ::MOI.NodeLimit, ::Nothing) - return MOI.set(model, MOI.RawOptimizerAttribute("mip_max_nodes"), typemax(Int32)) + return MOI.set( + model, + MOI.RawOptimizerAttribute("mip_max_nodes"), + typemax(Int32), + ) end function MOI.set(model::Optimizer, ::MOI.NodeLimit, limit::Real) From 313e568a7c0d4fb4f4e124e776ace0267b7e723c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20Besan=C3=A7on?= Date: Thu, 12 Dec 2024 23:22:18 +0100 Subject: [PATCH 3/4] valid type --- 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 3ee4928..fae754e 100644 --- a/src/MOI_wrapper.jl +++ b/src/MOI_wrapper.jl @@ -644,7 +644,7 @@ end function MOI.get(model::Optimizer, ::MOI.NodeLimit) value = MOI.get(model, MOI.RawOptimizerAttribute("mip_max_nodes")) - return value == typemax(Int32) ? nothing : Float64(value) + return value == typemax(Int32) ? nothing : Int(value) end ### From 74ff76a3ab380c9b1c919dcc4ca4aa7f303fdc33 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Mon, 16 Dec 2024 13:45:08 +1300 Subject: [PATCH 4/4] Update MOI_wrapper.jl --- src/MOI_wrapper.jl | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/MOI_wrapper.jl b/src/MOI_wrapper.jl index fae754e..f8d5188 100644 --- a/src/MOI_wrapper.jl +++ b/src/MOI_wrapper.jl @@ -627,24 +627,20 @@ end MOI.supports(::Optimizer, ::MOI.NodeLimit) = true function MOI.set(model::Optimizer, ::MOI.NodeLimit, ::Nothing) - return MOI.set( - model, - MOI.RawOptimizerAttribute("mip_max_nodes"), - typemax(Int32), - ) + attr = MOI.RawOptimizerAttribute("mip_max_nodes") + MOI.set(model, attr, typemax(Cint)) + return end function MOI.set(model::Optimizer, ::MOI.NodeLimit, limit::Real) - return MOI.set( - model, - MOI.RawOptimizerAttribute("mip_max_nodes"), - Int(limit), - ) + attr = MOI.RawOptimizerAttribute("mip_max_nodes") + MOI.set(model, attr, Int(limit)) + return end function MOI.get(model::Optimizer, ::MOI.NodeLimit) value = MOI.get(model, MOI.RawOptimizerAttribute("mip_max_nodes")) - return value == typemax(Int32) ? nothing : Int(value) + return value == typemax(Cint) ? nothing : Int(value) end ###