Skip to content

Commit

Permalink
[docs] add simple example "Low-rank matrix completion" (#3888)
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-foster authored Nov 21, 2024
1 parent 7eeee45 commit 701251a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/src/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,18 @@ @article{Peng2007
doi = {10.1137/050641983},
}

@article{RechtFazelParrilo2010,
author = {Recht, Benjamin and Fazel, Maryam and Parrilo, Pablo A.},
title = {Guaranteed Minimum-Rank Solutions of Linear Matrix Equations via Nuclear Norm Minimization},
journal = {SIAM Review},
volume = {52},
number = {3},
pages = {471--501},
year = {2010},
issn = {0036-1445},
url = {https://www.jstor.org/stable/20780168},
}

@article{Zimmerman2011,
author = {Zimmerman, Ray Daniel and Murillo-Sánchez, Carlos Edmundo and Thomas, Robert John},
journal = {IEEE Transactions on Power Systems},
Expand Down
27 changes: 27 additions & 0 deletions docs/src/tutorials/conic/simple_examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,33 @@ S, T = solve_max_cut_sdp([0 5 7 6; 5 0 0 1; 7 0 0 1; 6 1 1 0])

S, T = solve_max_cut_sdp([0 1 5 0; 1 0 0 9; 5 0 0 2; 0 9 2 0])

# ## Low-rank matrix completion

# The matrix completion problem seeks to find the missing entries of a matrix
# with a given (possibly random) subset of fixed entries, such that the completed
# matrix has the lowest attainable rank.
#
# For more details, see [RechtFazelParrilo2010](@cite).

function example_matrix_completion(; svdtol = 1e-6)
rng = Random.MersenneTwister(1234)
n = 20
mask = rand(rng, 1:25, n, n) .== 1
B = randn(rng, n, n)
model = Model(SCS.Optimizer)
@variable(model, X[1:n, 1:n])
@constraint(model, X[mask] .== B[mask])
@variable(model, t)
@constraint(model, [t; vec(X)] in MOI.NormNuclearCone(n, n))
@objective(model, Min, t)
optimize!(model)
@assert is_solved_and_feasible(model)
## Return the approximate rank of the completed matrix to a given tolerance:
return sum(LinearAlgebra.svdvals(value.(X)) .> svdtol)
end

example_matrix_completion()

# ## K-means clustering via SDP

# Given a set of points ``a_1, \ldots, a_m`` in ``\mathbb{R}^n``, allocate them to ``k`` clusters.
Expand Down

0 comments on commit 701251a

Please sign in to comment.