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

Add getter and setters for AbstractOptimizerAttribute #135

Merged
merged 4 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ParametricOptInterface"
uuid = "0ce4ce61-57bf-432b-a095-efac525d185e"
authors = ["Tomás Gutierrez <[email protected]>"]
version = "0.5.0"
version = "0.5.1"

[deps]
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
Expand Down
13 changes: 13 additions & 0 deletions src/ParametricOptInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,19 @@
return MOI.get(model.optimizer, MOI.RawStatusString())
end

function MOI.supports(model::Optimizer, attr::MOI.AbstractOptimizerAttribute)
return MOI.supports(model.optimizer, attr)
end

function MOI.get(model::Optimizer, attr::MOI.AbstractOptimizerAttribute)
return MOI.get(model.optimizer, attr)
end

function MOI.set(model::Optimizer, attr::MOI.AbstractOptimizerAttribute, value)
MOI.set(model.optimizer, attr, value)
return

Check warning on line 702 in src/ParametricOptInterface.jl

View check run for this annotation

Codecov / codecov/patch

src/ParametricOptInterface.jl#L700-L702

Added lines #L700 - L702 were not covered by tests
end

function MOI.get(model::Optimizer, ::MOI.NumberOfConstraints{F,S}) where {F,S}
return length(MOI.get(model, MOI.ListOfConstraintIndices{F,S}()))
end
Expand Down
9 changes: 9 additions & 0 deletions test/jump_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1055,3 +1055,12 @@ function test_affine_parametric_objective()
@test objective_value(model) ≈ 1.5
@test value(objective_function(model)) ≈ 1.5
end

function test_abstract_optimizer_attributes()
model = Model(() -> POI.Optimizer(GLPK.Optimizer()))
set_attribute(model, "tm_lim", 60 * 1000)
attr = MOI.RawOptimizerAttribute("tm_lim")
@test MOI.supports(unsafe_backend(model), attr)
@test get_attribute(model, "tm_lim") ≈ 60 * 1000
return
end
Loading