Consider a constrained least squares problem
with variable
This problem can be solved in Convex.jl as follows: :
# Make the Convex.jl module available
using Convex, SCS
# Generate random problem data
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.Optimizer(verbose=false))
# Check the status of the problem
problem.status # :Optimal, :Infeasible, :Unbounded etc.
# Get the optimum value
problem.optval