Reputation: 711
I want to find the theta that minimizes l2 norm of y-X*theta, and constraint is that some element of theta should equal to 0. How do I do this in MATLAB?
My y is 10x1, X is 10x9, theta is 9x1
I think using gradient descent may be helpful not sure
Upvotes: 0
Views: 99
Reputation: 33532
There are multiple interpretations possible here, because of the informal description.
If you just want to solve the linear least-squares problem and a-priori fix some variables to zero, use matlab's lsqlin and use upper-bound=lower-bound=0
for those variables.
If somehow your task is to solve the same objective subject to something like: at least w values of theta are 0
, this is probably NP-hard (in the general setting) and you would need Mixed-integer Quadratic-Programming or Mixed-integer Second-order-cone Programming. In this case, i'm not sure if there is a solver available. Some open-source solvers would be Bonmin (Couenne, to a lesser degree) or most commercial solvers like (Gurobi, CPLEX, Mosek).
Upvotes: 2