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

MOI to MatOI #7

Merged
merged 18 commits into from Nov 2, 2020
Merged

MOI to MatOI #7

merged 18 commits into from Nov 2, 2020

Conversation

akshay326
Copy link
Contributor

My bad. Took a whole week. But generates matrices!

@akshay326
Copy link
Contributor Author

Almost the same code as https://github.com/jump-dev/SCS.jl/blob/master/src/MOI_wrapper.jl
tested and works on COSMO, ProxSDP too

@codecov
Copy link

codecov bot commented Aug 5, 2020

Codecov Report

Merging #7 into master will decrease coverage by 3.22%.
The diff coverage is 79.16%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #7      +/-   ##
==========================================
- Coverage   86.14%   82.91%   -3.23%     
==========================================
  Files           3        5       +2     
  Lines         166      281     +115     
==========================================
+ Hits          143      233      +90     
- Misses         23       48      +25     
Impacted Files Coverage Δ
src/MatrixOptInterface.jl 88.00% <ø> (ø)
src/conic_form.jl 79.00% <79.00%> (ø)
src/sparse_matrix.jl 80.00% <80.00%> (ø)
src/matrix_input.jl 98.41% <0.00%> (-0.12%) ⬇️

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 f42e602...0544031. Read the comment docs.

@blegat
Copy link
Member

blegat commented Aug 5, 2020

Nice, could you adapt it to be closer to the matrix.jl and geometric.jl files in jump-dev/SCS.jl#192 ?

Copy link
Contributor

@frapac frapac left a comment

Choose a reason for hiding this comment

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

Thanks for this contribution! I have just an overall question: is there some plan to add a function getLinearForm, similar in spirit as getConicForm but for linear problems? If so, how hard it would be to adapt the function getConicForm to the linear case?

src/matrix_input.jl Outdated Show resolved Hide resolved
src/matrix_input.jl Outdated Show resolved Hide resolved
src/matrix_input.jl Outdated Show resolved Hide resolved
src/conic_form.jl Outdated Show resolved Hide resolved
src/conic_form.jl Outdated Show resolved Hide resolved
src/conic_form.jl Outdated Show resolved Hide resolved
src/conic_form.jl Outdated Show resolved Hide resolved
src/conic_form.jl Outdated Show resolved Hide resolved
src/conic_form.jl Outdated Show resolved Hide resolved
@akshay326
Copy link
Contributor Author

Thanks for this contribution! I have just an overall question: is there some plan to add a function getLinearForm, similar in spirit as getConicForm but for linear problems? If so, how hard it would be to adapt the function getConicForm to the linear case?

we did'nt plan getting the linear case. although it shudn't be much difficult - i tried extracting the matrices given LessThan, EqualTo, GreaterThan constraints

src/conic_form.jl Outdated Show resolved Hide resolved
src/conic_form.jl Outdated Show resolved Hide resolved
src/conic_form.jl Outdated Show resolved Hide resolved
test/conic_form.jl Outdated Show resolved Hide resolved
src/matrix_input.jl Outdated Show resolved Hide resolved
@matbesancon
Copy link
Collaborator

is there a specific convention on using double underscore for functions? It doesn't read that well

@akshay326
Copy link
Contributor Author

is there a specific convention on using double underscore for functions? It doesn't read that well

yep removed them now

@akshay326
Copy link
Contributor Author

having a hard time moving from get_conic_form to MOI.copy_to. @blegat can u share some example using MOI.copy_to on GeometricConicForm in action

@blegat
Copy link
Member

blegat commented Aug 13, 2020

If I understand correctly, you need something close to get_conic_form for DiffOpt. If copy_to is given, you can do something like:

function get_conic_form(::Type{T}, src::MOI.ModelLike, con_idx)
    dest = ConicForm{T, ...}()
    idxmap = MOI.copy_to(dest, src)
    return dest
end

except that you only need the constraints in con_idx, is that right ? Do you need to filter the constraints for DiffOpt or is a matrix with all constraints sufficient ?

@akshay326
Copy link
Contributor Author

took a lot of time but using MOI.copy_to now!
finally I understand that I was using a lot of SCS specific code

src/conic_form.jl Outdated Show resolved Hide resolved
Project.toml Outdated Show resolved Hide resolved
trimap(i::Integer, j::Integer) = i < j ? trimap(j, i) : div((i-1)*i, 2) + j
trimapL(i::Integer, j::Integer, n::Integer) = i < j ? trimapL(j, i, n) : i + div((2n-j) * (j-1), 2)
sympackedLtoU(x, n=sympackeddim(length(x))) = _sympackedto(x, n, (i, j) -> trimapL(i, j, n), trimap)
sympackedUtoL(x, n) = _sympackedto(x, n, trimap, (i, j) -> trimapL(i, j, n))
Copy link
Member

Choose a reason for hiding this comment

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

Why are these here? This is specific to SCS needing to scale off diagonal entries, do you need this too in DiffOpt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry for the late response.
yes, we need at least this part to scale diagonal entries for a PSD cone. my only source of cross checking the actual values was https://github.com/cvxgrp/diffcp, which accepts/returns matrices in SCS format

Copy link
Member

Choose a reason for hiding this comment

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

It doesn't make much sense to do it by default for the conic form. I would suggest DiffOpt to use something like
https://github.com/jump-dev/SCS.jl/blob/c1e3a8d5469e9f289dd0b3cdd87245792d266317/src/MOI_wrapper.jl#L147
In the future, if the scaled psd cone is brought back then SCS and DiffOpt could use this without any preprocessing function.

Copy link
Member

Choose a reason for hiding this comment

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

See jump-dev/MathOptInterface.jl#531 for the scaled psd cone

Copy link
Contributor Author

@akshay326 akshay326 Oct 15, 2020

Choose a reason for hiding this comment

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

ok got it now. will need to correct the tests accordingly!

Copy link
Member

Choose a reason for hiding this comment

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

should I check the presence of SCS/Mosek solver and edit the matrices accordingly - so that for every solver matrix A is same

Not sure to understand what you mean

Copy link
Contributor Author

Choose a reason for hiding this comment

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

forgot to edit the comment 😅 . saw the conic solver info at https://github.com/cvxgrp/cvxpy/tree/master/cvxpy/reductions/solvers/conic_solvers and understood this trimap thing is specific to SCS and shouldn't be a part of MatOI

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@blegat is this PR good to go? or is there anything specific to SCS that I'm missing

Copy link
Member

@blegat blegat left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for the sustained effort on this PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants