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

added node limit #259

Merged
merged 4 commits into from
Dec 16, 2024
Merged
Changes from all 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
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 @@
return value == Inf ? nothing : value
end

###
### MOI.NodeLimit
###

MOI.supports(::Optimizer, ::MOI.NodeLimit) = true

Check warning on line 627 in src/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI_wrapper.jl#L627

Added line #L627 was not covered by tests

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
Loading