-
Notifications
You must be signed in to change notification settings - Fork 87
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 identity_index_map and fix DoubleDict bug #1329
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,25 @@ function IndexMap(n = 0) | |
DoubleDicts.IndexDoubleDict(), | ||
) | ||
end | ||
function _identity_constraints_map( | ||
model, | ||
index_map::MOIU.DoubleDicts.IndexWithType{F,S}, | ||
) where {F,S} | ||
for ci in MOI.get(model, MOI.ListOfConstraintIndices{F,S}()) | ||
index_map[ci] = ci | ||
end | ||
end | ||
function identity_index_map(model::MOI.ModelLike) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this function needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is every solver going to need to do this? If so, it needs a docstring and to be added to the documentation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I expect it to be used a lot. I can add docstring :) |
||
vis = MOI.get(model, MOI.ListOfVariableIndices()) | ||
index_map = IndexMap(length(vis)) | ||
for vi in vis | ||
index_map[vi] = vi | ||
end | ||
for (F, S) in MOI.get(model, MOI.ListOfConstraints()) | ||
_identity_constraints_map(model, index_map.conmap[F, S]) | ||
end | ||
return index_map | ||
end | ||
|
||
""" | ||
index_map_for_variable_indices(variables) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. I ran into this with the NL writer, but I assumed it was expected behavior.