Skip to content

Commit

Permalink
Add support for MOI.NodeLimit (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
matbesancon authored Dec 16, 2024
1 parent 562d794 commit cba2a7a
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)
attr = MOI.RawOptimizerAttribute("mip_max_nodes")
MOI.set(model, attr, typemax(Cint))
return
end

function MOI.set(model::Optimizer, ::MOI.NodeLimit, limit::Real)
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(Cint) ? nothing : Int(value)
end

###
### MOI.AbsoluteGapTolerance
###
Expand Down

0 comments on commit cba2a7a

Please sign in to comment.