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

BackwardOut{...Objective} -> BackwardOutObjective #121

Merged
merged 12 commits into from
Jun 30, 2021

Conversation

blegat
Copy link
Member

@blegat blegat commented Jun 23, 2021

Follow up of #119
See #114

Closes #122
Closes #123
Closes #125

@blegat blegat force-pushed the bl/backwardoutobj branch 2 times, most recently from 1eb828d to e0bc18e Compare June 23, 2021 22:10
@codecov
Copy link

codecov bot commented Jun 23, 2021

Codecov Report

Merging #121 (f215a12) into master (6a74501) will decrease coverage by 2.29%.
The diff coverage is 60.49%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #121      +/-   ##
==========================================
- Coverage   83.49%   81.20%   -2.30%     
==========================================
  Files           6        6              
  Lines         727      782      +55     
==========================================
+ Hits          607      635      +28     
- Misses        120      147      +27     
Impacted Files Coverage Δ
src/jump_moi_overloads.jl 50.89% <54.83%> (+2.81%) ⬆️
src/diff_opt.jl 83.79% <77.77%> (+0.05%) ⬆️
src/quadratic_diff.jl 99.07% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6a74501...f215a12. Read the comment docs.

Copy link
Member

@joaquimg joaquimg left a comment

Choose a reason for hiding this comment

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

The new attributes are fine. But we should be able to query results sparsely.

@@ -296,10 +310,37 @@ function MOI.set(model::Optimizer, ::BackwardInVariablePrimal, vi::VI, val)
return
end

function MOI.get(model::Optimizer, ::BackwardOut{LinearObjective}, vi::VI)
return _get_dc(model, vi)
function MOI.get(model::Optimizer, ::BackwardOutObjective)
Copy link
Member

Choose a reason for hiding this comment

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

You rarely want all the sensitivities.
If you have a model with many variables this will waste a lot of time while the user might just care about a single variable coefficient.

@matbesancon
Copy link
Collaborator

that's a good point yup, that was the motivation for the MOI attributes in the first place

src/diff_opt.jl Outdated Show resolved Hide resolved
@matbesancon
Copy link
Collaborator

this introduces several elements that are not yet explained? What's the MOItoJuMP and why needed?

@blegat
Copy link
Member Author

blegat commented Jun 24, 2021

The new attributes are fine. But we should be able to query results sparsely.

This is adressed in the last commit.

this introduces several elements that are not yet explained? What's the MOItoJuMP and why needed?

Yes, I should add docstrings. It seems more consistent to return a JuMP.AbstractJuMPScalar than a MOI.AbstractScalarFunction if the getter is called on a JuMP model. The fact that it holds a JuMP model allows it to check that the variables indices given belong to the right model, handle conversion to JuMP functions and printing.


function MOI.get(model::JuMP.Model, attr::BackwardOutObjective)
func = MOI.get(JuMP.backend(model), attr)
return JuMP.jump_function(model, func)
Copy link
Member

Choose a reason for hiding this comment

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

do we still need the function below this one?

Copy link
Member Author

@blegat blegat Jun 25, 2021

Choose a reason for hiding this comment

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

Yes, we still have BackwardOut for the constraints.

@blegat
Copy link
Member Author

blegat commented Jun 25, 2021

In view of the bug #122 being unnoticed by the tests and that I wanted to be sure that we get it right, I thought we could have having integration tests checking for the scalar products between forward and backward diffs, which are unlikely to be correct if there are buts.
I added such tests in the latest commit. It didn't at first and after some debugging (which was so intense I missed the beginning of JuMP-dev talk :/), I found also
#125
#123
I took me some time to nail #123 down ^^

@blegat
Copy link
Member Author

blegat commented Jun 29, 2021

Any objection to merge ?

end

"""
struct MatrixScalarQuadraticFunction{T, VT, MT} <: MOI.AbstractScalarFunction
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we really need the full struct in the docstring?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in latest commit

@joaquimg
Copy link
Member

Go for it!
Next step constraint attributes?

@matbesancon matbesancon merged commit e62ee05 into master Jun 30, 2021
@matbesancon matbesancon deleted the bl/backwardoutobj branch June 30, 2021 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants