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 method to comply with JuMP's is_parameter #160

Merged
merged 1 commit into from
Sep 27, 2024
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
11 changes: 11 additions & 0 deletions src/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,17 @@
return false
end

function MOI.is_valid(
model::Optimizer,
ci::MOI.ConstraintIndex{MOI.VariableIndex,MOI.Parameter{T}},
) where {T}
vi = MOI.VariableIndex(ci.value)
if haskey(model.parameters, p_idx(vi))
return true
end
return false

Check warning on line 160 in src/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI_wrapper.jl#L160

Added line #L160 was not covered by tests
end

function MOI.supports(
model::Optimizer,
attr::MOI.VariableName,
Expand Down
1 change: 1 addition & 0 deletions test/moi_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function test_basic_tests()
y, cy = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0))
@test MOI.is_valid(optimizer, x[1])
@test MOI.is_valid(optimizer, y)
@test MOI.is_valid(optimizer, cy)
@test MOI.get(optimizer, POI.ListOfPureVariableIndices()) == x
@test MOI.get(optimizer, MOI.ListOfVariableIndices()) == [x[1], x[2], y]
z = MOI.VariableIndex(4)
Expand Down
Loading