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

bug fixes in QP backend #90

Merged
merged 2 commits into from
May 5, 2021
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
10 changes: 5 additions & 5 deletions src/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,13 @@ end

function MOI.get(model::Optimizer,
::ForwardIn{QuadraticObjective}, vi1::VI, vi2::VI)
tuple = ifelse(index(vi1) <= index(vi2), (vi1, vi2), (vi2, vi1))
return get(model.input_cache.dQ, tuple, 0.0)
idx = ifelse(vi1.value <= vi2.value, (vi1, vi2), (vi2, vi1))
return get(model.input_cache.dQ, idx, 0.0)
end
function MOI.set(model::Optimizer,
::ForwardIn{QuadraticObjective}, vi1::VI, vi2::VI, val)
tuple = ifelse(index(vi1) <= index(vi2), (vi1, vi2), (vi2, vi1))
model.input_cache.dQ[tuple] = val
idx = ifelse(vi1.value <= vi2.value, (vi1, vi2), (vi2, vi1))
model.input_cache.dQ[idx] = val
return
end

Expand Down Expand Up @@ -871,7 +871,7 @@ function _fill_quad_Q(model, dQv, dQi, dQj, index_map)
for ((vi1, vi2), val) in dict_dQ
i = index_map[vi1].value
j = index_map[vi2].value
for (vi, val) in dict
for (vi, val) in dict_dQ
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok this is weird that this wasn't caught by tests before

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joaquimg should there be a test where dict_dQ gets used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep. i guess with more examples common, such bugs (if any) will surface

push!(dQv, val)
push!(dQi, i)
push!(dQj, j)
Expand Down