Last active
February 16, 2021 12:02
-
-
Save loiseaujc/bbcb6679dd088ce37b4e5c002749258c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using LinearAlgebra | |
using Convex, SCS | |
# --> Direct resolution of the measurement equation. | |
lstsq(Θ, y) = Θ \ y | |
# --> Constrained least-squares formulation. | |
function cstrnd_lstsq(Θ, y, Σ) | |
# --> Optimization variable. | |
a = Convex.Variable(length(Σ)) | |
# --> Objective function to be minimized. | |
prob = minimize( sumsquares(Θ * a - y) ) | |
# --> Linear inequality constraints. | |
prob.constraints += abs(a) <= 2Σ | |
# --> Solve the problem using the SCS solver. | |
solve!(prob, SCS.Optimizer()) | |
return Convex.evaluate(a) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment