How to add this formula as an objective function?

Hi, I am new here.
I don’t know how to add this formula in my minimization objective function.
image
where //x//_1 stands for the sum of the absolute values of the components of x. (x is a 10x1 array)
Anyone can help me with this?

1 Like

maybe sum(abs.(x)) ? the dot means that the function is applied over all elements of the array (is called broadcasting)

You can handle this problem by lifting it’s formulation, i.e. introducing new dummy decision variable t, adding constraints \quad x ≤ t; \quad -x ≤ t and then modifying the objective function as \lVert Ax - b\rVert_2 + λt. With this formulation we reduced the problem to the classical constrained quadratic program, which can be handled easily with JuMP (check it’s documentation)

1 Like

I don’t think that works if x is a vector (your inequalities interpreted point wise give the infinity norm, not the one norm).

Yes, you are right. This should work:
\min ∥ A x − b ∥_2 + λ \sum_{i=1}^{n} t_i;\quad x \preccurlyeq t ;\quad − x \preccurlyeq t

2 Likes

Yes. I tried this code but Julia returns this error: MethodError: no method matching abs(::Array{VariableRef,1})

It works. Thank you!