# StructuredOptimization.jl : parsing issue when adding constraints

Hi,

I’m trying to solve a modified LASSO where weights are constrained to be nonnegative, using StructuredOptimization.jl. The documentation suggests this should be possible using a code similar to the one below :

``````using StructuredOptimization

n = 5
p = 10
A = rand(n, p)
y = rand(n)

x = Variable(n)

@minimize ls(A*x-y) + norm(x, 1) st x >= 0.
``````

This however gives me the following error message :
“Sorry, I cannot parse this problem for solver of type PANOC{Float64}”

Does someone (maybe @nantonel or @lostella ?) have any idea what is wrong with this ? Thanks anyway for developping this package which I have found extremly useful and easy to use aside this particular case Glad you’re enjoying the package! Unfortunately you cannot solve that type of problem at the moment…
See the this section of the documentation.

For this particular problem, I think the l_1 norm can be rewritten as sum(x) or 1^Tx (as x is non-negative) and absorbed into the smooth part of the objective. The problem could then be solved with a proximal method (though if your problem is small I’d recommend LBFGS-B).

2 Likes

I was about to suggest the same:

``````using StructuredOptimization

n = 5
p = 10
A = rand(n, p)
y = rand(n)

x = Variable(p)

@minimize ls(A*x-y) + dot(ones(p), x) st x >= 0.0
``````

should do the trick?

Edit: fixed the snippet after @nantonel’s suggestion

2 Likes

Sure ! I’m a bit ashamed to not have noticed this earlier ! Thank you all for your help well then, I’m even more ashamed! Just some minor correction to have the problem accepted:

``````n = 5
p = 10
A = rand(n, p)
y = rand(n)

x = Variable(p)

@minimize ls(A*x-y) + dot(ones(p),x) st x >= 0.0
``````

that is currently `dot` needs inputs to be `(::Array,::Variable)` and `x >= float(0)`.

1 Like

No one needs to feel shame – this is a textbook example of an XY Problem. And for readers, it’s a great reminder to keep this in mind.

2 Likes