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

Fix memory issue in MOI's interface #87

Merged
merged 4 commits into from
Aug 23, 2019
Merged

Fix memory issue in MOI's interface #87

merged 4 commits into from
Aug 23, 2019

Conversation

nrontsis
Copy link
Member

@nrontsis nrontsis commented Aug 16, 2019

_scalecoef was called (by scalecoef) with a wrong parameter d for PositiveSemidefiniteConeTriangle sets. Instead of d=n where n is the number of rows/columns of the PSD matrix, it was called with n*(n+1)/2. Furthermore _scalecoef was memory inefficient.

As a result the MOI interface was having memory issues when n > 1000 (see example below).

This PR avoids this issue by a different implementation of _scalecoef which does not need d.

Example

Download SDPLIB's equalG51.jld2.zip and compare the execution time & memory requirements of the MOI wrapper for the following code before and after the PR

using LinearAlgebra, SparseArrays
using COSMO, JuMP
using JLD2

function solve_sdpa_jump_dual(c, F; solver=COSMO.Optimizer, kwargs...)
    model = Model(with_optimizer(solver; kwargs...))
    m = length(c); n = size(F[1], 1)
    @variable(model, Y[1:n, 1:n], PSD)
    for i = 1:m
        @constraint(model, dot(Y, F[i + 1]) == c[i])
    end
    @objective(model, Max, dot(F[1], Y))

    JuMP.optimize!(model)
    @show JuMP.termination_status(model)
    return value.(Y), JuMP.objective_value(model)
end

@load "equalG51.jld2" c F blocks
solve_sdpa_jump_dual(c, F[:, 1])

@nrontsis nrontsis changed the title Fix bug & type instability. Fix memory issue in MOI's interface Aug 16, 2019
@codecov-io
Copy link

codecov-io commented Aug 16, 2019

Codecov Report

Merging #87 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #87      +/-   ##
==========================================
- Coverage   90.09%   90.08%   -0.02%     
==========================================
  Files          22       22              
  Lines        1707     1704       -3     
==========================================
- Hits         1538     1535       -3     
  Misses        169      169
Impacted Files Coverage Δ
src/MOIWrapper.jl 92.34% <100%> (-0.07%) ⬇️

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 cc32a30...b26da48. Read the comment docs.

migarstka pushed a commit that referenced this pull request Aug 23, 2019
- Fix dimension bug in _scalecoeff
- Remove type instability
@migarstka
Copy link
Member

Thanks Nikitas! That indeed speeds up the problem setup by a lot.

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

Successfully merging this pull request may close these issues.

None yet

3 participants