In [1]:
using Convex
using SCS

In [2]:
m = 4;  n = 5
A = randn(m, n); b = randn(m, 1)

# Create a (column vector) variable of size n x 1.
x = Variable(n)

# The problem is to minimize ||Ax - b||^2 subject to x >= 0
# This can be done by: minimize(objective, constraints)
problem = minimize(sumsquares(A * x - b), [x >= 0])

# Solve the problem by calling solve!
solve!(problem)


----------------------------------------------------------------------------
	SCS v1.2.6 - Splitting Conic Solver
	(c) Brendan O'Donoghue, Stanford University, 2012-2016
----------------------------------------------------------------------------
Lin-sys: sparse-direct, nnz in A = 31
eps = 1.00e-04, alpha = 1.80, max_iters = 20000, normalize = 1, scale = 5.00
Variables n = 8, constraints m = 15
Cones:	primal zero / dual free vars: 1
	linear vars: 6
	soc vars: 8, soc blks: 2
Setup time: 9.72e-04s
----------------------------------------------------------------------------
 Iter | pri res | dua res | rel gap | pri obj | dua obj | kap/tau | time (s)
----------------------------------------------------------------------------
     0|      inf       inf       nan      -inf       inf       inf  6.49e-04 
   100| 5.29e-04  5.38e-03  9.29e-03  1.86e-03  1.13e-02  0.00e+00  7.32e-04 
   200| 1.13e-04  1.13e-03  2.10e-03  1.39e-04  2.24e-03  0.00e+00  8.10e-04 
   300| 2.02e-05  2.01e-04  3.79e-04  1.63e-05  3.95e-04  0.00e+00  8.89e-04 
   380| 4.97e-06  4.92e-05  9.32e-05  3.66e-06  9.68e-05  0.00e+00  9.53e-04 
----------------------------------------------------------------------------
Status: Solved
Timing: Solve time: 9.84e-04s
	Lin-sys: nnz in L factor: 60, avg solve time: 8.92e-07s
	Cones: avg projection time: 8.27e-08s
----------------------------------------------------------------------------
Error metrics:
dist(s, K) = 3.6063e-17, dist(y, K*) = 1.0842e-19, s'y/|s||y| = 3.4564e-17
|Ax + s - b|_2 / (1 + |b|_2) = 4.9671e-06
|A'y + c|_2 / (1 + |c|_2) = 4.9193e-05
|c'x + b'y| / (1 + |c'x| + |b'y|) = 9.3167e-05
----------------------------------------------------------------------------
c'x = 0.0000, -b'y = 0.0001
============================================================================
Out[2]:
3.656985080587803e-6

In [3]:
problem.status


Out[3]:
:Optimal

In [4]:
problem.optval


Out[4]:
3.656985080587803e-6

In [ ]: