Skip to content

Commit

Permalink
added node limit
Browse files Browse the repository at this point in the history
  • Loading branch information
matbesancon committed Dec 12, 2024
1 parent 562d794 commit 8701a13
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
###
Expand Down

0 comments on commit 8701a13

Please sign in to comment.