Least squares Problem with Non Negativity Constraints Let $\mathbf{x}=[x_1,\ldots,x_K]$. I have the following optimization problem:
\begin{array}{rl} 
\min \limits_{\mathbf{x}} & \| \mathbf{Ax}-\mathbf{b} \|^2 \\
\mbox{s.t.} &  x_k\ge 0, \forall k
\end{array}
Please I need your help to solve this problem.
Another thing: my main problem was 
\begin{array}{rl} 
\min \limits_{\mathbf{x}} & \| \mathbf{A'x}-\mathbf{b'} \|^2 \\
\mbox{s.t.} &  x_k\ge 0, \forall k &  \\ & \mathbf{x}^T \mathbf{1}=1 
\end{array}
Then I transformed it to the first problem by including the equality constraint in the objective function. Is it fine  to do so ?

First, the lagrangian function is 
\begin{align}
\mathbf{L}(x,\alpha)=\Vert Ax-b \Vert^2 - \alpha^\mathsf{T} x
\end{align}
Then gradient of lagrangian vanishes at the optimal point:
\begin{align}
\frac{\partial \mathbf{L}}{\partial x} = 2 A^\mathsf{T}(Ax-b)-\alpha=0\\
2A^\mathsf{T}A x= \alpha+2A^\mathsf{T} b\\
\end{align}
If $A^\mathsf{T}A$ is not invertible we can just add a small regualrization term to it, i.e. replace it by $(2A^\mathsf{T}A + \mu I)$ or use moore penrose inverse. 
\begin{align}
 x=(2A^\mathsf{T}A)^\dagger \big(\alpha+2A^\mathsf{T} b\big)+x_0\\
\end{align}
which $x_0$ is a vector in null space of moore penrose inverse term and it vanishes.
The dual function is 
\begin{align}
\max_{\alpha\geq 0 } \min_{x} \mathbf{L(x,\alpha)}
\end{align}
You can easily obtain by putting $x$ into the lagrangian. It's a simple quadratic function with constraints $\alpha \geq 0$ which can be solved using ordinary quadratic solvers.
