L1-Norm minimization
An answer to this question on Stack Overflow.
Question
I am trying to minimize the following function using Linear programming. I am unable to include the image of my objective function. Click this Objective Function to view what I am trying to optimize. My question is there any library or function in python which can do this optimization for me or should I be writing the code?
Answer
import cvxpy as cp
import numpy as np
N=10
M=100
U = np.random.random((M,N))
m = np.random.random(M)
t = cp.Variable(M)
x = cp.Variable(N)
prob = cp.Problem(cp.Minimize(cp.sum(t)), [-t<=U@x-m, U@x-m<=t])
optimal_value = prob.solve()
print("t=",t.value)
print("x=",x.value)
print("val=",optimal_value)